]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: fix fromConfig argument to virDomainPCIAddressReserveAddr()
authorLaine Stump <laine@laine.org>
Sat, 22 Oct 2016 16:35:38 +0000 (12:35 -0400)
committerLaine Stump <laine@laine.org>
Wed, 11 Jan 2017 09:47:12 +0000 (04:47 -0500)
Although setting virDomainPCIAddressReserveAddr()'s fromConfig=true is
correct when a PCI addres is coming from a domain's config, the *true*
purpose of the fromConfig argument is to lower restrictions on what
kind of device can plug into what kind of controller - if fromConfig
is true, then a PCIE_DEVICE can plug into a slot that is marked as
only compatible with PCI_DEVICE (and vice versa), and the HOTPLUG flag
is ignored.

For a long time there have been several calls to
virDomainPCIAddressReserveAddr() that have fromConfig incorrectly set
to false - it's correct that the addresses aren't coming from user
config, but they are coming from hardcoded exceptions in libvirt that
should, if anything, pay *even less* attention to following the
pciConnectFlags (under the assumption that the libvirt programmer knew
what they were doing).

See commit b87703cf7 for an example of an actual bug caused by the
incorrect setting of the "fromConfig" argument to
virDomainPCIAddressReserveAddr(). Although they haven't resulted in
any reported bugs, this patch corrects all the other incorrect
settings of fromConfig in calls to virDomainPCIAddressReserveAddr().

src/conf/domain_addr.c
src/qemu/qemu_domain_address.c

index e0b19a238af0779d6e28d2588f4fb5cc38bac994..bf201e7a4d8f0166ab2b403e308f04bc99e60ca9 100644 (file)
@@ -591,7 +591,7 @@ virDomainPCIAddressReserveSlot(virDomainPCIAddressSetPtr addrs,
                                virPCIDeviceAddressPtr addr,
                                virDomainPCIConnectFlags flags)
 {
-    return virDomainPCIAddressReserveAddr(addrs, addr, flags, false);
+    return virDomainPCIAddressReserveAddr(addrs, addr, flags, true);
 }
 
 int
index d77a792d7c3e7af4f760c3110d7d430f3f6817ad..69a64fdac54a870f0c7e7efd82e43a1dad5b9d1a 100644 (file)
@@ -1348,7 +1348,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
                 tmp_addr.slot = 0x1E;
                 if (!virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
                     if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr,
-                                                       flags, false) < 0)
+                                                       flags, true) < 0)
                         goto cleanup;
                     cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
                     cont->info.addr.pci.domain = 0;
@@ -1372,12 +1372,12 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
         tmp_addr.function = 0;
         tmp_addr.multi = VIR_TRISTATE_SWITCH_ON;
         if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr,
-                                           flags, false) < 0)
+                                           flags, true) < 0)
            goto cleanup;
         tmp_addr.function = 3;
         tmp_addr.multi = VIR_TRISTATE_SWITCH_ABSENT;
         if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr,
-                                           flags, false) < 0)
+                                           flags, true) < 0)
            goto cleanup;
     }