qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] tpm: Move TPM passthrough specific command line options to backend structure
@ 2013-04-12 21:59 Stefan Berger
  2013-04-16 21:33 ` Corey Bryant
  2013-04-22 14:17 ` Anthony Liguori
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Berger @ 2013-04-12 21:59 UTC (permalink / raw)
  To: qemu-devel@nongnu.org; +Cc: coreyb

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>

---
 tpm/tpm.c             |    8 ++++++++
 tpm/tpm_int.h         |    8 ++++++++
 tpm/tpm_passthrough.c |   16 ++++++++++++++++
 vl.c                  |   16 +---------------
 4 files changed, 33 insertions(+), 15 deletions(-)

Index: qemu-git.pt/vl.c
===================================================================
--- qemu-git.pt.orig/vl.c
+++ qemu-git.pt/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 */ }
     },
 };
Index: qemu-git.pt/tpm/tpm.c
===================================================================
--- qemu-git.pt.orig/tpm/tpm.c
+++ qemu-git.pt/tpm/tpm.c
@@ -174,6 +174,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;
Index: qemu-git.pt/tpm/tpm_passthrough.c
===================================================================
--- qemu-git.pt.orig/tpm/tpm_passthrough.c
+++ qemu-git.pt/tpm/tpm_passthrough.c
@@ -512,8 +512,24 @@ static void tpm_passthrough_destroy(TPMB
     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 */ },
+};
+
 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: qemu-git.pt/tpm/tpm_int.h
===================================================================
--- qemu-git.pt.orig/tpm/tpm_int.h
+++ qemu-git.pt/tpm/tpm_int.h
@@ -35,6 +35,7 @@ struct TPMState {
 
 struct TPMDriverOps {
     enum TpmType type;
+    const QemuOptDesc *opts;
     /* get a descriptive text of the backend to display to the user */
     const char *(*desc)(void);
 
@@ -59,6 +60,13 @@ struct TPMDriverOps {
     bool (*get_tpm_established_flag)(TPMBackend *t);
 };
 
+#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;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] tpm: Move TPM passthrough specific command line options to backend structure
  2013-04-12 21:59 [Qemu-devel] [PATCH v2] tpm: Move TPM passthrough specific command line options to backend structure Stefan Berger
@ 2013-04-16 21:33 ` Corey Bryant
  2013-04-22 14:17 ` Anthony Liguori
  1 sibling, 0 replies; 4+ messages in thread
From: Corey Bryant @ 2013-04-16 21:33 UTC (permalink / raw)
  To: Stefan Berger; +Cc: qemu-devel@nongnu.org



On 04/12/2013 05:59 PM, Stefan Berger wrote:
> 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>
>
> ---
>   tpm/tpm.c             |    8 ++++++++
>   tpm/tpm_int.h         |    8 ++++++++
>   tpm/tpm_passthrough.c |   16 ++++++++++++++++
>   vl.c                  |   16 +---------------
>   4 files changed, 33 insertions(+), 15 deletions(-)
>
> Index: qemu-git.pt/vl.c
> ===================================================================
> --- qemu-git.pt.orig/vl.c
> +++ qemu-git.pt/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 */ }
>       },
>   };
> Index: qemu-git.pt/tpm/tpm.c
> ===================================================================
> --- qemu-git.pt.orig/tpm/tpm.c
> +++ qemu-git.pt/tpm/tpm.c
> @@ -174,6 +174,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;
> Index: qemu-git.pt/tpm/tpm_passthrough.c
> ===================================================================
> --- qemu-git.pt.orig/tpm/tpm_passthrough.c
> +++ qemu-git.pt/tpm/tpm_passthrough.c
> @@ -512,8 +512,24 @@ static void tpm_passthrough_destroy(TPMB
>       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 */ },
> +};
> +
>   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: qemu-git.pt/tpm/tpm_int.h
> ===================================================================
> --- qemu-git.pt.orig/tpm/tpm_int.h
> +++ qemu-git.pt/tpm/tpm_int.h
> @@ -35,6 +35,7 @@ struct TPMState {
>
>   struct TPMDriverOps {
>       enum TpmType type;
> +    const QemuOptDesc *opts;
>       /* get a descriptive text of the backend to display to the user */
>       const char *(*desc)(void);
>
> @@ -59,6 +60,13 @@ struct TPMDriverOps {
>       bool (*get_tpm_established_flag)(TPMBackend *t);
>   };
>
> +#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;
>
>

Reviewed-by: Corey Bryant <coreyb@linux.vnet.ibm.com>

-- 
Regards,
Corey Bryant

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] tpm: Move TPM passthrough specific command line options to backend structure
  2013-04-12 21:59 [Qemu-devel] [PATCH v2] tpm: Move TPM passthrough specific command line options to backend structure Stefan Berger
  2013-04-16 21:33 ` Corey Bryant
@ 2013-04-22 14:17 ` Anthony Liguori
  2013-04-22 15:00   ` Stefan Berger
  1 sibling, 1 reply; 4+ messages in thread
From: Anthony Liguori @ 2013-04-22 14:17 UTC (permalink / raw)
  To: Stefan Berger, qemu-devel@nongnu.org; +Cc: coreyb

Stefan Berger <stefanb@linux.vnet.ibm.com> writes:

> 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>

This doesn't apply.  Looks like it's pre-QOM?

Regards,

Anthony Liguori

>
> ---
>  tpm/tpm.c             |    8 ++++++++
>  tpm/tpm_int.h         |    8 ++++++++
>  tpm/tpm_passthrough.c |   16 ++++++++++++++++
>  vl.c                  |   16 +---------------
>  4 files changed, 33 insertions(+), 15 deletions(-)
>
> Index: qemu-git.pt/vl.c
> ===================================================================
> --- qemu-git.pt.orig/vl.c
> +++ qemu-git.pt/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 */ }
>      },
>  };
> Index: qemu-git.pt/tpm/tpm.c
> ===================================================================
> --- qemu-git.pt.orig/tpm/tpm.c
> +++ qemu-git.pt/tpm/tpm.c
> @@ -174,6 +174,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;
> Index: qemu-git.pt/tpm/tpm_passthrough.c
> ===================================================================
> --- qemu-git.pt.orig/tpm/tpm_passthrough.c
> +++ qemu-git.pt/tpm/tpm_passthrough.c
> @@ -512,8 +512,24 @@ static void tpm_passthrough_destroy(TPMB
>      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 */ },
> +};
> +
>  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: qemu-git.pt/tpm/tpm_int.h
> ===================================================================
> --- qemu-git.pt.orig/tpm/tpm_int.h
> +++ qemu-git.pt/tpm/tpm_int.h
> @@ -35,6 +35,7 @@ struct TPMState {
>  
>  struct TPMDriverOps {
>      enum TpmType type;
> +    const QemuOptDesc *opts;
>      /* get a descriptive text of the backend to display to the user */
>      const char *(*desc)(void);
>  
> @@ -59,6 +60,13 @@ struct TPMDriverOps {
>      bool (*get_tpm_established_flag)(TPMBackend *t);
>  };
>  
> +#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;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2] tpm: Move TPM passthrough specific command line options to backend structure
  2013-04-22 14:17 ` Anthony Liguori
@ 2013-04-22 15:00   ` Stefan Berger
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Berger @ 2013-04-22 15:00 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: coreyb, qemu-devel@nongnu.org

On 04/22/2013 10:17 AM, Anthony Liguori wrote:
> Stefan Berger <stefanb@linux.vnet.ibm.com> writes:
>
>> 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>
> This doesn't apply.  Looks like it's pre-QOM?

It was from before Paolo moved the files around.

I just reposted this patch as v3.

Thanks.
     Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-22 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-12 21:59 [Qemu-devel] [PATCH v2] tpm: Move TPM passthrough specific command line options to backend structure Stefan Berger
2013-04-16 21:33 ` Corey Bryant
2013-04-22 14:17 ` Anthony Liguori
2013-04-22 15:00   ` Stefan Berger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).