]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemucapsprobe: Ignore all greetings except the first one
authorJiri Denemark <jdenemar@redhat.com>
Mon, 14 Nov 2016 13:29:57 +0000 (14:29 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 25 Nov 2016 19:34:26 +0000 (20:34 +0100)
When starting QEMU more than once during a single probing process,
qemucapsprobe utility would save QMP greeting several times, which
doesn't play well with our test monitor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
tests/qemucapsprobemock.c

index 0c4c786b15c537def05718aa525c44cc32b48296..bad69bb1fe51d0267838bec9630d09cc5c5a8781 100644 (file)
@@ -77,10 +77,14 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
         char *p;
         bool skip = false;
 
-        if (first)
+        if (first) {
             first = false;
-        else
+        } else {
+            /* Ignore QMP greeting if it's not the first one */
+            if (virJSONValueObjectHasKey(value, "QMP"))
+                goto cleanup;
             putchar('\n');
+        }
 
         for (p = json; *p; p++) {
             if (skip && *p == '\n') {
@@ -92,6 +96,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
         }
     }
 
+ cleanup:
     VIR_FREE(json);
     virJSONValueFree(value);
     return ret;