[PATCH] qemu_monitor: Don't output snapshot format argument if type is NULL

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

 



If the snapshot format type string was NULL, the JSON framework created
an invalid JSON string.
---
The other option would be to fix qemuMonitorJSONMakeCommandRaw that string arguments with a NULL
argument would suppress outputing the complete option, but I'm afraid of breaking something.

Background:
http://www.redhat.com/archives/libvir-list/2012-March/msg01198.html

 src/qemu/qemu_monitor_json.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index eeeb6a6..6fce58a 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3112,14 +3112,25 @@ qemuMonitorJSONDiskSnapshot(qemuMonitorPtr mon, virJSONValuePtr actions,
     virJSONValuePtr cmd;
     virJSONValuePtr reply = NULL;

-    cmd = qemuMonitorJSONMakeCommandRaw(actions != NULL,
-                                        "blockdev-snapshot-sync",
-                                        "s:device", device,
-                                        "s:snapshot-file", file,
-                                        "s:format", format,
-                                        reuse ? "s:mode" : NULL,
-                                        reuse ? "existing" : NULL,
-                                        NULL);
+    if (format) {
+        cmd = qemuMonitorJSONMakeCommandRaw(actions != NULL,
+                                            "blockdev-snapshot-sync",
+                                            "s:device", device,
+                                            "s:snapshot-file", file,
+                                            "s:format", format,
+                                            reuse ? "s:mode" : NULL,
+                                            reuse ? "existing" : NULL,
+                                            NULL);
+    } else {
+        cmd = qemuMonitorJSONMakeCommandRaw(actions != NULL,
+                                            "blockdev-snapshot-sync",
+                                            "s:device", device,
+                                            "s:snapshot-file", file,
+                                            reuse ? "s:mode" : NULL,
+                                            reuse ? "existing" : NULL,
+                                            NULL);
+    }
+
     if (!cmd)
         return -1;

-- 
1.7.3.4

--
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]