Emit the vcpu-removed event when QEMU vCPU unplug completes.

Hook this into qemuDomainRemoveVcpu(), which covers both the
synchronous completion path and the DEVICE_DELETED-driven alias
removal path.

Some architectures may have multiple vcpus grouped under a single qemu
vcpu object; on those platforms a `vcpu-removed` event will be emitted
for each vcpu that is removed from this group.

Signed-off-by: Akash Kulhalli <[email protected]>
---
 src/qemu/qemu_hotplug.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b7a282b96e52..3c9adb2e6c37 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -6728,6 +6728,7 @@ qemuDomainRemoveVcpu(virDomainObj *vm,
     unsigned int nvcpus = vcpupriv->vcpus;
     size_t i;
     ssize_t offlineVcpuWithTid = -1;
+    virObjectEvent *event = NULL;
 
     if (qemuDomainRefreshVcpuInfo(vm, VIR_ASYNC_JOB_NONE, false) < 0)
         return -1;
@@ -6745,6 +6746,10 @@ qemuDomainRemoveVcpu(virDomainObj *vm,
             if (offlineVcpuWithTid == -1)
                 offlineVcpuWithTid = i;
         }
+
+        /* fire the `vcpu-removed` event for each removed vcpu */
+        event = virDomainEventVcpuRemovedNewFromObj(vm, i);
+        virObjectEventStateQueue(priv->driver->domainEventState, event);
     }
 
     if (offlineVcpuWithTid != -1) {
-- 
2.47.3

Reply via email to