[libvirt] [PATCH 4/4] Ignore error from query-cpu-definitions

Daniel P. Berrange berrange at redhat.com
Fri Sep 28 14:58:23 UTC 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

Some architectures provide the query-cpu-definitions command,
but are set to always return a "GenericError" from it :-(
Catch this & treat it as if there was an empty list of CPUs
returned

Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 src/qemu/qemu_capabilities.c |  2 +-
 src/qemu/qemu_monitor.c      |  1 -
 src/qemu/qemu_monitor_json.c | 12 ++++++++++++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 682d3e6..2ae6fec 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2240,7 +2240,7 @@ qemuCapsInitQMP(qemuCapsPtr caps)
     VIR_DEBUG("Got version %d.%d.%d (%s)",
               major, minor, micro, NULLSTR(package));
 
-    if (!(major >= 1 && minor >= 1 && micro >= 90)) {
+    if (!(major >= 1 || (major == 1 && minor >= 1))) {
         VIR_DEBUG("Not new enough for QMP capabilities detection");
         ret = 0;
         goto cleanup;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 6c3f09e..85b0bc2 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -843,7 +843,6 @@ void qemuMonitorClose(qemuMonitorPtr mon)
             mon->watch = 0;
         }
         VIR_FORCE_CLOSE(mon->fd);
-        fprintf(stderr, "Closing monitr\n");
     }
 
     /* In case another thread is waiting for its monitor command to be
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 166c431..bd52ce4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3957,6 +3957,18 @@ int qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
 
     ret = qemuMonitorJSONCommand(mon, cmd, &reply);
 
+    if (ret == 0) {
+        /* Urgh, some QEMU architectures have the query-cpu-definitions
+         * command, but return 'GenericError' with string "Not supported",
+         * instead of simply omitting the command entirely :-(
+         */
+        if (qemuMonitorJSONHasError(reply, "GenericError")) {
+            ret = 0;
+            goto cleanup;
+        }
+        ret = qemuMonitorJSONCheckError(cmd, reply);
+    }
+
     if (ret == 0)
         ret = qemuMonitorJSONCheckError(cmd, reply);
 
-- 
1.7.11.4




More information about the libvir-list mailing list