[libvirt] [PATCH 3/8] qemu: snapshot: Unify conditions checking whether snapshot needs to be taken

Ján Tomko jtomko at redhat.com
Thu Jul 12 14:01:48 UTC 2018


On Tue, Jul 03, 2018 at 02:33:01PM +0200, Peter Krempa wrote:
>In the cleanup path we already checked whether a snapshot needed to be
>taken by looking into the collected data. Use the same approach when
>creating the snapshot command data and when commiting the changes to the

*committing

>domain definition.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/qemu/qemu_driver.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
>diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
>index 39b745b1db..e5005fd829 100644
>--- a/src/qemu/qemu_driver.c
>+++ b/src/qemu/qemu_driver.c
>@@ -15012,7 +15012,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
>       * VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL with a valid file name and
>       * qcow2 format.  */
>     for (i = 0; i < snap->def->ndisks; i++) {
>-        if (snap->def->disks[i].snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE)
>+        if (!diskdata[i].src)
>             continue;
>
>         ret = qemuDomainSnapshotCreateSingleDiskActive(driver, vm,
>@@ -15036,8 +15036,14 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
>             goto error;
>         }
>
>-        for (i = 0; i < snap->def->ndisks; i++)
>+        for (i = 0; i < snap->def->ndisks; i++) {
>+            qemuDomainSnapshotDiskDataPtr dd = &diskdata[i];
>+
>+            if (!dd->src)
>+                continue;
>+
>             qemuDomainSnapshotUpdateDiskSources(&diskdata[i], &persist);

qemuDomainSnapshotUpdateDiskSources already is a no-op for NULL dd->src.
Also, the other occurrence of '&diskdata[i]' can be replaced by dd now.

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180712/c99582e5/attachment-0001.sig>


More information about the libvir-list mailing list