tpm: QMP/HMP support for libtpms TPM backend
PATCH 3/4 tpm: QMP/HMP support for libtpms TPM backend
This patch provides HMP 'info tpm', QMP 'query-tpm' and QMP 'query-tpm-types' support for the libtpms TPM backend.
--- hmp.c | 5 +++++ include/sysemu/tpm_backend.h | 1 + qapi-schema.json | 18 ++++++++++++++++-- tpm.c | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-)
hmp.c +5 -0
@@ -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 ; }
include/sysemu/tpm_backend.h +1 -0
@@ -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;
qapi-schema.json +16 -2
@@ -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:
tpm.c +7 -0
@@ -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 ; }
Signature · 1 line
1.7.1
On 11/06/2013 07:39 AM, Corey Bryant wrote:
[your git settings are odd; your messages came across as individual threads rather than in-reply to the cover letter]
Quoted 13 lines
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 <[email protected]>--- hmp.c | 5 +++++ include/sysemu/tpm_backend.h | 1 + qapi-schema.json | 18 ++++++++++++++++-- tpm.c | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-)+++
b/qapi-schema.json
qapi-schema.json line 3676
Quoted 4 lines
qapi-schema.json +1
-0@@ -3673,10 +3673,11 @@ # An enumeration of TPM types # # @passthrough: TPM passthrough type +# @libtpms: TPM libtpms type
Worth adding '(since 1.8)' to mark when this enum value was added.
qapi-schema.json line 3725
Quoted 6 lines
qapi-schema.json +1
-0# @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
here as well.
qapi-schema.json line 3731
Quoted 8 lines
qapi-schema.json +2
-1# # Since: 1.5 ## { 'union': 'TpmTypeOptions', - 'data': { 'passthrough' : 'TPMPassthroughOptions' } } + 'data': { 'passthrough' : 'TPMPassthroughOptions', + 'libtpms' : 'TPMLibtpmsOptions' } }
Otherwise it looks okay to me.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 5 lines · Eric Blake
On 11/06/2013 07:39 AM, Corey Bryant wrote:
[your git settings are odd; your messages came across as individual threads rather than in-reply to the cover letter]
I wonder if that's because I sent each patch separately with git send-email? Sometimes it hangs when I send more than 1.
Quoted 38 lines
Quoted 13 lines
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 <[email protected]>--- hmp.c | 5 +++++ include/sysemu/tpm_backend.h | 1 + qapi-schema.json | 18 ++++++++++++++++-- tpm.c | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-)+++
b/qapi-schema.jsonqapi-schema.json line 3676
Quoted 4 lines
qapi-schema.json +1
-0@@ -3673,10 +3673,11 @@ # An enumeration of TPM types # # @passthrough: TPM passthrough type +# @libtpms: TPM libtpms typeWorth adding '(since 1.8)' to mark when this enum value was added.
qapi-schema.json line 3725
Quoted 6 lines
qapi-schema.json +1
-0# @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 typehere as well.
qapi-schema.json line 3731
Quoted 8 lines
qapi-schema.json +2
-1# # Since: 1.5 ## { 'union': 'TpmTypeOptions', - 'data': { 'passthrough' : 'TPMPassthroughOptions' } } + 'data': { 'passthrough' : 'TPMPassthroughOptions', + 'libtpms' : 'TPMLibtpmsOptions' } }
Quoted 2 lines
Otherwise it looks okay to me.
Thanks for the comments. I'll add them to the next version. Can I add your Reviewed-by to this patch?
Signature · 2 lines
Regards, Corey Bryant
Eric Blake
Reviewed-byQuoted 9 lines · Corey Bryant
Quoted 9 lines
Quoted 8 lines
#
# Since: 1.5
##
{ 'union': 'TpmTypeOptions',qapi-schema.json +2
-1- 'data': { 'passthrough' : 'TPMPassthroughOptions' } } + 'data': { 'passthrough' : 'TPMPassthroughOptions', + 'libtpms' : 'TPMLibtpmsOptions' } }
Quoted 5 lines
Quoted 2 lines
Otherwise it looks okay to me.
Thanks for the comments. I'll add them to the next version. Can I add your Reviewed-by to this patch?
Yes, now that I've looked at the full patch (and not just the .json):
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org