qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Corey Bryant <coreyb@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Corey Bryant <coreyb@linux.vnet.ibm.com>, aliguori@amazon.com
Subject: [Qemu-devel] [PATCH 3/4] tpm: QMP/HMP support for libtpms TPM backend
Date: Wed,  6 Nov 2013 09:39:01 -0500	[thread overview]
Message-ID: <1383748741-8865-1-git-send-email-coreyb@linux.vnet.ibm.com> (raw)

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 <coreyb@linux.vnet.ibm.com>
---
 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;
     }
-- 
1.7.1

             reply	other threads:[~2013-11-06 14:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-06 14:39 Corey Bryant [this message]
2013-11-06 16:13 ` [Qemu-devel] [PATCH 3/4] tpm: QMP/HMP support for libtpms TPM backend Eric Blake
2013-11-06 19:35   ` Corey Bryant
2013-11-06 20:15     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383748741-8865-1-git-send-email-coreyb@linux.vnet.ibm.com \
    --to=coreyb@linux.vnet.ibm.com \
    --cc=aliguori@amazon.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).