[PATCH 2/4] Move ccwaddrs from QEMU's private data to domainDef

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

 



The definitions of struct virDomainCCWAddressSet and
virDomainCCWAddressSetFree() had to be moved from domain_addr
to domain_conf, because virDomainDefFree() has to free the CCW
address set when freeing domainDef.
---
 src/conf/domain_addr.c         |  9 ---------
 src/conf/domain_addr.h         |  7 -------
 src/conf/domain_conf.c         | 10 ++++++++++
 src/conf/domain_conf.h         |  9 +++++++++
 src/libvirt_private.syms       |  2 +-
 src/qemu/qemu_domain.c         |  1 -
 src/qemu/qemu_domain.h         |  1 -
 src/qemu/qemu_domain_address.c | 22 ++++++++--------------
 src/qemu/qemu_hotplug.c        |  8 ++++----
 9 files changed, 32 insertions(+), 37 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 3570a62..93eebf2 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -805,15 +805,6 @@ virDomainCCWAddressReleaseAddr(virDomainCCWAddressSetPtr addrs,
     return ret;
 }
 
-void virDomainCCWAddressSetFree(virDomainCCWAddressSetPtr addrs)
-{
-    if (!addrs)
-        return;
-
-    virHashFree(addrs->defined);
-    VIR_FREE(addrs);
-}
-
 virDomainCCWAddressSetPtr
 virDomainCCWAddressSetCreate(void)
 {
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index f4a9852..cda1e3f 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -157,13 +157,6 @@ int virDomainPCIAddressReserveNextSlot(virDomainPCIAddressSetPtr addrs,
                                        virDomainPCIConnectFlags flags)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
-struct _virDomainCCWAddressSet {
-    virHashTablePtr defined;
-    virDomainDeviceCCWAddress next;
-};
-typedef struct _virDomainCCWAddressSet virDomainCCWAddressSet;
-typedef virDomainCCWAddressSet *virDomainCCWAddressSetPtr;
-
 int virDomainCCWAddressAssign(virDomainDeviceInfoPtr dev,
                               virDomainCCWAddressSetPtr addrs,
                               bool autoassign)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 13230c9..12448dd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2535,6 +2535,15 @@ virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs)
     }
 }
 
+void virDomainCCWAddressSetFree(virDomainCCWAddressSetPtr addrs)
+{
+    if (!addrs)
+        return;
+
+    virHashFree(addrs->defined);
+    VIR_FREE(addrs);
+}
+
 void virDomainDefFree(virDomainDefPtr def)
 {
     size_t i;
@@ -2706,6 +2715,7 @@ void virDomainDefFree(virDomainDefPtr def)
     xmlFreeNode(def->metadata);
 
     virDomainVirtioSerialAddrSetFree(def->vioserialaddrs);
+    virDomainCCWAddressSetFree(def->ccwaddrs);
 
     VIR_FREE(def);
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2bac992..28fdb98 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2104,6 +2104,13 @@ struct _virDomainVirtioSerialAddrSet {
 typedef struct _virDomainVirtioSerialAddrSet virDomainVirtioSerialAddrSet;
 typedef virDomainVirtioSerialAddrSet *virDomainVirtioSerialAddrSetPtr;
 
+struct _virDomainCCWAddressSet {
+    virHashTablePtr defined;
+    virDomainDeviceCCWAddress next;
+};
+typedef struct _virDomainCCWAddressSet virDomainCCWAddressSet;
+typedef virDomainCCWAddressSet *virDomainCCWAddressSetPtr;
+
 typedef struct _virDomainPowerManagement virDomainPowerManagement;
 typedef virDomainPowerManagement *virDomainPowerManagementPtr;
 
@@ -2271,6 +2278,7 @@ struct _virDomainDef {
     virDomainKeyWrapDefPtr keywrap;
 
     virDomainVirtioSerialAddrSetPtr vioserialaddrs;
+    virDomainCCWAddressSetPtr ccwaddrs;
 
     /* Application-specific custom metadata */
     xmlNodePtr metadata;
@@ -2545,6 +2553,7 @@ void virDomainDefClearDeviceAliases(virDomainDefPtr def);
 void virDomainTPMDefFree(virDomainTPMDefPtr def);
 void virDomainVirtioSerialControllerFree(virDomainVirtioSerialControllerPtr cont);
 void virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs);
+void virDomainCCWAddressSetFree(virDomainCCWAddressSetPtr addrs);
 
 typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def,
                                            virDomainDeviceDefPtr dev,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7df6b35..75c8f70 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -94,7 +94,6 @@ virDomainCCWAddressAllocate;
 virDomainCCWAddressAssign;
 virDomainCCWAddressReleaseAddr;
 virDomainCCWAddressSetCreate;
-virDomainCCWAddressSetFree;
 virDomainCCWAddressValidate;
 virDomainGetBlkioParametersAssignFromDef;
 virDomainPCIAddressAsString;
@@ -165,6 +164,7 @@ virDomainBootTypeFromString;
 virDomainBootTypeToString;
 virDomainCapabilitiesPolicyTypeToString;
 virDomainCapsFeatureTypeToString;
+virDomainCCWAddressSetFree;
 virDomainChrConsoleTargetTypeFromString;
 virDomainChrConsoleTargetTypeToString;
 virDomainChrDefForeach;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f6ccbc0..5e3d305 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1248,7 +1248,6 @@ qemuDomainObjPrivateFree(void *data)
 
     virCgroupFree(&priv->cgroup);
     virDomainPCIAddressSetFree(priv->pciaddrs);
-    virDomainCCWAddressSetFree(priv->ccwaddrs);
     virDomainChrSourceDefFree(priv->monConfig);
     qemuDomainObjFreeJob(priv);
     VIR_FREE(priv->vcpupids);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 58221bb..4a15260 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -188,7 +188,6 @@ struct _qemuDomainObjPrivate {
     int *vcpupids;
 
     virDomainPCIAddressSetPtr pciaddrs;
-    virDomainCCWAddressSetPtr ccwaddrs;
 
     virQEMUCapsPtr qemuCaps;
     char *lockState;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 49f3652..5d58eb1 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -176,12 +176,10 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
  */
 static int
 qemuDomainAssignS390Addresses(virDomainDefPtr def,
-                              virQEMUCapsPtr qemuCaps,
-                              virDomainObjPtr obj)
+                              virQEMUCapsPtr qemuCaps)
 {
     int ret = -1;
     virDomainCCWAddressSetPtr addrs = NULL;
-    qemuDomainObjPrivatePtr priv = NULL;
 
     if (qemuDomainMachineIsS390CCW(def) &&
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
@@ -204,15 +202,11 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
             def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390);
     }
 
-    if (obj && obj->privateData) {
-        priv = obj->privateData;
-        if (addrs) {
-            /* if this is the live domain object, we persist the CCW addresses*/
-            virDomainCCWAddressSetFree(priv->ccwaddrs);
-            priv->ccwaddrs = addrs;
-            addrs = NULL;
-        }
-    }
+    /* we persist the CCW addresses*/
+    virDomainCCWAddressSetFree(def->ccwaddrs);
+    def->ccwaddrs = addrs;
+    addrs = NULL;
+
     ret = 0;
 
  cleanup:
@@ -1147,7 +1141,7 @@ qemuDomainAssignAddresses(virDomainDefPtr def,
     if (qemuDomainAssignSpaprVIOAddresses(def, qemuCaps) < 0)
         return -1;
 
-    if (qemuDomainAssignS390Addresses(def, qemuCaps, obj) < 0)
+    if (qemuDomainAssignS390Addresses(def, qemuCaps) < 0)
         return -1;
 
     qemuDomainAssignARMVirtioMMIOAddresses(def, qemuCaps);
@@ -1172,7 +1166,7 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
     if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
         qemuDomainMachineIsS390CCW(vm->def) &&
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW) &&
-        virDomainCCWAddressReleaseAddr(priv->ccwaddrs, info) < 0)
+        virDomainCCWAddressReleaseAddr(vm->def->ccwaddrs, info) < 0)
         VIR_WARN("Unable to release CCW address on %s",
                  NULLSTR(devstr));
     else if (virDeviceInfoPCIAddressPresent(info) &&
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 696ec9e..bed4173 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -327,7 +327,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
         goto cleanup;
 
     if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
-        if (virDomainCCWAddressAssign(&disk->info, priv->ccwaddrs,
+        if (virDomainCCWAddressAssign(&disk->info, vm->def->ccwaddrs,
                                       !disk->info.addr.ccw.assigned) < 0)
             goto error;
     } else if (!disk->info.type ||
@@ -457,7 +457,7 @@ 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 (virDomainCCWAddressAssign(&controller->info, vm->def->ccwaddrs,
                                       !controller->info.addr.ccw.assigned) < 0)
             goto cleanup;
     }
@@ -944,7 +944,7 @@ 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 (virDomainCCWAddressAssign(&net->info, vm->def->ccwaddrs,
                                       !net->info.addr.ccw.assigned) < 0)
             goto cleanup;
     } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
@@ -1594,7 +1594,7 @@ 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 (virDomainCCWAddressAssign(&rng->info, vm->def->ccwaddrs,
                                       !rng->info.addr.ccw.assigned) < 0)
             return -1;
     }
-- 
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]