[PATCH] qemuProcessStop: Reattach NVMe disks a domain is mirroring into

Michal Privoznik posted 1 patch 3 years, 11 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/206ddd7fa6b3edce461f50fd2abe7b895ed65ff1.1588768886.git.mprivozn@redhat.com
There is a newer version of this series
src/qemu/qemu_process.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] qemuProcessStop: Reattach NVMe disks a domain is mirroring into
Posted by Michal Privoznik 3 years, 11 months ago
In v5.10.0-rc1~42 (which was later fixed in v6.0.0-rc1~487) I am
removing XATTRs for a file that QEMU is mirroring a disk into but
it is killed meanwhile. Well, if we call
qemuDomainStorageSourceAccessRevoke() instead of
qemuBlockRemoveImageMetadata() then not only the file will have
perms fixed (instead of left accessible to qemu) but if the
mirror destination is not a file but a NVMe disk, then the disk
will be reattached back to the host.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1825785

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_process.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 8ea470f75f..70c71e069c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7605,7 +7605,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
             virDomainDiskDefPtr disk = def->disks[i];
 
             if (disk->mirror)
-                qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->mirror);
+                qemuDomainStorageSourceAccessRevoke(driver, vm, disk->mirror);
 
             qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->src);
         }
-- 
2.26.2

Re: [PATCH] qemuProcessStop: Reattach NVMe disks a domain is mirroring into
Posted by Peter Krempa 3 years, 11 months ago
On Wed, May 06, 2020 at 14:41:36 +0200, Michal Privoznik wrote:
> In v5.10.0-rc1~42 (which was later fixed in v6.0.0-rc1~487) I am
> removing XATTRs for a file that QEMU is mirroring a disk into but
> it is killed meanwhile. Well, if we call
> qemuDomainStorageSourceAccessRevoke() instead of
> qemuBlockRemoveImageMetadata() then not only the file will have
> perms fixed (instead of left accessible to qemu) but if the
> mirror destination is not a file but a NVMe disk, then the disk
> will be reattached back to the host.
> 
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1825785
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_process.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index 8ea470f75f..70c71e069c 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -7605,7 +7605,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
>              virDomainDiskDefPtr disk = def->disks[i];
>  
>              if (disk->mirror)
> -                qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->mirror);
> +                qemuDomainStorageSourceAccessRevoke(driver, vm, disk->mirror);

IMO this function is not designed to be called after the VM is dead.

Specifically this would try to tear down cgroup access which was removed
previously and would try to set memory locking limits using 'prlimit'
with -1 'pid'.

image locks are also lifted because of the qemu process has already
exitted.