[libvirt] [PATCH] Check for QMP query-tpm-models

Check for QMP query-tpm-models and set a capability flag. Do not use this QMP command if it is not supported. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> --- src/qemu/qemu_capabilities.c | 8 ++++++++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 9 insertions(+) Index: libvirt/src/qemu/qemu_capabilities.h =================================================================== --- libvirt.orig/src/qemu/qemu_capabilities.h +++ libvirt/src/qemu/qemu_capabilities.h @@ -179,6 +179,7 @@ enum virQEMUCapsFlags { QEMU_CAPS_MACHINE_USB_OPT = 137, /* -machine xxx,usb=on/off */ QEMU_CAPS_DEVICE_TPM_PASSTHROUGH = 138, /* -tpmdev passthrough */ QEMU_CAPS_DEVICE_TPM_TIS = 139, /* -device tpm_tis */ + QEMU_CAPS_TPM_MODELS = 140, /* query-tpm-models QMP command */ QEMU_CAPS_LAST, /* this must always be the last item */ }; Index: libvirt/src/qemu/qemu_capabilities.c =================================================================== --- libvirt.orig/src/qemu/qemu_capabilities.c +++ libvirt/src/qemu/qemu_capabilities.c @@ -220,6 +220,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAS "machine-usb-opt", "tpm-passthrough", "tpm-tis", + + "query-tpm-models", /* 140 */ ); struct _virQEMUCaps { @@ -1962,6 +1964,8 @@ virQEMUCapsProbeQMPCommands(virQEMUCapsP virQEMUCapsSet(qemuCaps, QEMU_CAPS_ADD_FD); else if (STREQ(name, "nbd-server-start")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_NBD_SERVER); + else if (STREQ(name, "query-tpm-models")) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_TPM_MODELS); VIR_FREE(name); } VIR_FREE(commands); @@ -2144,6 +2148,10 @@ virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qe { int nentries, i; char **entries = NULL; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_TPM_MODELS)) + return 0; + if ((nentries = qemuMonitorGetTPMModels(mon, &entries)) < 0) return -1;

On 04/15/2013 01:49 PM, Stefan Berger wrote:
Check for QMP query-tpm-models and set a capability flag. Do not use this QMP command if it is not supported.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
--- src/qemu/qemu_capabilities.c | 8 ++++++++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 9 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 04/15/2013 04:15 PM, Eric Blake wrote:
On 04/15/2013 01:49 PM, Stefan Berger wrote:
Check for QMP query-tpm-models and set a capability flag. Do not use this QMP command if it is not supported.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
--- src/qemu/qemu_capabilities.c | 8 ++++++++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 9 insertions(+) ACK.
Pushed.

On Mon, Apr 15, 2013 at 04:55:00PM -0400, Stefan Berger wrote:
On 04/15/2013 04:15 PM, Eric Blake wrote:
On 04/15/2013 01:49 PM, Stefan Berger wrote:
Check for QMP query-tpm-models and set a capability flag. Do not use this QMP command if it is not supported.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
--- src/qemu/qemu_capabilities.c | 8 ++++++++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 9 insertions(+) ACK.
Pushed.
NACK, please revert this. You should check "CommandNotFound" error from the monitor command instead, as we do for other monitor commands which can be missing. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 04/16/2013 03:10 AM, Daniel P. Berrange wrote:
On Mon, Apr 15, 2013 at 04:55:00PM -0400, Stefan Berger wrote:
On 04/15/2013 04:15 PM, Eric Blake wrote:
On 04/15/2013 01:49 PM, Stefan Berger wrote:
Check for QMP query-tpm-models and set a capability flag. Do not use this QMP command if it is not supported.
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
--- src/qemu/qemu_capabilities.c | 8 ++++++++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 9 insertions(+) ACK.
Pushed.
NACK, please revert this. You should check "CommandNotFound" error from the monitor command instead, as we do for other monitor commands which can be missing.
My fault for suggesting and approving this method. I forgot that we have used qemu_monitor_json returning a special -2 on command not found as a way to short-circuit needing to burn another capability bit; and since capability bits become part of the XML contract across libvirtd upgrades, fewer capabilities is a nicer goal for tasks like this. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Stefan Berger