]> xenbits.xensource.com Git - libvirt.git/commitdiff
snapshot: don't pass NULL to QMP command creation
authorEric Blake <eblake@redhat.com>
Tue, 27 Mar 2012 14:33:23 +0000 (08:33 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 27 Mar 2012 15:34:07 +0000 (09:34 -0600)
Commit d42a2ff caused a regression in creating a disk-only snapshot
of a qcow2 disk; by passing the wrong variable to the monitor call,
libvirt ended up creating JSON that looked like "format":null instead
of the intended "format":"qcow2".

To make it easier to diagnose this in the future, make JSON creation
error out if "s:arg" is paired with NULL (it is still possible to
use "n:arg" in the rare cases where qemu will accept a null).

* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive): Pass correct value.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONMakeCommandRaw):
Improve error message.

src/qemu/qemu_driver.c
src/qemu/qemu_monitor_json.c

index 7ff846f6f6b347e194786ed978a8180accd8b871..0d3b0bd7f3e6e006dee7ade2fab49f28b8e5a521 100644 (file)
@@ -9919,7 +9919,7 @@ qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver *driver,
 
     /* create the actual snapshot */
     ret = qemuMonitorDiskSnapshot(priv->mon, actions, device, source,
-                                  driverType, reuse);
+                                  snap->driverType, reuse);
     virDomainAuditDisk(vm, disk->src, source, "snapshot", ret >= 0);
     if (ret < 0)
         goto cleanup;
index eeeb6a603bcb5dd821d469b1ddca1537d0e3f1eb..8c028b9bc079ae168d16e2d8ab544e273c14bfad 100644 (file)
@@ -417,6 +417,12 @@ qemuMonitorJSONMakeCommandRaw(bool wrap, const char *cmdname, ...)
         switch (type) {
         case 's': {
             char *val = va_arg(args, char *);
+            if (!val) {
+                qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                                _("argument key '%s' must not have null value"),
+                                key);
+                goto error;
+            }
             ret = virJSONValueObjectAppendString(jargs, key, val);
         }   break;
         case 'i': {