[libvirt] [PATCH] qemuMonitorJSONGetCPUx86Data: Don't fail on ancient qemus

On the domain startup, this function is called to dump some info about the CPUs. At the beginning of the function we check if we aren't running older qemu which is not exposing the CPUs via 'qom-list'. However, we are not checking for even older qemus, which throw 'CommandNotFound' error. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_monitor_json.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e716fb3..ec3b958 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5528,11 +5528,13 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon, goto cleanup; /* check if device exists */ - if ((data = virJSONValueObjectGet(reply, "error")) && - STREQ_NULLABLE(virJSONValueObjectGetString(data, "class"), - "DeviceNotFound")) { - ret = -2; - goto cleanup; + if ((data = virJSONValueObjectGet(reply, "error"))) { + const char *klass = virJSONValueObjectGetString(data, "class"); + if (STREQ_NULLABLE(klass, "DeviceNotFound") || + STREQ_NULLABLE(klass, "CommandNotFound")) { + ret = -2; + goto cleanup; + } } if (qemuMonitorJSONCheckError(cmd, reply)) -- 1.8.3.2

On 11/19/2013 07:44 AM, Michal Privoznik wrote:
On the domain startup, this function is called to dump some info about the CPUs. At the beginning of the function we check if we aren't running older qemu which is not exposing the CPUs via 'qom-list'. However, we are not checking for even older qemus, which throw 'CommandNotFound' error.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_monitor_json.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
Any chance we can enhance the testsuite to cover this? At any rate, ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 19.11.2013 15:53, Eric Blake wrote:
On 11/19/2013 07:44 AM, Michal Privoznik wrote:
On the domain startup, this function is called to dump some info about the CPUs. At the beginning of the function we check if we aren't running older qemu which is not exposing the CPUs via 'qom-list'. However, we are not checking for even older qemus, which throw 'CommandNotFound' error.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_monitor_json.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
Any chance we can enhance the testsuite to cover this? At any rate, ACK.
I'll push this one, and post another patch adding a test case. Thanks! Michal
participants (2)
-
Eric Blake
-
Michal Privoznik