]> xenbits.xensource.com Git - libvirt.git/commitdiff
Detect errors from the 'sendkey' command
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 25 Aug 2011 16:48:25 +0000 (17:48 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 26 Aug 2011 13:18:57 +0000 (14:18 +0100)
On success, the 'sendkey' command does not return any data, so
any data in the reply should be considered to be an error
message

* src/qemu/qemu_monitor_text.c: Treat non-"" reply data as an
  error message for 'sendkey' command

src/qemu/qemu_monitor_text.c

index 54541cec7e8e91c277c60c779efc316d4d8243f9..4bd761d72b6f3e0758a7648d6fd188958710e606 100644 (file)
@@ -2848,6 +2848,7 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
     int i;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *cmd, *reply = NULL;
+    int ret = -1;
 
     if (nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS || nkeycodes == 0)
         return -1;
@@ -2880,13 +2881,21 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
         qemuReportError(VIR_ERR_OPERATION_FAILED,
                          _("failed to send key using command '%s'"),
                          cmd);
-        VIR_FREE(cmd);
-        return -1;
+        goto cleanup;
+    }
+
+    if (STRNEQ(reply, "")) {
+        qemuReportError(VIR_ERR_OPERATION_FAILED,
+                        _("failed to send key '%s'"), reply);
+        goto cleanup;
     }
 
+    ret = 0;
+
+cleanup:
     VIR_FREE(cmd);
     VIR_FREE(reply);
-    return 0;
+    return ret;
 }
 
 /* Returns -1 on error, -2 if not supported */