]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONEjectMedia: don't stringify the replay at all
authorPavel Hrdina <phrdina@redhat.com>
Tue, 15 Dec 2015 10:04:49 +0000 (11:04 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 15 Dec 2015 11:18:27 +0000 (12:18 +0100)
Commit 256496e1 introduced a detection if "is locked" in error replay
from qemu monitor. Commit c4073657 fixed a memory leak, but it was
pointed out by Peter, that this could be done cleaner without
stringifing the replay.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_monitor_json.c

index 4ae63cf7c4c887373be7e1bc3ce1c84481ae1cfd..d4b65144205e2119bf7be2ee2e400570ba2a4941 100644 (file)
@@ -2223,11 +2223,12 @@ int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
         ret = qemuMonitorJSONCheckError(cmd, reply);
 
     if (ret < 0) {
-        char *replyStr = virJSONValueToString(reply, false);
-
-        if (c_strcasestr(replyStr, "is locked"))
-            ret = -2;
-        VIR_FREE(replyStr);
+        virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
+        if (error) {
+            const char *errorStr = virJSONValueObjectGetString(error, "desc");
+            if (errorStr && c_strcasestr(errorStr, "is locked"))
+                ret = -2;
+        }
     }
 
     virJSONValueFree(cmd);