[libvirt] [PATCH 7/9] qemu: blockjob: Ensure that config disk source is identical when modifying it

Peter Krempa posted 9 patches 6 years, 6 months ago
[libvirt] [PATCH 7/9] qemu: blockjob: Ensure that config disk source is identical when modifying it
Posted by Peter Krempa 6 years, 6 months ago
qemuBlockJobRewriteConfigDiskSource rewrites the disk source only
according to the 'target'. This means that if someone would change the
inactive config of the VM to refer to a different disk a block job would
rewrite it when finishing a job which modifies the disk source.

Make sure that this does not happen by verifying that the source of the
config disk is the same.

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

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index f5574b7e03..0c0ae89f10 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -479,6 +479,9 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm,
     if (!(persistDisk = virDomainDiskByName(vm->newDef, disk->dst, false)))
         return;

+    if (!virStorageSourceIsSameLocation(disk->src, persistDisk->src))
+        return;
+
     if (!(copy = virStorageSourceCopy(newsrc, false)) ||
         virStorageSourceInitChainElement(copy, persistDisk->src, true) < 0) {
         VIR_WARN("Unable to update persistent definition on vm %s after block job",
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 7/9] qemu: blockjob: Ensure that config disk source is identical when modifying it
Posted by Eric Blake 6 years, 6 months ago
On 7/24/19 4:07 PM, Peter Krempa wrote:
> qemuBlockJobRewriteConfigDiskSource rewrites the disk source only
> according to the 'target'. This means that if someone would change the
> inactive config of the VM to refer to a different disk a block job would
> rewrite it when finishing a job which modifies the disk source.
> 
> Make sure that this does not happen by verifying that the source of the
> config disk is the same.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_blockjob.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
> index f5574b7e03..0c0ae89f10 100644
> --- a/src/qemu/qemu_blockjob.c
> +++ b/src/qemu/qemu_blockjob.c
> @@ -479,6 +479,9 @@ qemuBlockJobRewriteConfigDiskSource(virDomainObjPtr vm,
>      if (!(persistDisk = virDomainDiskByName(vm->newDef, disk->dst, false)))
>          return;
> 
> +    if (!virStorageSourceIsSameLocation(disk->src, persistDisk->src))
> +        return;

ACK.
Especially useful if I hotunplug disk vdb pointing to file1 and then
hotplug disk vdb pointing to file2, but without updating config in the
meantime.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

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