]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ch: virCHProcessEvent() vm shutdown event handler fix
authorKirill Shchetiniuk via Devel <devel@lists.libvirt.org>
Tue, 25 Mar 2025 14:11:59 +0000 (15:11 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 2 Apr 2025 15:35:28 +0000 (17:35 +0200)
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 <kshcheti@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/ch/ch_events.c

index 32846ba4e5dfe3d2f6b465161e4a074e680fbb94..f1dc5c6f4ce17bdd9794ce2aa48a116096274f5a 100644 (file)
@@ -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);