[PATCH 2/4] ch: Make sure the cloud-hypervisor process is killed in virCHProcessStop()

Michal Privoznik via Devel posted 4 patches 3 weeks, 4 days ago
[PATCH 2/4] ch: Make sure the cloud-hypervisor process is killed in virCHProcessStop()
Posted by Michal Privoznik via Devel 3 weeks, 4 days ago
From: Michal Privoznik <mprivozn@redhat.com>

Currently, virCHProcessStop() is called either when the
cloud-hypervisor process dies gracefully (e.g. on shutdown
initiated from within the guest) or when virDomainDestroy() is
called (or on failed start attempt, but that's not important
right now).

At any rate, if the cloud-hypervisor process is running it's not
a child process of libvirtd rather than the init (per
virCommandDaemonize() called inside of virCHMonitorNew()). This
distinction is important because virCHProcessStop() then calls
virProcessAbort() thinking it'll kill the process. Well,
virProcessAbort() works only on child processes.

Switch to virProcessKillPainfully() which does work in such
cases.

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

diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c
index 5195d3f5da..6b779285e1 100644
--- a/src/ch/ch_process.c
+++ b/src/ch/ch_process.c
@@ -1028,7 +1028,7 @@ virCHProcessStop(virCHDriver *driver,
     virErrorPreserveLast(&orig_err);
 
     if (priv->monitor) {
-        virProcessAbort(vm->pid);
+        virProcessKillPainfully(vm->pid, true);
         g_clear_pointer(&priv->monitor, virCHMonitorClose);
     }
 
-- 
2.49.1