render / rpms / libvirt

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