From patchwork Wed Nov 6 14:39:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Bryant X-Patchwork-Id: 288940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EE2ED2C0086 for ; Thu, 7 Nov 2013 01:42:05 +1100 (EST) Received: from localhost ([::1]:34324 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve4J2-0000b4-3s for incoming@patchwork.ozlabs.org; Wed, 06 Nov 2013 09:42:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve4IV-0000R1-Tg for qemu-devel@nongnu.org; Wed, 06 Nov 2013 09:41:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve4IM-00017F-Vn for qemu-devel@nongnu.org; Wed, 06 Nov 2013 09:41:31 -0500 Received: from e38.co.us.ibm.com ([32.97.110.159]:48181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve4IM-000179-Ph for qemu-devel@nongnu.org; Wed, 06 Nov 2013 09:41:22 -0500 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Nov 2013 07:41:22 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 6 Nov 2013 07:41:21 -0700 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 9479A1FF001C for ; Wed, 6 Nov 2013 07:41:05 -0700 (MST) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rA6EebIH204492 for ; Wed, 6 Nov 2013 07:41:20 -0700 Received: from d03av01.boulder.ibm.com (localhost [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rA6Ed31W018228 for ; Wed, 6 Nov 2013 07:39:04 -0700 Received: from localhost ([9.80.103.90]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id rA6Ed3Fh018193; Wed, 6 Nov 2013 07:39:03 -0700 From: Corey Bryant To: qemu-devel@nongnu.org Date: Wed, 6 Nov 2013 09:39:01 -0500 Message-Id: <1383748741-8865-1-git-send-email-coreyb@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.1.4 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13110614-1344-0000-0000-0000030C5427 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.110.159 Cc: Corey Bryant , aliguori@amazon.com Subject: [Qemu-devel] [PATCH 3/4] tpm: QMP/HMP support for libtpms TPM backend X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch provides HMP 'info tpm', QMP 'query-tpm' and QMP 'query-tpm-types' support for the libtpms TPM backend. Signed-off-by: Corey Bryant Reviewed-by: Eric Blake --- hmp.c | 5 +++++ include/sysemu/tpm_backend.h | 1 + qapi-schema.json | 18 ++++++++++++++++-- tpm.c | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/hmp.c b/hmp.c index 32ee285..0903969 100644 --- a/hmp.c +++ b/hmp.c @@ -673,6 +673,7 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) Error *err = NULL; unsigned int c = 0; TPMPassthroughOptions *tpo; + TPMLibtpmsOptions *tlo; info_list = qmp_query_tpm(&err); if (err) { @@ -702,6 +703,10 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) tpo->has_cancel_path ? ",cancel-path=" : "", tpo->has_cancel_path ? tpo->cancel_path : ""); break; + case TPM_TYPE_OPTIONS_KIND_LIBTPMS: + tlo = ti->options->libtpms; + monitor_printf(mon, ",nvram=%s", tlo->nvram); + break; case TPM_TYPE_OPTIONS_KIND_MAX: break; } diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index c7a7281..e648f79 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -51,6 +51,7 @@ struct TPMBackend { enum TpmModel fe_model; char *path; char *cancel_path; + char *nvram_id; const TPMDriverOps *ops; QLIST_ENTRY(TPMBackend) list; diff --git a/qapi-schema.json b/qapi-schema.json index 81a375b..564e529 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3673,10 +3673,11 @@ # An enumeration of TPM types # # @passthrough: TPM passthrough type +# @libtpms: TPM libtpms type # # Since: 1.5 ## -{ 'enum': 'TpmType', 'data': [ 'passthrough' ] } +{ 'enum': 'TpmType', 'data': [ 'passthrough', 'libtpms' ] } ## # @query-tpm-types: @@ -3705,16 +3706,29 @@ '*cancel-path' : 'str'} } ## +# @TPMLibtpmsOptions: +# +# Information about the TPM libtpms type +# +# @nvram: string showing the NVRAM drive id +# +# Since: 1.8 +## +{ 'type': 'TPMLibtpmsOptions', 'data': { 'nvram' : 'str' } } + +## # @TpmTypeOptions: # # A union referencing different TPM backend types' configuration options # # @passthrough: The configuration options for the TPM passthrough type +# @libtpms: The configuration options for the TPM libtpms type # # Since: 1.5 ## { 'union': 'TpmTypeOptions', - 'data': { 'passthrough' : 'TPMPassthroughOptions' } } + 'data': { 'passthrough' : 'TPMPassthroughOptions', + 'libtpms' : 'TPMLibtpmsOptions' } } ## # @TpmInfo: diff --git a/tpm.c b/tpm.c index 1dd516b..2f4ef52 100644 --- a/tpm.c +++ b/tpm.c @@ -275,6 +275,7 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv) { TPMInfo *res = g_new0(TPMInfo, 1); TPMPassthroughOptions *tpo; + TPMLibtpmsOptions *tlo; res->id = g_strdup(drv->id); res->model = drv->fe_model; @@ -294,6 +295,12 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv) tpo->has_cancel_path = true; } break; + case TPM_TYPE_LIBTPMS: + res->options->kind = TPM_TYPE_OPTIONS_KIND_LIBTPMS; + tlo = g_new0(TPMLibtpmsOptions, 1); + res->options->libtpms = tlo; + tlo->nvram = g_strdup(drv->nvram_id); + break; case TPM_TYPE_MAX: break; }