[PATCH 0/2] qemu: block fixes

Few issues I've found while testing the block layer for an upcoming patchset. Peter Krempa (2): qemu: hotplug: Detect disk backing images before setting up security access qemu: block: Don't try to merge bitmaps into 'raw' images src/qemu/qemu_block.c | 10 ++++++++++ src/qemu/qemu_hotplug.c | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-) -- 2.42.0

The VM will require access also to the detected images. Unfortunately a recent reordering of the code introduced a bug where the backing chain was probed after setting up cgroups/selinux/namespaces, which caused that any detected images were not allowed/added and qemu was then not able to use them. Fixes: 9b8bb536ff999fa61e41869bd98a026b8e23378f Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_hotplug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f197a9d5ff..4e2fc724c0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1001,17 +1001,17 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver, goto cleanup; if (!virStorageSourceIsEmpty(disk->src)) { - if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0) - goto cleanup; - - releaseSeclabel = true; - if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0) goto cleanup; if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL) < 0) goto cleanup; + if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0) + goto cleanup; + + releaseSeclabel = true; + if (qemuProcessPrepareHostStorageDisk(vm, disk) < 0) goto cleanup; -- 2.42.0

If any of the images in a chain above a raw image have bitmaps, libvirt would attempt to merge them when doing a block commit or block copy operation, which would result into a error in the logs as creating persistent bitmaps in a raw image is not supported. Since libvirt cares only about persisten bitmaps we can simply skip the operation if the target of a block copy or block commit is a raw image. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_block.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index fab122942a..359595367b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3074,6 +3074,11 @@ qemuBlockBitmapsHandleBlockcopy(virStorageSource *src, { virStorageSource *base = NULL; + /* if copy destination is a 'raw' image there's no point in attempting to + * merge the bitmaps into it */ + if (mirror->format == VIR_STORAGE_FILE_RAW) + return 0; + if (shallow) base = src->backingStore; @@ -3107,6 +3112,11 @@ qemuBlockBitmapsHandleCommitFinish(virStorageSource *topsrc, { virStorageSource *writebitmapsrc = NULL; + /* if base is a 'raw' image there's no point in attempting to merge the + * bitmaps into it */ + if (basesrc->format == VIR_STORAGE_FILE_RAW) + return 0; + if (active) writebitmapsrc = basesrc; -- 2.42.0

On a Thursday in 2023, Peter Krempa wrote:
If any of the images in a chain above a raw image have bitmaps, libvirt would attempt to merge them when doing a block commit or block copy operation, which would result into a error in the logs as creating persistent bitmaps in a raw image is not supported.
Since libvirt cares only about persisten bitmaps we can simply skip the
*persistent
operation if the target of a block copy or block commit is a raw image.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_block.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
Jano

On a Thursday in 2023, Peter Krempa wrote:
Few issues I've found while testing the block layer for an upcoming patchset.
Peter Krempa (2): qemu: hotplug: Detect disk backing images before setting up security access qemu: block: Don't try to merge bitmaps into 'raw' images
src/qemu/qemu_block.c | 10 ++++++++++ src/qemu/qemu_hotplug.c | 10 +++++----- 2 files changed, 15 insertions(+), 5 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa