[RFC PATCH 2/3] qemu: introduce qemuDomainRemoveDimmDevice

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

 



This func being introduced is responsible for deleting memory backend
and removing dimm from VM def.

Signed-off-by: Zhu Guihua <zhugh.fnst@xxxxxxxxxxxxxx>
---
 src/qemu/qemu_hotplug.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b7ca41e..8a0594f 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2931,6 +2931,44 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
 }
 
 
+static int
+qemuDomainRemoveDimmDevice(virQEMUDriverPtr driver,
+                           virDomainObjPtr vm,
+                           virDomainDimmDefPtr dimm)
+{
+    virObjectEventPtr event;
+    char *objAlias = NULL;
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    int ret = -1;
+
+    VIR_DEBUG("Removing dimm device %s from domain %p %s",
+              dimm->info.alias, vm, vm->def->name);
+
+    if (virAsprintf(&objAlias, "obj%s", dimm->info.alias) < 0)
+        goto cleanup;
+
+    qemuDomainObjEnterMonitor(driver, vm);
+    if (qemuMonitorDelMemoryBackend(priv->mon, objAlias) < 0) {
+        qemuDomainObjExitMonitor(driver, vm);
+        goto cleanup;
+    }
+    qemuDomainObjExitMonitor(driver, vm);
+
+    event = virDomainEventDeviceRemovedNewFromObj(vm, dimm->info.alias);
+    if (event)
+        qemuDomainEventQueue(driver, event);
+
+    virDomainDimmRemove(vm->def, dimm);
+    virDomainDimmDefFree(dimm);
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(objAlias);
+    return ret;
+}
+
+
 int
 qemuDomainRemoveDevice(virQEMUDriverPtr driver,
                        virDomainObjPtr vm,
@@ -2956,6 +2994,9 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
         break;
 
     case VIR_DOMAIN_DEVICE_DIMM:
+        qemuDomainRemoveDimmDevice(driver, vm, dev->data.dimm);
+        break;
+
     case VIR_DOMAIN_DEVICE_NONE:
     case VIR_DOMAIN_DEVICE_LEASE:
     case VIR_DOMAIN_DEVICE_FS:
-- 
1.9.3

--
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]