[PATCH v2 05/10] qemu_hotplug: generate ccw address list on demand

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

 



Dropping the caching of ccw address set.
Instead of using the cached address set, functions in qemu_hotplug.c
now recalculate it on demand.
---
 src/qemu/qemu_hotplug.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 5c82361..3deeb0b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -313,6 +313,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
     bool driveAdded = false;
     bool secobjAdded = false;
     bool encobjAdded = false;
+    virDomainCCWAddressSetPtr ccwaddrs = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     const char *src = virDomainDiskGetSource(disk);
     virJSONValuePtr secobjProps = NULL;
@@ -337,7 +338,9 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
         goto cleanup;
 
     if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-        if (virDomainCCWAddressAssign(&disk->info, priv->ccwaddrs,
+        if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def)))
+            goto error;
+        if (virDomainCCWAddressAssign(&disk->info, ccwaddrs,
                                       !disk->info.addr.ccw.assigned) < 0)
             goto error;
     } else if (!disk->info.type ||
@@ -416,6 +419,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
     virJSONValueFree(secobjProps);
     virJSONValueFree(encobjProps);
     qemuDomainSecretDiskDestroy(disk);
+    virDomainCCWAddressSetFree(ccwaddrs);
     VIR_FREE(devstr);
     VIR_FREE(drivestr);
     VIR_FREE(drivealias);
@@ -459,6 +463,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
     const char* type = virDomainControllerTypeToString(controller->type);
     char *devstr = NULL;
     qemuDomainObjPrivatePtr priv = vm->privateData;
+    virDomainCCWAddressSetPtr ccwaddrs = NULL;
     bool releaseaddr = false;
 
     if (controller->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
@@ -500,7 +505,9 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
         if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0)
             goto cleanup;
     } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-        if (virDomainCCWAddressAssign(&controller->info, priv->ccwaddrs,
+        if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def)))
+            goto cleanup;
+        if (virDomainCCWAddressAssign(&controller->info, ccwaddrs,
                                       !controller->info.addr.ccw.assigned) < 0)
             goto cleanup;
     }
@@ -533,6 +540,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
         qemuDomainReleaseDeviceAddress(vm, &controller->info, NULL);
 
     VIR_FREE(devstr);
+    virDomainCCWAddressSetFree(ccwaddrs);
     return ret;
 }
 
@@ -901,6 +909,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
     int actualType;
     virNetDevBandwidthPtr actualBandwidth;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    virDomainCCWAddressSetPtr ccwaddrs = NULL;
     size_t i;
 
     /* preallocate new slot for device */
@@ -1038,7 +1047,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
     if (qemuDomainMachineIsS390CCW(vm->def) &&
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
         net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-        if (virDomainCCWAddressAssign(&net->info, priv->ccwaddrs,
+        if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def)))
+            goto cleanup;
+        if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
                                       !net->info.addr.ccw.assigned) < 0)
             goto cleanup;
     } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
@@ -1212,6 +1223,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
     VIR_FREE(vhostfd);
     VIR_FREE(vhostfdName);
     virObjectUnref(cfg);
+    virDomainCCWAddressSetFree(ccwaddrs);
 
     return ret;
 
@@ -1692,6 +1704,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
     bool chardevAdded = false;
     bool objAdded = false;
     virJSONValuePtr props = NULL;
+    virDomainCCWAddressSetPtr ccwaddrs = NULL;
     const char *type;
     int ret = -1;
     int rv;
@@ -1722,9 +1735,11 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
         if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &rng->info) < 0)
             return -1;
     } else if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-        if (virDomainCCWAddressAssign(&rng->info, priv->ccwaddrs,
+        if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def)))
+            goto cleanup;
+        if (virDomainCCWAddressAssign(&rng->info, ccwaddrs,
                                       !rng->info.addr.ccw.assigned) < 0)
-            return -1;
+            goto cleanup;
     }
 
     /* build required metadata */
@@ -1775,6 +1790,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
     VIR_FREE(charAlias);
     VIR_FREE(objAlias);
     VIR_FREE(devstr);
+    virDomainCCWAddressSetFree(ccwaddrs);
     return ret;
 
  exit_monitor:
-- 
2.7.4 (Apple Git-66)

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