[PATCH] blockjob: Report correct error when missing qemu support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When executing blockjob monitor commands, we are not checking for
CommandNotFound errors.  This results in 'unexpected error' messages when using
a qemu without support for the required commands.  Fix this up by checking for
CommandNotFound errors for QMP and detecting this condition for the text
monitor.

This fixes the problem reported in Bug 727502.

Signed-off-by: Adam Litke <agl@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c |    3 +++
 src/qemu/qemu_monitor_text.c |   20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 7adfb26..4c8a08b 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2939,6 +2939,9 @@ int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
         else if (qemuMonitorJSONHasError(reply, "NotSupported"))
             qemuReportError(VIR_ERR_OPERATION_INVALID,
                 _("Operation is not supported for device: %s"), device);
+        else if (qemuMonitorJSONHasError(reply, "CommandNotFound"))
+            qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                _("Operation is not supported"));
         else
             qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                 _("Unexpected error"));
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 52d924a..d9cad2d 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -271,6 +271,19 @@ qemuMonitorTextCommandWithFd(qemuMonitorPtr mon,
                                              scm_fd, reply);
 }
 
+/* Check monitor output for evidence that the command was not recognized.
+ * For 'info' commands, qemu returns help text.  For other commands, qemu
+ * returns 'unknown command:'.
+ */
+static int
+qemuMonitorTextCommandNotFound(const char *reply)
+{
+    if (strstr(reply, "unknown command:"))
+        return 1;
+    if (strstr(reply, "info version  -- show the version of QEMU"))
+        return 1;
+    return 0;
+}
 
 static int
 qemuMonitorSendDiskPassphrase(qemuMonitorPtr mon,
@@ -3056,6 +3069,13 @@ int qemuMonitorTextBlockJob(qemuMonitorPtr mon,
         goto cleanup;
     }
 
+    if (qemuMonitorTextCommandNotFound(reply)) {
+        qemuReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                        _("Operation is not supported"));
+        ret = -1;
+        goto cleanup;
+    }
+
     ret = qemuMonitorTextParseBlockJob(reply, device, info);
 
 cleanup:
-- 
1.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]