qemu: snapshot: Skip 'transaction' command when no disks are selected

When doing a memory-only snapshot libvirt would still issue the
'transaction' command without any disk. Skip it if it isn't necessary.
This commit is contained in:
Peter Krempa 2016-01-06 13:56:47 +01:00
parent 6343018fac
commit 5f7df34611

View File

@ -14331,6 +14331,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virJSONValuePtr actions = NULL; virJSONValuePtr actions = NULL;
bool do_transaction = false;
int ret = 0; int ret = 0;
size_t i; size_t i;
bool persist = false; bool persist = false;
@ -14379,9 +14380,11 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
reuse, asyncJob); reuse, asyncJob);
if (ret < 0) if (ret < 0)
break; break;
do_transaction = true;
} }
if (actions) { if (actions) {
if (ret == 0) { if (ret == 0 && do_transaction) {
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) { if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
ret = qemuMonitorTransaction(priv->mon, actions); ret = qemuMonitorTransaction(priv->mon, actions);
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
@ -14390,6 +14393,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
/* failed to enter monitor, clean stuff up and quit */ /* failed to enter monitor, clean stuff up and quit */
ret = -1; ret = -1;
} }
} else {
VIR_DEBUG("no disks to snapshot, skipping 'transaction' command");
} }
virJSONValueFree(actions); virJSONValueFree(actions);