[libvirt] [PATCH 07/13] Implement controller hotplugging

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

 



From: Wolfgang Mauerer <wolfgang.mauerer@xxxxxxxxxxx>

This enables to hot-add disk controllers without attached
disks into the system. Previously, it was only possible to
(implicitly) add disk controllers in the static machine
configuration.

Notice that the actual functionality is only available
for qemu at present, but other emulators can be extended
likewise.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@xxxxxxxxxxx>
Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
 src/conf/domain_conf.c |    5 +----
 src/qemu/qemu_driver.c |   19 ++++++++++++++-----
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 91115b6..e90975f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -880,7 +880,6 @@ error:
      goto cleanup;
 }
 
-
 /* Parse the XML definition for a disk
  * @param node XML nodeset to parse for disk definition
  */
@@ -2940,7 +2939,6 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn,
 }
 #endif
 
-
 int virDomainDiskInsert(virDomainDefPtr def,
                         virDomainDiskDefPtr disk)
 {
@@ -3326,8 +3324,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
 
         def->controllers[def->ncontrollers++] = controller;
     }
-    /*    qsort(def->controllers, def->ncontrollers, sizeof(*def->controllers),
-          virDomainControllerQSort); */
+
     VIR_FREE(nodes);
 
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1fbfdde..1b20937 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4413,6 +4413,15 @@ try_command:
 	bus    = dev->data.disk->controller_pci_addr.bus;
 	slot   = dev->data.disk->controller_pci_addr.slot;
 
+        if (dev->data.disk->controller_name) {
+            /* TODO: Obtain the PCI address of the controller
+               from the data structures using the ID */
+        } else {
+            domain = dev->data.disk->controller_pci_addr.domain;
+            bus    = dev->data.disk->controller_pci_addr.bus;
+            slot   = dev->data.disk->controller_pci_addr.slot;
+	}
+
         if (dev->data.disk->bus_id != -1) {
             virBufferVSprintf(&buf, ",bus=%d", dev->data.disk->bus_id);
         }
@@ -4568,6 +4577,8 @@ try_command:
 
     VIR_FREE(cmd);
 
+    /* Naturally, the controller hotplug reply is identical with
+       any other PCI hotplug reply */
     if (qemudParsePciAddReply(vm, reply, &domain, &bus, &slot) < 0) {
         if (!tryOldSyntax && strstr(reply, "invalid char in expression")) {
 	    VIR_FREE(reply);
@@ -4582,18 +4593,14 @@ try_command:
     }
 
     /* Also fill in when the address was explicitely specified in
-       case qemu changed it (TODO: Can this really happen?) */
+       case qemu changed it */
     dev->data.controller->address->data.pci.domain = domain;
     dev->data.controller->address->data.pci.bus    = bus;
     dev->data.controller->address->data.pci.slot   = slot;
 
     VIR_FREE(reply);
 
-    /* NOTE: Sort function is added in a later commit */
     vm->def->controllers[vm->def->ncontrollers++] = dev->data.controller;
-    /*    qsort(vm->def->disks, vm->def->ndisks, sizeof(*vm->def->disks),
-    virDomainDiskQSort);*/
-
     return 0;
 }
 
@@ -4947,6 +4954,8 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
             virCgroupDenyDevicePath(cgroup,
                                     dev->data.disk->src);
         }
+    } else if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) {
+        ret = qemudDomainAttachDiskController(dom->conn, vm, dev);
     } else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
         ret = qemudDomainAttachNetDevice(dom->conn, driver, vm, dev, qemuCmdFlags);
     } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
-- 
1.6.4

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