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

[libvirt] [PATCH 12/12] qemu: Emit VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED events



---
 src/qemu/qemu_hotplug.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 8c2f756..ea62e71 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2105,6 +2105,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
                            virDomainDiskDefPtr disk)
 {
     virDomainDeviceDef dev;
+    virDomainEventPtr event;
     size_t i;
 
     VIR_DEBUG("Removing disk %s from domain %p %s",
@@ -2112,6 +2113,10 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
 
     virDomainAuditDisk(vm, disk->src, NULL, "detach", true);
 
+    event = virDomainEventDeviceRemovedNewFromObj(vm, disk->info.alias);
+    if (event)
+        qemuDomainEventQueue(driver, event);
+
     for (i = 0; i < vm->def->ndisks; i++) {
         if (vm->def->disks[i] == disk) {
             virDomainDiskRemove(vm->def, i);
@@ -2140,15 +2145,20 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
 
 
 static void
-qemuDomainRemoveControllerDevice(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+qemuDomainRemoveControllerDevice(virQEMUDriverPtr driver,
                                  virDomainObjPtr vm,
                                  virDomainControllerDefPtr controller)
 {
+    virDomainEventPtr event;
     size_t i;
 
     VIR_DEBUG("Removing controller %s from domain %p %s",
               controller->info.alias, vm, vm->def->name);
 
+    event = virDomainEventDeviceRemovedNewFromObj(vm, controller->info.alias);
+    if (event)
+        qemuDomainEventQueue(driver, event);
+
     for (i = 0; i < vm->def->ncontrollers; i++) {
         if (vm->def->controllers[i] == controller) {
             virDomainControllerRemove(vm->def, i);
@@ -2168,6 +2178,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
 {
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     virNetDevVPortProfilePtr vport;
+    virDomainEventPtr event;
     size_t i;
 
     VIR_DEBUG("Removing network interface %s from domain %p %s",
@@ -2175,6 +2186,10 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
 
     virDomainAuditNet(vm, net, NULL, "detach", true);
 
+    event = virDomainEventDeviceRemovedNewFromObj(vm, net->info.alias);
+    if (event)
+        qemuDomainEventQueue(driver, event);
+
     for (i = 0; i < vm->def->nnets; i++) {
         if (vm->def->nets[i] == net) {
             virDomainNetRemove(vm->def, i);
@@ -2291,11 +2306,16 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
                            virDomainHostdevDefPtr hostdev)
 {
     virDomainNetDefPtr net = NULL;
+    virDomainEventPtr event;
     size_t i;
 
     VIR_DEBUG("Removing host device %s from domain %p %s",
               hostdev->info->alias, vm, vm->def->name);
 
+    event = virDomainEventDeviceRemovedNewFromObj(vm, hostdev->info->alias);
+    if (event)
+        qemuDomainEventQueue(driver, event);
+
     if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET) {
         net = hostdev->parent.data.net;
 
-- 
1.8.3.2


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