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

wolfgang.mauerer at siemens.com wolfgang.mauerer at siemens.com
Mon Nov 16 23:53:38 UTC 2009


From: Wolfgang Mauerer <wolfgang.mauerer at siemens.com>

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 at siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka at siemens.com>
---
 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




More information about the libvir-list mailing list