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

Peter Krempa posted 8 patches 6 years, 10 months ago
[libvirt] [PATCH 3/8] qemu: snapshot: Unify conditions checking whether snapshot needs to be taken
Posted by Peter Krempa 6 years, 10 months ago
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
domain definition.

Signed-off-by: Peter Krempa <pkrempa@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);
+        }
     }

  error:
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/8] qemu: snapshot: Unify conditions checking whether snapshot needs to be taken
Posted by Ján Tomko 6 years, 10 months ago
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@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@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list