aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.vnet.ibm.com>2013-02-27 12:47:49 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2013-03-12 13:40:11 -0500
commitd1a0cf738dab24fbfd8e9225b7f3df43dcfafc06 (patch)
tree56858e1759fe3e14f2acfc0a83297ff2bb61c72a /vl.c
parentfe3cc14fd83e0c8f376d849ccd0fc3433388442d (diff)
downloadqemu-d1a0cf738dab24fbfd8e9225b7f3df43dcfafc06.zip
qemu-d1a0cf738dab24fbfd8e9225b7f3df43dcfafc06.tar.gz
qemu-d1a0cf738dab24fbfd8e9225b7f3df43dcfafc06.tar.bz2
Support for TPM command line options
This patch adds support for TPM command line options. The command line options supported here are ./qemu-... -tpmdev passthrough,path=<path to TPM device>,id=<id> -device tpm-tis,tpmdev=<id>,id=<other id> and ./qemu-... -tpmdev help where the latter works similar to -soundhw help and shows a list of available TPM backends (for example 'passthrough'). Using the type parameter, the backend is chosen, i.e., 'passthrough' for the passthrough driver. The interpretation of the other parameters along with determining whether enough parameters were provided is pushed into the backend driver, which needs to implement the interface function 'create' and return a TPMDriverOpts structure if the VM can be started or 'NULL' if not enough or bad parameters were provided. Monitor support for 'info tpm' has been added. It for example prints the following: (qemu) info tpm TPM devices: tpm0: model=tpm-tis \ tpm0: type=passthrough,path=/dev/tpm0,cancel-path=/sys/devices/pnp0/00:09/cancel Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com> Reviewed-by: Joel Schopp <jschopp@linux.vnet.ibm.com> Message-id: 1361987275-26289-2-git-send-email-stefanb@linux.vnet.ibm.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index 154f7ba..0c6c2bf 100644
--- a/vl.c
+++ b/vl.c
@@ -139,6 +139,7 @@ int main(int argc, char **argv)
#include "sysemu/blockdev.h"
#include "hw/block-common.h"
#include "migration/block.h"
+#include "tpm/tpm.h"
#include "sysemu/dma.h"
#include "audio/audio.h"
#include "migration/migration.h"
@@ -491,6 +492,25 @@ static QemuOptsList qemu_object_opts = {
},
};
+static QemuOptsList qemu_tpmdev_opts = {
+ .name = "tpmdev",
+ .implied_opt_name = "type",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_tpmdev_opts.head),
+ .desc = {
+ {
+ .name = "type",
+ .type = QEMU_OPT_STRING,
+ .help = "Type of TPM backend",
+ },
+ {
+ .name = "path",
+ .type = QEMU_OPT_STRING,
+ .help = "Path to TPM device on the host",
+ },
+ { /* end of list */ }
+ },
+};
+
const char *qemu_get_vm_name(void)
{
return qemu_name;
@@ -2868,6 +2888,7 @@ int main(int argc, char **argv, char **envp)
qemu_add_opts(&qemu_sandbox_opts);
qemu_add_opts(&qemu_add_fd_opts);
qemu_add_opts(&qemu_object_opts);
+ qemu_add_opts(&qemu_tpmdev_opts);
runstate_init();
@@ -3231,6 +3252,13 @@ int main(int argc, char **argv, char **envp)
}
break;
}
+#ifdef CONFIG_TPM
+ case QEMU_OPTION_tpmdev:
+ if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
+ exit(1);
+ }
+ break;
+#endif
case QEMU_OPTION_mempath:
mem_path = optarg;
break;
@@ -4108,6 +4136,12 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+#ifdef CONFIG_TPM
+ if (tpm_init() < 0) {
+ exit(1);
+ }
+#endif
+
/* init the bluetooth world */
if (foreach_device_config(DEV_BT, bt_parse))
exit(1);
@@ -4353,6 +4387,9 @@ int main(int argc, char **argv, char **envp)
bdrv_close_all();
pause_all_vcpus();
res_free();
+#ifdef CONFIG_TPM
+ tpm_cleanup();
+#endif
return 0;
}