From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USDVr-0007j6-49 for qemu-devel@nongnu.org; Tue, 16 Apr 2013 17:34:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USDVp-0002jp-2f for qemu-devel@nongnu.org; Tue, 16 Apr 2013 17:34:03 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:54990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USDVo-0002jL-L5 for qemu-devel@nongnu.org; Tue, 16 Apr 2013 17:34:00 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Apr 2013 17:33:59 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id B841A6E803C for ; Tue, 16 Apr 2013 17:33:52 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3GLXtYc323456 for ; Tue, 16 Apr 2013 17:33:55 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3GLXsYi031476 for ; Tue, 16 Apr 2013 17:33:55 -0400 Message-ID: <516DC3C2.7090602@linux.vnet.ibm.com> Date: Tue, 16 Apr 2013 17:33:54 -0400 From: Corey Bryant MIME-Version: 1.0 References: <1365803977.26271.2.camel@d941e-10> In-Reply-To: <1365803977.26271.2.camel@d941e-10> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] tpm: Move TPM passthrough specific command line options to backend structure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 > > --- > 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 -- Regards, Corey Bryant