[PATCH 11/13] Move and rename qemuDomainPCIAddrSetCreateFromDomain

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

 



qemuDomainPCIAddrSetCreateFromDomain is renamed to
virDomainPCIAddrSetCreateFromDomain and moved from
qemu_domain_address.c to domain_addr.c

All these functions are being moved because they don't depend on
qemu, so they have the potential to be reused for more hypervisors.
---
 src/conf/domain_addr.c         | 43 ++++++++++++++++++++++++++++++++++++++++++
 src/conf/domain_addr.h         |  7 +++++++
 src/libvirt_private.syms       |  1 +
 src/qemu/qemu_domain_address.c | 43 +-----------------------------------------
 src/qemu/qemu_domain_address.h |  6 ------
 src/qemu/qemu_hotplug.c        | 12 ++++++------
 6 files changed, 58 insertions(+), 54 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 3ac7d3f..ec68ca0 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -2250,3 +2250,46 @@ virDomainSupportsPCI(virDomainDefPtr def,
 
     return false;
 }
+
+
+virDomainPCIAddressSetPtr
+virDomainPCIAddrSetCreateFromDomain(virDomainDefPtr def,
+                                     bool virtioMMIOEnabled,
+                                     bool videoPrimaryEnabled,
+                                     bool gpexEnabled)
+{
+    virDomainPCIAddressSetPtr addrs = NULL;
+    int max_idx = -1;
+    int nbuses = 0;
+    virDomainPCIAddressSetPtr ret = NULL;
+    size_t i;
+
+    for (i = 0; i < def->ncontrollers; i++) {
+        if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
+            if ((int) def->controllers[i]->idx > max_idx)
+                max_idx = def->controllers[i]->idx;
+        }
+    }
+
+    nbuses = max_idx + 1;
+
+    if (!(addrs = virDomainPCIAddressSetCreate(def, nbuses, false)))
+        goto cleanup;
+
+    if (virDomainSupportsPCI(def, gpexEnabled)) {
+        if (virDomainValidateDevicePCISlotsChipsets(def, addrs,
+                                             videoPrimaryEnabled) < 0)
+            goto cleanup;
+
+        if (virDomainAssignDevicePCISlots(def, addrs, virtioMMIOEnabled) < 0)
+            goto cleanup;
+    }
+
+    ret = addrs;
+    addrs = NULL;
+
+ cleanup:
+    virDomainPCIAddressSetFree(addrs);
+
+    return ret;
+}
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index f06ae46..5bfec3b 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -290,4 +290,11 @@ virDomainSupportsPCI(virDomainDefPtr def,
                      bool gpexEnabled)
     ATTRIBUTE_NONNULL(1);
 
+virDomainPCIAddressSetPtr
+virDomainPCIAddrSetCreateFromDomain(virDomainDefPtr def,
+                                     bool virtioMMIOEnabled,
+                                     bool videoPrimaryEnabled,
+                                     bool gpexEnabled)
+    ATTRIBUTE_NONNULL(1);
+
 #endif /* __DOMAIN_ADDR_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9d1024b..a111f02 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -112,6 +112,7 @@ virDomainPCIAddressSetFree;
 virDomainPCIAddressSetGrow;
 virDomainPCIAddressSlotInUse;
 virDomainPCIAddressValidate;
+virDomainPCIAddrSetCreateFromDomain;
 virDomainPCIBusFullyReserved;
 virDomainPCIControllerModelToConnectType;
 virDomainSupportsPCI;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 795fcd0..2754623 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -397,47 +397,6 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont)
     }
 }
 
-virDomainPCIAddressSetPtr
-qemuDomainPCIAddrSetCreateFromDomain(virDomainDefPtr def,
-                                     bool virtioMMIOEnabled,
-                                     bool videoPrimaryEnabled,
-                                     bool gpexEnabled)
-{
-    virDomainPCIAddressSetPtr addrs = NULL;
-    int max_idx = -1;
-    int nbuses = 0;
-    virDomainPCIAddressSetPtr ret = NULL;
-    size_t i;
-
-    for (i = 0; i < def->ncontrollers; i++) {
-        if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
-            if ((int) def->controllers[i]->idx > max_idx)
-                max_idx = def->controllers[i]->idx;
-        }
-    }
-
-    nbuses = max_idx + 1;
-
-    if (!(addrs = virDomainPCIAddressSetCreate(def, nbuses, false)))
-        goto cleanup;
-
-    if (virDomainSupportsPCI(def, gpexEnabled)) {
-        if (virDomainValidateDevicePCISlotsChipsets(def, addrs,
-                                             videoPrimaryEnabled) < 0)
-            goto cleanup;
-
-        if (virDomainAssignDevicePCISlots(def, addrs, virtioMMIOEnabled) < 0)
-            goto cleanup;
-    }
-
-    ret = addrs;
-    addrs = NULL;
-
- cleanup:
-    virDomainPCIAddressSetFree(addrs);
-
-    return ret;
-}
 
 static int
 qemuDomainAssignPCIAddresses(virDomainDefPtr def,
@@ -521,7 +480,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
         goto cleanup;
     }
 
-    if (!(addrs = qemuDomainPCIAddrSetCreateFromDomain(def,
+    if (!(addrs = virDomainPCIAddrSetCreateFromDomain(def,
                                                        virtioMMIOEnabled,
                                                        videoPrimaryEnabled,
                                                        gpexEnabled)))
diff --git a/src/qemu/qemu_domain_address.h b/src/qemu/qemu_domain_address.h
index 77a5541..b6ef65d 100644
--- a/src/qemu/qemu_domain_address.h
+++ b/src/qemu/qemu_domain_address.h
@@ -41,12 +41,6 @@ virDomainCCWAddressSetPtr
 qemuDomainCCWAddrSetCreateFromDomain(virDomainDefPtr def)
     ATTRIBUTE_NONNULL(1);
 
-virDomainPCIAddressSetPtr
-qemuDomainPCIAddrSetCreateFromDomain(virDomainDefPtr def,
-                                     bool virtioMMIOEnabled,
-                                     bool videoPrimaryEnabled,
-                                     bool gpexEnabled)
-    ATTRIBUTE_NONNULL(1);
 
 # define __QEMU_DOMAIN_ADDRESS_H__
 
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index fa7a8e9..a193cc0 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -334,7 +334,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
             goto error;
     } else if (!disk->info.type ||
                 disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-        if (!(pciaddrs = qemuDomainPCIAddrSetCreateFromDomain(vm->def,
+        if (!(pciaddrs = virDomainPCIAddrSetCreateFromDomain(vm->def,
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO),
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY),
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_GPEX))))
@@ -456,7 +456,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 (!(pciaddrs = qemuDomainPCIAddrSetCreateFromDomain(vm->def,
+        if (!(pciaddrs = virDomainPCIAddrSetCreateFromDomain(vm->def,
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO),
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY),
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_GPEX))))
@@ -976,7 +976,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
                        _("virtio-s390 net device cannot be hotplugged."));
         goto cleanup;
     } else {
-        if (!(pciaddrs = qemuDomainPCIAddrSetCreateFromDomain(vm->def,
+        if (!(pciaddrs = virDomainPCIAddrSetCreateFromDomain(vm->def,
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO),
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY),
                             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_GPEX))))
@@ -1258,7 +1258,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
 
     if (qemuAssignDeviceHostdevAlias(vm->def, &hostdev->info->alias, -1) < 0)
         goto error;
-    if (!(pciaddrs = qemuDomainPCIAddrSetCreateFromDomain(vm->def,
+    if (!(pciaddrs = virDomainPCIAddrSetCreateFromDomain(vm->def,
                         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO),
                         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY),
                         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_GPEX))))
@@ -1507,7 +1507,7 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainDefPtr def,
 
     } else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
                chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI) {
-        if (!(pciaddrs = qemuDomainPCIAddrSetCreateFromDomain(def,
+        if (!(pciaddrs = virDomainPCIAddrSetCreateFromDomain(def,
                              virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO),
                              virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY),
                              virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_GPEX))))
@@ -1638,7 +1638,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
 
     if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
         rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
-        if (!(pciaddrs = qemuDomainPCIAddrSetCreateFromDomain(vm->def,
+        if (!(pciaddrs = virDomainPCIAddrSetCreateFromDomain(vm->def,
                              virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO),
                              virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY),
                              virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_GPEX))))
-- 
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]