qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 4/5] Add configure script and command line options f


From: Andreas Niederl
Subject: [Qemu-devel] [PATCH 4/5] Add configure script and command line options for TPM interface.
Date: Fri, 18 Feb 2011 16:33:34 +0100

Signed-off-by: Andreas Niederl <address@hidden>
---
 configure       |    9 +++++++++
 qemu-config.c   |   16 ++++++++++++++++
 qemu-config.h   |    1 +
 qemu-options.hx |    6 ++++++
 vl.c            |   22 ++++++++++++++++++++++
 5 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index a3f5345..7addec3 100755
--- a/configure
+++ b/configure
@@ -316,6 +316,7 @@ case "$cpu" in
   ;;
 esac
 
+tpm="no"
 # OS specific
 if check_define __linux__ ; then
   targetos="Linux"
@@ -455,6 +456,7 @@ Haiku)
   usb="linux"
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
+    tpm="yes"
   fi
 ;;
 esac
@@ -713,6 +715,8 @@ for opt do
   ;;
   --enable-vhost-net) vhost_net="yes"
   ;;
+  --disable-tpm) tpm="no"
+  ;;
   --*dir)
   ;;
   --disable-rbd) rbd="no"
@@ -914,6 +918,7 @@ echo "                           Default:trace-<pid>"
 echo "  --disable-spice          disable spice"
 echo "  --enable-spice           enable spice"
 echo "  --enable-rbd             enable building the rados block device (rbd)"
+echo "  --disable-tpm            disable tpm passthrough device emulation"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
@@ -2478,6 +2483,7 @@ echo "Trace output file $trace_file-<pid>"
 echo "spice support     $spice"
 echo "rbd support       $rbd"
 echo "xfsctl support    $xfs"
+echo "tpm support       $tpm"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2739,6 +2745,9 @@ fi
 if test "$fdatasync" = "yes" ; then
   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
 fi
+if test "$tpm" = "yes" ; then
+  echo "CONFIG_TPM=y" >> $config_host_mak
+fi
 if test "$madvise" = "yes" ; then
   echo "CONFIG_MADVISE=y" >> $config_host_mak
 fi
diff --git a/qemu-config.c b/qemu-config.c
index 323d3c2..fe3a2ae 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -451,6 +451,22 @@ QemuOptsList qemu_option_rom_opts = {
     },
 };
 
+QemuOptsList qemu_tpm_opts = {
+    .name = "tpm",
+    .implied_opt_name = "type",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_tpm_opts.head),
+    .desc = {
+        {
+            .name = "type",
+            .type = QEMU_OPT_STRING,
+        },{
+            .name = "path",
+            .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 20d707f..eed9b3f 100644
--- a/qemu-config.h
+++ b/qemu-config.h
@@ -4,6 +4,7 @@
 extern QemuOptsList qemu_fsdev_opts;
 extern QemuOptsList qemu_virtfs_opts;
 extern QemuOptsList qemu_spice_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 945edf3..cf4494d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2339,6 +2339,12 @@ STEXI
 Specify a trace file to log output traces to.
 ETEXI
 #endif
+#ifdef CONFIG_TPM
+DEF("tpm", HAS_ARG, QEMU_OPTION_tpm,
+    "-tpm host,id=id,path=path\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 f74f37a..4bafcce 100644
--- a/vl.c
+++ b/vl.c
@@ -1651,6 +1651,14 @@ static int fsdev_init_func(QemuOpts *opts, void *opaque)
 #endif
 
 #ifdef CONFIG_TPM
+static int tpm_init_func(QemuOpts *opts, void *opaque)
+{
+    int ret;
+    ret = qemu_tpm_add(opts);
+
+    return ret;
+}
+
 static int tpm_acpi_init_func(QemuOpts *opts, void *opaque)
 {
     int ret = 0;
@@ -1993,6 +2001,10 @@ int main(int argc, char **argv, char **envp)
     tb_size = 0;
     autostart= 1;
 
+#ifdef CONFIG_TPM
+    qemu_add_opts(&qemu_tpm_opts);
+#endif
+
     /* first pass of option parsing */
     optind = 1;
     while (optind < argc) {
@@ -2493,6 +2505,13 @@ int main(int argc, char **argv, char **envp)
                 qemu_free(arg_9p);
                 break;
             }
+            case QEMU_OPTION_tpm:
+               opts = qemu_opts_parse(qemu_find_opts("tpm"), optarg, 0);
+               if (!opts) {
+                   fprintf(stderr, "parse error: %s\n", optarg);
+                   exit(1);
+               }
+               break;
             case QEMU_OPTION_serial:
                 add_device_config(DEV_SERIAL, optarg);
                 default_serial = 0;
@@ -2881,6 +2900,9 @@ int main(int argc, char **argv, char **envp)
 #endif
 
 #ifdef CONFIG_TPM
+    if (qemu_opts_foreach(qemu_find_opts("tpm"), tpm_init_func, NULL, 1) != 0) 
{
+        exit(1);
+    }
     /* register TPM acpi table before machine->init is called */
     if (qemu_opts_foreach(qemu_find_opts("device"), tpm_acpi_init_func, NULL, 
1) != 0) {
         exit(1);
-- 
1.7.4.1




reply via email to

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