Blame SOURCES/libvirt-conf-simplify-logic-when-checking-for-AUTOASSIGN-PCI-addresses.patch

a41c76
From f52197675b2babfafb1b89058e3fd01decebd8ab Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <f52197675b2babfafb1b89058e3fd01decebd8ab@dist-git>
a41c76
From: Laine Stump <laine@redhat.com>
a41c76
Date: Sun, 26 Apr 2020 13:04:12 -0400
a41c76
Subject: [PATCH] conf: simplify logic when checking for AUTOASSIGN PCI
a41c76
 addresses
a41c76
a41c76
Old behavior: If the address was manually provided by config, copy
a41c76
device AUTOASSIGN flag into the bus flag, and then later on in the
a41c76
function *always* check for a match of the flags (which will always
a41c76
match if the address came from config, since we just copied it).
a41c76
a41c76
New behavior: Don't mess with the bus flags - just directly check if
a41c76
the AUTOASSIGN flag matches in bus and dev, but only make the check if
a41c76
the address didn't come from config (i.e. it was auto-assigned by
a41c76
libvirt).
a41c76
a41c76
Signed-off-by: Laine Stump <laine@redhat.com>
a41c76
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
(cherry picked from commit fcdf87d3ef14de9dfb0acaf4b4445e1580dfc629)
a41c76
a41c76
https://bugzilla.redhat.com/1802592
a41c76
Signed-off-by: Laine Stump <laine@redhat.com>
a41c76
Message-Id: <20200426170415.18328-10-laine@redhat.com>
a41c76
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
---
a41c76
 src/conf/domain_addr.c | 27 ++++++++++-----------------
a41c76
 1 file changed, 10 insertions(+), 17 deletions(-)
a41c76
a41c76
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
a41c76
index 53be6cd34b..05f036e3e6 100644
a41c76
--- a/src/conf/domain_addr.c
a41c76
+++ b/src/conf/domain_addr.c
a41c76
@@ -358,18 +358,22 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
a41c76
          */
a41c76
         if (busFlags & VIR_PCI_CONNECT_TYPES_ENDPOINT)
a41c76
             busFlags |= VIR_PCI_CONNECT_TYPES_ENDPOINT;
a41c76
-        /* Also allow manual specification of bus to override
a41c76
-         * libvirt's assumptions about whether or not hotplug
a41c76
-         * capability will be required.
a41c76
-         */
a41c76
-        if (devFlags & VIR_PCI_CONNECT_AUTOASSIGN)
a41c76
-            busFlags |= VIR_PCI_CONNECT_AUTOASSIGN;
a41c76
         /* if the device is a pci-bridge, allow manually
a41c76
          * assigning to any bus that would also accept a
a41c76
          * standard PCI device.
a41c76
          */
a41c76
         if (devFlags & VIR_PCI_CONNECT_TYPE_PCI_BRIDGE)
a41c76
             devFlags |= VIR_PCI_CONNECT_TYPE_PCI_DEVICE;
a41c76
+    } else if ((devFlags & VIR_PCI_CONNECT_AUTOASSIGN) &&
a41c76
+               !(busFlags & VIR_PCI_CONNECT_AUTOASSIGN)) {
a41c76
+        if (reportError) {
a41c76
+            virReportError(errType,
a41c76
+                           _("The device at PCI address %s was auto-assigned "
a41c76
+                             "this address, but the PCI controller "
a41c76
+                             "with index='%d' doesn't allow auto-assignment"),
a41c76
+                           addrStr, addr->bus);
a41c76
+        }
a41c76
+        return false;
a41c76
     }
a41c76
 
a41c76
     /* If this bus doesn't allow the type of connection (PCI
a41c76
@@ -419,17 +423,6 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
a41c76
                        addrStr, addr->bus, connectStr);
a41c76
         return false;
a41c76
     }
a41c76
-    if ((devFlags & VIR_PCI_CONNECT_AUTOASSIGN) &&
a41c76
-        !(busFlags & VIR_PCI_CONNECT_AUTOASSIGN)) {
a41c76
-        if (reportError) {
a41c76
-            virReportError(errType,
a41c76
-                           _("The device at PCI address %s requires "
a41c76
-                             "hotplug capability, but the PCI controller "
a41c76
-                             "with index='%d' doesn't support hotplug"),
a41c76
-                           addrStr, addr->bus);
a41c76
-        }
a41c76
-        return false;
a41c76
-    }
a41c76
     return true;
a41c76
 }
a41c76
 
a41c76
-- 
a41c76
2.26.2
a41c76