qemuDomainSnapshotDiskPrepareOne is already called for each disk which
is member of the snapshot so we don't need to iterate through the
snapshot list again to generate members of the 'transaction' command for
each snapshot.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_driver.c | 45 +++++++++++++++++-------------------------
1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 41a124d215..d2769dab1a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15285,7 +15285,8 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
virHashTablePtr blockNamedNodeData,
bool reuse,
bool blockdev,
- qemuDomainAsyncJob asyncJob)
+ qemuDomainAsyncJob asyncJob,
+ virJSONValuePtr actions)
{
virDomainDiskDefPtr persistdisk;
bool supportsCreate;
@@ -15358,10 +15359,17 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
dd->prepared = true;
- if (blockdev &&
- qemuDomainSnapshotDiskPrepareOneBlockdev(driver, vm, dd, cfg, reuse,
- blockNamedNodeData, asyncJob) < 0)
- return -1;
+ if (blockdev) {
+ if (qemuDomainSnapshotDiskPrepareOneBlockdev(driver, vm, dd, cfg, reuse,
+ blockNamedNodeData, asyncJob) <
0)
+ return -1;
+
+ if (qemuBlockSnapshotAddBlockdev(actions, dd->disk, dd->src) < 0)
+ return -1;
+ } else {
+ if (qemuBlockSnapshotAddLegacy(actions, dd->disk, dd->src, reuse) < 0)
+ return -1;
+ }
return 0;
}
@@ -15383,7 +15391,8 @@ qemuDomainSnapshotDiskPrepare(virQEMUDriverPtr driver,
virHashTablePtr blockNamedNodeData,
qemuDomainAsyncJob asyncJob,
qemuDomainSnapshotDiskDataPtr *rdata,
- size_t *rndata)
+ size_t *rndata,
+ virJSONValuePtr actions)
{
size_t i;
qemuDomainSnapshotDiskDataPtr data;
@@ -15403,7 +15412,8 @@ qemuDomainSnapshotDiskPrepare(virQEMUDriverPtr driver,
data + ndata++,
blockNamedNodeData,
reuse, blockdev,
- asyncJob) < 0)
+ asyncJob,
+ actions) < 0)
goto cleanup;
}
@@ -15516,7 +15526,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
* have to roll back later */
if (qemuDomainSnapshotDiskPrepare(driver, vm, snap, cfg, reuse, blockdev,
blockNamedNodeData, asyncJob,
- &diskdata, &ndiskdata) < 0)
+ &diskdata, &ndiskdata, actions) < 0)
goto cleanup;
/* check whether there's anything to do */
@@ -15525,25 +15535,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
goto cleanup;
}
- /* Based on earlier qemuDomainSnapshotPrepare, all disks in this list are
- * now either VIR_DOMAIN_SNAPSHOT_LOCATION_NONE, or
- * VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL with a valid file name and
- * qcow2 format. */
- for (i = 0; i < ndiskdata; i++) {
- if (blockdev) {
- if (qemuBlockSnapshotAddBlockdev(actions,
- diskdata[i].disk,
- diskdata[i].src) < 0)
- goto cleanup;
- } else {
- if (qemuBlockSnapshotAddLegacy(actions,
- diskdata[i].disk,
- diskdata[i].src,
- reuse) < 0)
- goto cleanup;
- }
- }
-
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
goto cleanup;
--
2.23.0