From: Eric Blake Date: Tue, 27 Mar 2012 14:33:23 +0000 (-0600) Subject: snapshot: don't pass NULL to QMP command creation X-Git-Tag: v0.9.11-rc2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a14eda311ee4d3d943c4a5f4c24e398907a1f468;p=thirdparty%2Flibvirt.git snapshot: don't pass NULL to QMP command creation 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. --- diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7ff846f6f6..0d3b0bd7f3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index eeeb6a603b..8c028b9bc0 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -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': {