mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-30 21:47:18 +00:00
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.
This commit is contained in:
parent
72c507317a
commit
a14eda311e
@ -9919,7 +9919,7 @@ qemuDomainSnapshotCreateSingleDiskActive(struct qemud_driver *driver,
|
|||||||
|
|
||||||
/* create the actual snapshot */
|
/* create the actual snapshot */
|
||||||
ret = qemuMonitorDiskSnapshot(priv->mon, actions, device, source,
|
ret = qemuMonitorDiskSnapshot(priv->mon, actions, device, source,
|
||||||
driverType, reuse);
|
snap->driverType, reuse);
|
||||||
virDomainAuditDisk(vm, disk->src, source, "snapshot", ret >= 0);
|
virDomainAuditDisk(vm, disk->src, source, "snapshot", ret >= 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -417,6 +417,12 @@ qemuMonitorJSONMakeCommandRaw(bool wrap, const char *cmdname, ...)
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case 's': {
|
case 's': {
|
||||||
char *val = va_arg(args, char *);
|
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);
|
ret = virJSONValueObjectAppendString(jargs, key, val);
|
||||||
} break;
|
} break;
|
||||||
case 'i': {
|
case 'i': {
|
||||||
|
Loading…
Reference in New Issue
Block a user