From 4c5e3b1ca0a9ec68796d28f4cc39f5bbbff77a8a Mon Sep 17 00:00:00 2001 From: Kirill Shchetiniuk via Devel Date: Tue, 25 Mar 2025 15:11:59 +0100 Subject: [PATCH] ch: virCHProcessEvent() vm shutdown event handler fix When the domain shutdown was executed from virsh, only the VM process (a child of the CH monitor) was terminated. Since we assume only one VM per monitor, the monitor process should also be terminated. Modified the VM shutdown event handler to match the VMM shutdown behavior, ensuring the VM monitor stops along with the VM. Also updated the virCHEventStopProcess job type, as it only destroys the domain rather than modifying anything. Signed-off-by: Kirill Shchetiniuk Reviewed-by: Michal Privoznik --- src/ch/ch_events.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ch/ch_events.c b/src/ch/ch_events.c index 32846ba4e5..f1dc5c6f4c 100644 --- a/src/ch/ch_events.c +++ b/src/ch/ch_events.c @@ -57,7 +57,7 @@ virCHEventStopProcess(virDomainObj *vm, virCHDriver *driver = ((virCHDomainObjPrivate *)vm->privateData)->driver; virObjectLock(vm); - if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY)) + if (virDomainObjBeginJob(vm, VIR_JOB_DESTROY)) return -1; virCHProcessStop(driver, vm, reason); virDomainObjEndJob(vm); @@ -108,17 +108,13 @@ virCHProcessEvent(virCHMonitor *mon, case VIR_CH_EVENT_VM_DELETED: break; case VIR_CH_EVENT_VMM_SHUTDOWN: + case VIR_CH_EVENT_VM_SHUTDOWN: if (virCHEventStopProcess(vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN)) { VIR_WARN("Failed to mark the VM(%s) as SHUTDOWN!", vm->def->name); ret = -1; } break; - case VIR_CH_EVENT_VM_SHUTDOWN: - virObjectLock(vm); - virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_SHUTDOWN); - virObjectUnlock(vm); - break; case VIR_CH_EVENT_VM_REBOOTED: virObjectLock(vm); virCHProcessUpdateInfo(vm); -- 2.47.3