]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Move TPM passthrough specific command line options to backend structure
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Mon, 22 Apr 2013 14:41:39 +0000 (10:41 -0400)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 23 Apr 2013 15:40:40 +0000 (10:40 -0500)
Move the TPM passthrough specific command line options to the passthrough
backend implementation and attach them to the backend's interface structure.

Add code to tpm.c for validating the TPM command line options.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Corey Bryan <coreyb@linux.vnet.ibm.com>
Message-id: 1366641699-21420-1-git-send-email-stefanb@linux.vnet.ibm.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/tpm/tpm_int.h
hw/tpm/tpm_passthrough.c
include/sysemu/tpm_backend.h
tpm.c
vl.c

index 08f87cb9a8e97abcc84b9651dec2f85b67982216..2f582caaee6e332b27ad0fc9052fe6a2c35081f3 100644 (file)
@@ -33,6 +33,13 @@ struct TPMState {
 
 #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
 
+#define TPM_STANDARD_CMDLINE_OPTS \
+    { \
+        .name = "type", \
+        .type = QEMU_OPT_STRING, \
+        .help = "Type of TPM backend", \
+    }
+
 struct tpm_req_hdr {
     uint16_t tag;
     uint32_t len;
index ce74e97043dc5cf8c81e97d9706c5c99d21497cf..56e9e0f8a211492a9ae8fac5190d2aa1b6b7cabd 100644 (file)
@@ -488,8 +488,24 @@ static void tpm_passthrough_destroy(TPMBackend *tb)
     g_free(tpm_pt->tpm_dev);
 }
 
+static const QemuOptDesc tpm_passthrough_cmdline_opts[] = {
+    TPM_STANDARD_CMDLINE_OPTS,
+    {
+        .name = "cancel-path",
+        .type = QEMU_OPT_STRING,
+        .help = "Sysfs file entry for canceling TPM commands",
+    },
+    {
+        .name = "path",
+        .type = QEMU_OPT_STRING,
+        .help = "Path to TPM device on the host",
+    },
+    { /* end of list */ },
+};
+
 static const TPMDriverOps tpm_passthrough_driver = {
     .type                     = TPM_TYPE_PASSTHROUGH,
+    .opts                     = tpm_passthrough_cmdline_opts,
     .desc                     = tpm_passthrough_create_desc,
     .create                   = tpm_passthrough_create,
     .destroy                  = tpm_passthrough_destroy,
index 466787453dd736a08657b06ec2487970bf07d855..825f33bdc3e1c0bcf796ed8ee325de81e7b6f8c4 100644 (file)
@@ -65,6 +65,7 @@ typedef struct TPMSizedBuffer {
 
 struct TPMDriverOps {
     enum TpmType type;
+    const QemuOptDesc *opts;
     /* get a descriptive text of the backend to display to the user */
     const char *(*desc)(void);
 
diff --git a/tpm.c b/tpm.c
index c91da43cf1b4ac2e5176fcdc3dd238389fb5d9b8..f13c9bc80c769b661fd843a2e739e290c1283eff 100644 (file)
--- a/tpm.c
+++ b/tpm.c
@@ -159,6 +159,14 @@ static int configure_tpm(QemuOpts *opts)
         return 1;
     }
 
+    /* validate backend specific opts */
+    qemu_opts_validate(opts, be->opts, &local_err);
+    if (error_is_set(&local_err)) {
+        qerror_report_err(local_err);
+        error_free(local_err);
+        return 1;
+    }
+
     drv = be->create(opts, id);
     if (!drv) {
         return 1;
diff --git a/vl.c b/vl.c
index 6caa5f4272e318af725e23f0dc252717f5d626c1..2e0d1a744cf48373a21e74a849c803da2e0a776f 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -502,21 +502,7 @@ static QemuOptsList qemu_tpmdev_opts = {
     .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 = "cancel-path",
-            .type = QEMU_OPT_STRING,
-            .help = "Sysfs file entry for canceling TPM commands",
-        },
-        {
-            .name = "path",
-            .type = QEMU_OPT_STRING,
-            .help = "Path to TPM device on the host",
-        },
+        /* options are defined in the TPM backends */
         { /* end of list */ }
     },
 };