[PATCH] qemu: processShutdownCompletedEvent: Remove inactive VM object after shutdown

Peter Krempa via Devel posted 1 patch 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/7582d28f4d229c40431aad0e71648261c81dedf5.1773065763.git.pkrempa@redhat.com
src/qemu/qemu_driver.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] qemu: processShutdownCompletedEvent: Remove inactive VM object after shutdown
Posted by Peter Krempa via Devel 2 weeks ago
From: Peter Krempa <pkrempa@redhat.com>

When the qemu process can't be successfully killed (e.g. when it's stuck
in a long system call) libvirt creates a watch and waits for the monitor
socket to go away before cleaning up the domain.

The cleanup code in 'processShutdownCompletedEvent' called
'qemuProcessStop' but didn't call also 'qemuDomainRemoveInactive' which
would break if a transient VM would undergo the delayed cleanup as we'd
still have it's VM object around.

Fixes: e62c26a20dced58ea342d9cb8f5e9164dc3bb023
Closes: https://gitlab.com/libvirt/libvirt/-/work_items/853
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9e4d0f8640..7d33477636 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4079,6 +4079,7 @@ processShutdownCompletedEvent(virDomainObj *vm)

     if (virDomainObjIsActive(vm)) {
         qemuProcessStop(vm, VIR_DOMAIN_SHUTOFF_UNKNOWN, VIR_ASYNC_JOB_NONE, 0);
+        qemuDomainRemoveInactive(vm, 0, false);
     }

     qemuProcessEndStopJob(vm);
-- 
2.53.0
Re: [PATCH] qemu: processShutdownCompletedEvent: Remove inactive VM object after shutdown
Posted by Michal Prívozník via Devel 2 weeks ago
On 3/9/26 15:16, Peter Krempa via Devel wrote:
> From: Peter Krempa <pkrempa@redhat.com>
> 
> When the qemu process can't be successfully killed (e.g. when it's stuck
> in a long system call) libvirt creates a watch and waits for the monitor
> socket to go away before cleaning up the domain.
> 
> The cleanup code in 'processShutdownCompletedEvent' called
> 'qemuProcessStop' but didn't call also 'qemuDomainRemoveInactive' which
> would break if a transient VM would undergo the delayed cleanup as we'd
> still have it's VM object around.
> 
> Fixes: e62c26a20dced58ea342d9cb8f5e9164dc3bb023
> Closes: https://gitlab.com/libvirt/libvirt/-/work_items/853
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_driver.c | 1 +
>  1 file changed, 1 insertion(+)
> 

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Michal