[PATCH 27/27] RFC: qemu: hotplug: Add DEVICE_(ADDED|DELETED) events for vcpus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since vcpus behave as devices it has the same implications. Add events
so that management can see.

For instances where a hotpluggable instance adds multiple logical vcpus
the events are synthetized.

Note: A different option would be to add a VCPU_LIFECYCLE event rather
than abusing the device ones, but for now this is good at least for
testing purposes.
---
 src/qemu/qemu_driver.c  | 10 ++++++++++
 src/qemu/qemu_hotplug.c | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 260a34a..9161504 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4607,6 +4607,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
     int rc;
     int oldvcpus = virDomainDefGetVcpus(vm->def);
     size_t i;
+    virObjectEventPtr event;

     if (newhotplug) {
         if (virAsprintf(&vcpupriv->alias, "vcpu%u", vcpu) < 0)
@@ -4649,6 +4650,15 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver,
         if (vcpupriv->tid > 0 &&
             qemuProcessSetupVcpu(vm, i) < 0)
             goto cleanup;
+
+        if (newhotplug) {
+            char *alias;
+            if (virAsprintf(&alias, "vcpu%zu", i) < 0)
+                goto cleanup;
+
+            event = virDomainEventDeviceAddedNewFromObj(vm, alias);
+            qemuDomainEventQueue(driver, event);
+        }
     }

     if (qemuDomainValidateVcpuInfo(vm) < 0)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1bdde5b..db43460 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4431,6 +4431,7 @@ qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
     qemuDomainVcpuPrivatePtr vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo);
     int oldvcpus = virDomainDefGetVcpus(vm->def);
     unsigned int nvcpus = vcpupriv->vcpus;
+    virObjectEventPtr event;
     size_t i;

     if (qemuDomainRefreshVcpuInfo(driver, vm, QEMU_ASYNC_JOB_NONE, false) < 0)
@@ -4456,9 +4457,18 @@ qemuDomainRemoveVcpu(virQEMUDriverPtr driver,
     virDomainAuditVcpu(vm, oldvcpus, oldvcpus - nvcpus, "update", true);

     for (i = vcpu; i < vcpu + nvcpus; i++) {
+        char *alias;
         vcpuinfo = virDomainDefGetVcpu(vm->def, i);
         if (virCgroupDelThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, i) < 0)
             return -1;
+
+        /* synthetize the event */
+        if (virAsprintf(&alias, "vcpu%zu", i) < 0)
+            return -1;
+
+        event = virDomainEventDeviceRemovedNewFromObj(vm, alias);
+        qemuDomainEventQueue(driver, event);
+        VIR_FREE(alias);
     }

     return 0;
-- 
2.9.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]