]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: Fix type of holdtime argument in qemuMonitorJSONSendKey
authorPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2014 09:19:51 +0000 (11:19 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Jun 2014 12:24:14 +0000 (14:24 +0200)
qemuMonitorJSONSendKey declares the "holdtime" argument as unsigned int
while the command was constructed in qemuMonitorJSONMakeCommand using
the "P" modifier which took a unsigned long from the variable
arguments which then made it possible to access uninitialized memory.

This broke the qemumonitorjsontest on 32bit fedora 20:
64) qemuMonitorJSONSendKey
... libvirt: QEMU Driver error : internal error: unsupported data type 'W' for arg 'WVS\83ì \8bD$0è\91wÿÿ\81ÃAå' FAILED

Uncovered by upstream commit f744b831c66d9e82453f7a96cab5eddf7570c253.

Additionally add test for the hold-time option.

src/qemu/qemu_monitor_json.c
tests/qemumonitorjsontest.c

index 0c44b11882c24de64d41519532c4e2dafc22968d..bedd959ee36c78e4de17c326ff18518c7c8838b9 100644 (file)
@@ -3610,7 +3610,7 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
 
     cmd = qemuMonitorJSONMakeCommand("send-key",
                                      "a:keys", keys,
-                                     "P:hold-time", holdtime,
+                                     "p:hold-time", holdtime,
                                      NULL);
     if (!cmd)
         goto cleanup;
index 47d7481c204b1baae410238f838dddaf98f3c192..2099dc874cc377e24b2f8527a20d80a0599e9b50 100644 (file)
@@ -1959,6 +1959,38 @@ testQemuMonitorJSONqemuMonitorJSONSendKey(const void *data)
     return ret;
 }
 
+static int
+testQemuMonitorJSONqemuMonitorJSONSendKeyHoldtime(const void *data)
+{
+    virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
+    qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
+    int ret = -1;
+    unsigned int keycodes[] = {43, 26, 46, 32};
+
+    if (!test)
+        return -1;
+
+    if (qemuMonitorTestAddItemParams(test, "send-key",
+                                     "{\"return\":{}}",
+                                     "hold-time", "31337",
+                                     "keys", "[{\"type\":\"number\",\"data\":43},"
+                                              "{\"type\":\"number\",\"data\":26},"
+                                              "{\"type\":\"number\",\"data\":46},"
+                                              "{\"type\":\"number\",\"data\":32}]",
+                                     NULL, NULL) < 0)
+        goto cleanup;
+
+    if (qemuMonitorJSONSendKey(qemuMonitorTestGetMonitor(test),
+                               31337, keycodes,
+                               ARRAY_CARDINALITY(keycodes)) < 0)
+        goto cleanup;
+
+    ret = 0;
+ cleanup:
+    qemuMonitorTestFree(test);
+    return ret;
+}
+
 static int
 testQemuMonitorJSONqemuMonitorJSONGetDumpGuestMemoryCapability(const void *data)
 {
@@ -2230,6 +2262,7 @@ mymain(void)
     DO_TEST(qemuMonitorJSONGetVirtType);
     DO_TEST(qemuMonitorJSONSendKey);
     DO_TEST(qemuMonitorJSONGetDumpGuestMemoryCapability);
+    DO_TEST(qemuMonitorJSONSendKeyHoldtime);
 
     DO_TEST_CPU_DATA("host");
     DO_TEST_CPU_DATA("full");