[libvirt] [PATCH 01/10] qemu: snapshot: Don't modify persistent XML if disk source is different

Peter Krempa posted 10 patches 6 years, 5 months ago
There is a newer version of this series
[libvirt] [PATCH 01/10] qemu: snapshot: Don't modify persistent XML if disk source is different
Posted by Peter Krempa 6 years, 5 months ago
While the VM is running the persistent source of a disk might differ
e.g. as the 'newDef' was redefined. Our snapshot code would blindly
rewrite the source of such disk if it shared the 'target'. Fix this by
checking whether the source is the same in the first place.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_driver.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 11f97dbc65..b6fbb197b8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15332,6 +15332,7 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver,
     qemuDomainSnapshotDiskDataPtr dd;
     char *backingStoreStr;
     virDomainSnapshotDefPtr snapdef = virDomainSnapshotObjGetDef(snap);
+    virDomainDiskDefPtr persistdisk;
     int ret = -1;

     if (VIR_ALLOC_N(data, snapdef->ndisks) < 0)
@@ -15352,13 +15353,12 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver,
         if (virStorageSourceInitChainElement(dd->src, dd->disk->src, false) < 0)
             goto cleanup;

-        /* Note that it's unsafe to assume that the disks in the persistent
-         * definition match up with the disks in the live definition just by
-         * checking that the target name is the same. We've done that
-         * historically this way though. */
+        /* modify disk in persistent definition only when the source is the same */
         if (vm->newDef &&
-            (dd->persistdisk = virDomainDiskByName(vm->newDef, dd->disk->dst,
-                                                   false))) {
+            (persistdisk = virDomainDiskByName(vm->newDef, dd->disk->dst, false)) &&
+            virStorageSourceIsSameLocation(dd->disk->src, persistdisk->src)) {
+
+            dd->persistdisk = persistdisk;

             if (!(dd->persistsrc = virStorageSourceCopy(dd->src, false)))
                 goto cleanup;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 01/10] qemu: snapshot: Don't modify persistent XML if disk source is different
Posted by Ján Tomko 6 years, 5 months ago
On Fri, Aug 16, 2019 at 03:54:35PM +0200, Peter Krempa wrote:
>While the VM is running the persistent source of a disk might differ
>e.g. as the 'newDef' was redefined. Our snapshot code would blindly
>rewrite the source of such disk if it shared the 'target'. Fix this by
>checking whether the source is the same in the first place.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_driver.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>

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