Blame SOURCES/libvirt-conf-allow-hotplugging-legacy-PCI-device-to-manually-addressed-PCIe-slot.patch

6ae9ed
From 58593f4340d766fb7639de542f3b21463d5b98ef Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <58593f4340d766fb7639de542f3b21463d5b98ef@dist-git>
6ae9ed
From: Laine Stump <laine@laine.org>
6ae9ed
Date: Mon, 12 Sep 2016 16:25:25 -0400
6ae9ed
Subject: [PATCH] conf: allow hotplugging "legacy PCI" device to manually
6ae9ed
 addressed PCIe slot
6ae9ed
6ae9ed
In a full domain config, libvirt allows overriding the normal PCI
6ae9ed
vs. PCI Express rules when a device address is explicitly provided
6ae9ed
(so, e.g., you can force a legacy PCI device to plug into a PCIe port,
6ae9ed
although libvirt would never do that on its own). However, due to a
6ae9ed
bug libvirt doesn't give this same leeway when hotplugging devices. On
6ae9ed
top of that, current libvirt assumes that *all* devices are legacy
6ae9ed
PCI. The result of all this is that it's impossible to hotplug a
6ae9ed
device into a PCIe port, even if you manually add the PCI address.
6ae9ed
6ae9ed
This can all be traced to the function
6ae9ed
virDomainPCIAddressEnsureAddr(), and the fact that it calls
6ae9ed
virDomainPCIaddressReserveSlot() for manually set addresses, and that
6ae9ed
function hardcodes the argument "fromConfig" to false (meaning "this
6ae9ed
address was auto-assigned, so it should be subject to stricter
6ae9ed
validation").
6ae9ed
6ae9ed
Since virDomainPCIAddressReserveSlot() is just a one line simple
6ae9ed
wrapper around virDomainPCIAddressReserveAddr() (adding in a hardcoded
6ae9ed
reserveEntireSlot = true and fromConfig = false), all that's needed to
6ae9ed
solve the problem with no unwanted side effects is to replace that
6ae9ed
call for virDomainPCIAddressReserveSlot() with a direct call to
6ae9ed
virDomainPCIAddressReserveAddr(), but with reserveEntireSlot = true,
6ae9ed
fromConfig = true. That's what this patch does.
6ae9ed
6ae9ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1337490
6ae9ed
(cherry picked from commit b87703cf79559157404667628802d7fe8f9f19a6)
6ae9ed
---
6ae9ed
 src/conf/domain_addr.c | 3 ++-
6ae9ed
 1 file changed, 2 insertions(+), 1 deletion(-)
6ae9ed
6ae9ed
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
6ae9ed
index 7f4f4d8..cad1c27 100644
6ae9ed
--- a/src/conf/domain_addr.c
6ae9ed
+++ b/src/conf/domain_addr.c
6ae9ed
@@ -507,7 +507,8 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
6ae9ed
                                          addrStr, flags, true))
6ae9ed
             goto cleanup;
6ae9ed
 
6ae9ed
-        ret = virDomainPCIAddressReserveSlot(addrs, &dev->addr.pci, flags);
6ae9ed
+        ret = virDomainPCIAddressReserveAddr(addrs, &dev->addr.pci, flags,
6ae9ed
+                                             true, true);
6ae9ed
     } else {
6ae9ed
         ret = virDomainPCIAddressReserveNextSlot(addrs, dev, flags);
6ae9ed
     }
6ae9ed
-- 
6ae9ed
2.10.0
6ae9ed