qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 2/3] Add command line options for TPM interface


From: Andreas Niederl
Subject: [Qemu-devel] [PATCH 2/3] Add command line options for TPM interface
Date: Wed, 25 Aug 2010 18:33:01 +0200

Signed-off-by: Andreas Niederl <address@hidden>
---
 hw/pc.h         |    5 +++++
 qemu-config.c   |   12 ++++++++++++
 qemu-config.h   |    1 +
 qemu-options.hx |    6 ++++++
 vl.c            |   25 +++++++++++++++++++++++++
 5 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/hw/pc.h b/hw/pc.h
index 63b0249..d95020c 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -176,4 +176,9 @@ void isa_ne2000_init(int base, int irq, NICInfo *nd);
 
 int e820_add_entry(uint64_t, uint64_t, uint32_t);
 
+#ifdef CONFIG_TPM
+/* tpm.c */
+extern int tpm_init(QemuOpts *opts);
+#endif
+
 #endif
diff --git a/qemu-config.c b/qemu-config.c
index 3abe655..aedca13 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -336,6 +336,18 @@ static QemuOptsList qemu_cpudef_opts = {
     },
 };
 
+QemuOptsList qemu_tpm_opts = {
+    .name = "tpm",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_tpm_opts.head),
+    .desc = {
+        {
+            .name = "dev",
+            .type = QEMU_OPT_STRING,
+        },
+        { /*End of list */ }
+    },
+};
+
 static QemuOptsList *vm_config_groups[32] = {
     &qemu_drive_opts,
     &qemu_chardev_opts,
diff --git a/qemu-config.h b/qemu-config.h
index 533a049..492a35d 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -3,6 +3,7 @@
 
 extern QemuOptsList qemu_fsdev_opts;
 extern QemuOptsList qemu_virtfs_opts;
+extern QemuOptsList qemu_tpm_opts;
 
 QemuOptsList *qemu_find_opts(const char *group);
 void qemu_add_opts(QemuOptsList *list);
diff --git a/qemu-options.hx b/qemu-options.hx
index 453f129..771990b 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2230,6 +2230,12 @@ Normally QEMU loads a configuration file from 
@var{sysconfdir}/qemu.conf and
 @var{sysconfdir}/address@hidden on startup.  The @code{-nodefconfig}
 option will prevent QEMU from loading these configuration files at startup.
 ETEXI
+#ifdef CONFIG_TPM
+DEF("tpm", HAS_ARG, QEMU_OPTION_tpm,
+    "-tpm dev=<device>\n"
+    "                enable TPM support and forward commands to the given TPM 
device file\n",
+    QEMU_ARCH_I386)
+#endif
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/vl.c b/vl.c
index 91d1684..fe35f49 100644
--- a/vl.c
+++ b/vl.c
@@ -1541,6 +1541,16 @@ static int fsdev_init_func(QemuOpts *opts, void *opaque)
 }
 #endif
 
+#ifdef CONFIG_TPM
+static int tpm_init_func(QemuOpts *opts, void *opaque)
+{
+    if (tpm_init(opts) != 0) {
+        return 1;
+    }
+    return 0;
+}
+#endif
+
 static int mon_init_func(QemuOpts *opts, void *opaque)
 {
     CharDriverState *chr;
@@ -1860,6 +1870,10 @@ int main(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_virtfs_opts);
 #endif
 
+#ifdef CONFIG_TPM
+    qemu_add_opts(&qemu_tpm_opts);
+#endif
+
     /* first pass of option parsing */
     optind = 1;
     while (optind < argc) {
@@ -2360,6 +2374,12 @@ int main(int argc, char **argv, char **envp)
                 qemu_free(arg_9p);
                 break;
             }
+            case QEMU_OPTION_tpm:
+                opts = qemu_opts_parse(&qemu_tpm_opts, optarg, 0);
+                if (!opts) {
+                    exit(1);
+                }
+                break;
             case QEMU_OPTION_serial:
                 add_device_config(DEV_SERIAL, optarg);
                 default_serial = 0;
@@ -2713,6 +2733,11 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 #endif
+#ifdef CONFIG_TPM
+    if (qemu_opts_foreach(&qemu_tpm_opts, tpm_init_func, NULL, 1) != 0) {
+        exit(1);
+    }
+#endif
 
     os_daemonize();
 
-- 
1.7.2.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]