[PATCH v6 05/17] qemu: set pciConnectFlags to 0 instead of PCI|HOTPLUGGABLE if device isn't PCI

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

 



This patch cleans up the connect flags for certain types/models of
devices that aren't PCI to return 0. In the future that may be used as
an indicator to the caller about whether or not a device needs a PCI
address. For now it's just ignored, except for in
virDomainPCIAddressEnsureAddr() - called during device hotplug - (and
in some cases actually needs to be re-set to PCI|HOTPLUGGABLE just in
case someone (in some old config) has manually set a PCI address for a
device that isn't PCI.
---
 src/conf/domain_addr.c         |  6 +++++
 src/qemu/qemu_domain_address.c | 54 +++++++++++++++++++++++++-----------------
 2 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 0346471e..d3a2f6f 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -493,6 +493,12 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
     int ret = -1;
     char *addrStr = NULL;
 
+    /* if flags is 0, the particular model of this device on this
+     * machinetype doesn't need a PCI address, so we're done.
+     */
+    if (!flags)
+       return 0;
+
     if (!(addrStr = virDomainPCIAddressAsString(&dev->addr.pci)))
         goto cleanup;
 
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 85e9521..657dc62 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -467,8 +467,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
             case VIR_DOMAIN_CONTROLLER_MODEL_USB_QUSB2: /* xen only */
             case VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE:
             case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST:
-                /* should be 0 */
-                return pciFlags;
+                return 0;
             }
 
         case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
@@ -497,8 +496,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
          */
         if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV ||
             STREQ(net->model, "usb-net")) {
-            /* should be 0 */
-            return pciFlags;
+            return 0;
         }
         return pciFlags;
     }
@@ -515,8 +513,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
         case VIR_DOMAIN_SOUND_MODEL_PCSPK:
         case VIR_DOMAIN_SOUND_MODEL_USB:
         case VIR_DOMAIN_SOUND_MODEL_LAST:
-            /* should be 0 */
-            return pciFlags;
+            return 0;
         }
 
     case VIR_DOMAIN_DEVICE_DISK:
@@ -533,8 +530,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
         case VIR_DOMAIN_DISK_BUS_SATA:
         case VIR_DOMAIN_DISK_BUS_SD:
         case VIR_DOMAIN_DISK_BUS_LAST:
-            /* should be 0 */
-            return pciFlags;
+            return 0;
         }
 
     case VIR_DOMAIN_DEVICE_HOSTDEV:
@@ -548,8 +544,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
         case VIR_DOMAIN_MEMBALLOON_MODEL_XEN:
         case VIR_DOMAIN_MEMBALLOON_MODEL_NONE:
         case VIR_DOMAIN_MEMBALLOON_MODEL_LAST:
-            /* should be 0 (not PCI) */
-            return pciFlags;
+            return 0;
         }
 
     case VIR_DOMAIN_DEVICE_RNG:
@@ -558,8 +553,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
             return pciFlags;
 
         case VIR_DOMAIN_RNG_MODEL_LAST:
-            /* should be 0 */
-            return pciFlags;
+            return 0;
         }
 
     case VIR_DOMAIN_DEVICE_WATCHDOG:
@@ -571,8 +565,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
         case VIR_DOMAIN_WATCHDOG_MODEL_IB700:
         case VIR_DOMAIN_WATCHDOG_MODEL_DIAG288:
         case VIR_DOMAIN_WATCHDOG_MODEL_LAST:
-            /* should be 0 */
-            return pciFlags;
+            return 0;
         }
 
     case VIR_DOMAIN_DEVICE_VIDEO:
@@ -588,8 +581,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
             return pciFlags;
 
         case VIR_DOMAIN_VIDEO_TYPE_LAST:
-            /* should be 0 */
-            return pciFlags;
+            return 0;
         }
 
 
@@ -606,8 +598,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
         case VIR_DOMAIN_INPUT_BUS_XEN:
         case VIR_DOMAIN_INPUT_BUS_PARALLELS:
         case VIR_DOMAIN_INPUT_BUS_LAST:
-            /* should be 0 */
-            return pciFlags;
+            return 0;
         }
 
     case VIR_DOMAIN_DEVICE_CHR:
@@ -618,8 +609,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB:
         case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST:
-            /* should be 0 */
-            return pciFlags;
+            return 0;
         }
 
     /* These devices don't ever connect with PCI */
@@ -636,8 +626,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
     case VIR_DOMAIN_DEVICE_IOMMU:
     case VIR_DOMAIN_DEVICE_LAST:
     case VIR_DOMAIN_DEVICE_NONE:
-        /* should be 0 */
-        return pciFlags;
+        return 0;
     }
 
     /* We can never get here, because all cases are covered in the
@@ -817,6 +806,27 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
         return 0;
     }
 
+   /* If we get to here, the device has a PCI address assigned in the
+     * config and we should mark it as in-use. But if the
+     * pciConnectFlags are 0, then this device shouldn't have a PCI
+     * address associated with it. *BUT* since there are cases in the
+     * past where we've apparently allowed that, we need to pretend
+     * for now that it's okay, otherwise an existing domain could
+     * "disappear" from the list of domains due to a parse failure. We
+     * can fix this by just forcing the pciConnectFlags to be
+     * PCI_DEVICE (and then relying on validation functions to report
+     * inappropriate address types.
+     */
+    if (info->pciConnectFlags == 0) {
+        char *addrStr = virDomainPCIAddressAsString(&info->addr.pci);
+
+        VIR_WARN("qemuDomainDeviceCalculatePCIConnectFlags() thinks that the "
+                 "device with PCI address %s should not have a PCI address",
+                 addrStr ? addrStr : "(unknown)");
+        VIR_FREE(addrStr);
+        info->pciConnectFlags = VIR_PCI_CONNECT_TYPE_PCI_DEVICE;
+    }
+
     /* Ignore implicit controllers on slot 0:0:1.0:
      * implicit IDE controller on 0:0:1.1 (no qemu command line)
      * implicit USB controller on 0:0:1.2 (-usb)
-- 
2.7.4

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