[PATCH 4/4] Move pciaddrs from private data to domainDef

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

 



---
 src/bhyve/bhyve_device.c       | 16 +++-------------
 src/bhyve/bhyve_domain.c       |  2 --
 src/bhyve/bhyve_domain.h       |  3 ---
 src/conf/domain_conf.c         |  1 +
 src/conf/domain_conf.h         |  1 +
 src/qemu/qemu_domain.c         |  3 +--
 src/qemu/qemu_domain.h         |  2 --
 src/qemu/qemu_domain_address.c | 22 ++++++++--------------
 src/qemu/qemu_domain_address.h |  3 +--
 src/qemu/qemu_hotplug.c        | 15 +++++++--------
 src/qemu/qemu_process.c        |  6 +++---
 tests/qemuhotplugtest.c        |  2 +-
 12 files changed, 26 insertions(+), 50 deletions(-)

diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index 8373a5f..9ddd9aa 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -135,11 +135,9 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
     return -1;
 }
 
-int bhyveDomainAssignPCIAddresses(virDomainDefPtr def,
-                                  virDomainObjPtr obj)
+int bhyveDomainAssignPCIAddresses(virDomainDefPtr def)
 {
     virDomainPCIAddressSetPtr addrs = NULL;
-    bhyveDomainObjPrivatePtr priv = NULL;
 
     int ret = -1;
 
@@ -149,16 +147,8 @@ int bhyveDomainAssignPCIAddresses(virDomainDefPtr def,
     if (bhyveAssignDevicePCISlots(def, addrs) < 0)
         goto cleanup;
 
-    if (obj && obj->privateData) {
-        priv = obj->privateData;
-        if (addrs) {
-            virDomainPCIAddressSetFree(priv->pciaddrs);
-            priv->persistentAddrs = 1;
-            priv->pciaddrs = addrs;
-        } else {
-            priv->persistentAddrs = 0;
-        }
-    }
+    virDomainPCIAddressSetFree(def->pciaddrs);
+    def->pciaddrs = addrs;
 
     ret = 0;
 
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 89cb171..81e5c8d 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -47,8 +47,6 @@ bhyveDomainObjPrivateFree(void *data)
 {
     bhyveDomainObjPrivatePtr priv = data;
 
-    virDomainPCIAddressSetFree(priv->pciaddrs);
-
     VIR_FREE(priv);
 }
 
diff --git a/src/bhyve/bhyve_domain.h b/src/bhyve/bhyve_domain.h
index 0a60392..262605e 100644
--- a/src/bhyve/bhyve_domain.h
+++ b/src/bhyve/bhyve_domain.h
@@ -31,9 +31,6 @@
 typedef struct _bhyveDomainObjPrivate bhyveDomainObjPrivate;
 typedef bhyveDomainObjPrivate *bhyveDomainObjPrivatePtr;
 struct _bhyveDomainObjPrivate {
-    virDomainPCIAddressSetPtr pciaddrs;
-    bool persistentAddrs;
-
     bhyveMonitorPtr mon;
 };
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5f31a97..96731df 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2726,6 +2726,7 @@ void virDomainDefFree(virDomainDefPtr def)
 
     virDomainVirtioSerialAddrSetFree(def->vioserialaddrs);
     virDomainCCWAddressSetFree(def->ccwaddrs);
+    virDomainPCIAddressSetFree(def->pciaddrs);
 
     VIR_FREE(def);
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 887e061..a1f14e0 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2319,6 +2319,7 @@ struct _virDomainDef {
 
     virDomainVirtioSerialAddrSetPtr vioserialaddrs;
     virDomainCCWAddressSetPtr ccwaddrs;
+    virDomainPCIAddressSetPtr pciaddrs;
 
     /* Application-specific custom metadata */
     xmlNodePtr metadata;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5e3d305..afcb012 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1247,7 +1247,6 @@ qemuDomainObjPrivateFree(void *data)
     virObjectUnref(priv->qemuCaps);
 
     virCgroupFree(&priv->cgroup);
-    virDomainPCIAddressSetFree(priv->pciaddrs);
     virDomainChrSourceDefFree(priv->monConfig);
     qemuDomainObjFreeJob(priv);
     VIR_FREE(priv->vcpupids);
@@ -2433,7 +2432,7 @@ qemuDomainDefAssignAddresses(virDomainDef *def,
                                             def->emulator)))
         goto cleanup;
 
-    if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
+    if (qemuDomainAssignAddresses(def, qemuCaps) < 0)
         goto cleanup;
 
     ret = 0;
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 4a15260..59b41de 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -187,8 +187,6 @@ struct _qemuDomainObjPrivate {
     int nvcpupids;
     int *vcpupids;
 
-    virDomainPCIAddressSetPtr pciaddrs;
-
     virQEMUCapsPtr qemuCaps;
     char *lockState;
 
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 5d58eb1..fa42144 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -947,12 +947,10 @@ qemuDomainSupportsPCI(virDomainDefPtr def,
 
 static int
 qemuDomainAssignPCIAddresses(virDomainDefPtr def,
-                             virQEMUCapsPtr qemuCaps,
-                             virDomainObjPtr obj)
+                             virQEMUCapsPtr qemuCaps)
 {
     int ret = -1;
     virDomainPCIAddressSetPtr addrs = NULL;
-    qemuDomainObjPrivatePtr priv = NULL;
     int max_idx = -1;
     int nbuses = 0;
     size_t i;
@@ -1113,13 +1111,10 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
         }
     }
 
-    if (obj && obj->privateData) {
-        priv = obj->privateData;
-        /* if this is the live domain object, we persist the PCI addresses */
-        virDomainPCIAddressSetFree(priv->pciaddrs);
-        priv->pciaddrs = addrs;
-        addrs = NULL;
-    }
+    /* we persist the PCI addresses */
+    virDomainPCIAddressSetFree(def->pciaddrs);
+    def->pciaddrs = addrs;
+    addrs = NULL;
 
     ret = 0;
 
@@ -1132,8 +1127,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
 
 int
 qemuDomainAssignAddresses(virDomainDefPtr def,
-                          virQEMUCapsPtr qemuCaps,
-                          virDomainObjPtr obj)
+                          virQEMUCapsPtr qemuCaps)
 {
     if (virDomainAssignVirtioSerialAddresses(def) < 0)
         return -1;
@@ -1146,7 +1140,7 @@ qemuDomainAssignAddresses(virDomainDefPtr def,
 
     qemuDomainAssignARMVirtioMMIOAddresses(def, qemuCaps);
 
-    if (qemuDomainAssignPCIAddresses(def, qemuCaps, obj) < 0)
+    if (qemuDomainAssignPCIAddresses(def, qemuCaps) < 0)
         return -1;
 
     return 0;
@@ -1170,7 +1164,7 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
         VIR_WARN("Unable to release CCW address on %s",
                  NULLSTR(devstr));
     else if (virDeviceInfoPCIAddressPresent(info) &&
-             virDomainPCIAddressReleaseSlot(priv->pciaddrs,
+             virDomainPCIAddressReleaseSlot(vm->def->pciaddrs,
                                             &info->addr.pci) < 0)
         VIR_WARN("Unable to release PCI address on %s",
                  NULLSTR(devstr));
diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h
index 50019b8..03b99d9 100644
--- a/src/qemu/qemu_domain_address.h
+++ b/src/qemu/qemu_domain_address.h
@@ -32,8 +32,7 @@ int qemuDomainSetSCSIControllerModel(const virDomainDef *def,
                                      int *model);
 
 int qemuDomainAssignAddresses(virDomainDefPtr def,
-                              virQEMUCapsPtr qemuCaps,
-                              virDomainObjPtr obj)
+                              virQEMUCapsPtr qemuCaps)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
 void qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index bed4173..46e2143 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -332,7 +332,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
             goto error;
     } else if (!disk->info.type ||
                 disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-        if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &disk->info) < 0)
+        if (virDomainPCIAddressEnsureAddr(vm->def->pciaddrs, &disk->info) < 0)
             goto error;
     }
     releaseaddr = true;
@@ -454,7 +454,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
 
     if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
         controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-        if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &controller->info) < 0)
+        if (virDomainPCIAddressEnsureAddr(vm->def->pciaddrs, &controller->info) < 0)
             goto cleanup;
     } else if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
         if (virDomainCCWAddressAssign(&controller->info, vm->def->ccwaddrs,
@@ -951,7 +951,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("virtio-s390 net device cannot be hotplugged."));
         goto cleanup;
-    } else if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) {
+    } else if (virDomainPCIAddressEnsureAddr(vm->def->pciaddrs, &net->info) < 0) {
         goto cleanup;
     }
 
@@ -1230,7 +1230,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
 
     if (qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1) < 0)
         goto error;
-    if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, hostdev->info) < 0)
+    if (virDomainPCIAddressEnsureAddr(vm->def->pciaddrs, hostdev->info) < 0)
         goto error;
     releaseaddr = true;
     if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO &&
@@ -1458,7 +1458,6 @@ qemuDomainChrRemove(virDomainDefPtr vmdef,
 
 static int
 qemuDomainAttachChrDeviceAssignAddr(virDomainDefPtr vmdef,
-                                    qemuDomainObjPrivatePtr priv,
                                     virDomainChrDefPtr chr)
 {
     if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
@@ -1470,7 +1469,7 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainDefPtr vmdef,
 
     } else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
                chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI) {
-        if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &chr->info) < 0)
+        if (virDomainPCIAddressEnsureAddr(vmdef->pciaddrs, &chr->info) < 0)
             return -1;
         return 1;
 
@@ -1510,7 +1509,7 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
     if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
         goto cleanup;
 
-    if ((rc = qemuDomainAttachChrDeviceAssignAddr(vmdef, priv, chr)) < 0)
+    if ((rc = qemuDomainAttachChrDeviceAssignAddr(vmdef, chr)) < 0)
         goto cleanup;
     if (rc == 1)
         need_release = true;
@@ -1591,7 +1590,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
 
     if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
         rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-        if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &rng->info) < 0)
+        if (virDomainPCIAddressEnsureAddr(vm->def->pciaddrs, &rng->info) < 0)
             return -1;
     } else if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
         if (virDomainCCWAddressAssign(&rng->info, vm->def->ccwaddrs,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 373e7a9..f107193 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3291,7 +3291,7 @@ qemuProcessReconnect(void *opaque)
         goto cleanup;
     }
 
-    if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps, obj)) < 0)
+    if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps)) < 0)
         goto error;
 
     /* if domain requests security driver we haven't loaded, report error, but
@@ -4878,7 +4878,7 @@ qemuProcessPrepareDomain(virConnectPtr conn,
      * use in hotplug
      */
     VIR_DEBUG("Assigning domain PCI addresses");
-    if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
+    if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps)) < 0)
         goto cleanup;
 
     if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
@@ -6066,7 +6066,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
      * use in hotplug
      */
     VIR_DEBUG("Assigning domain PCI addresses");
-    if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
+    if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps)) < 0)
         goto error;
 
     if ((timestamp = virTimeStringNow()) == NULL)
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 13055ab..6d90a0c 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -86,7 +86,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
                                                VIR_DOMAIN_DEF_PARSE_INACTIVE)))
         goto cleanup;
 
-    if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, *vm) < 0)
+    if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps) < 0)
         goto cleanup;
 
     if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0)
-- 
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]