From 79901543b91073bf01d1f2d094137cb1821cc6f8 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Sat, 22 Oct 2016 12:35:38 -0400 Subject: [PATCH] conf: fix fromConfig argument to virDomainPCIAddressReserveAddr() 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 | 2 +- src/qemu/qemu_domain_address.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index e0b19a238a..bf201e7a4d 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -591,7 +591,7 @@ virDomainPCIAddressReserveSlot(virDomainPCIAddressSetPtr addrs, virPCIDeviceAddressPtr addr, virDomainPCIConnectFlags flags) { - return virDomainPCIAddressReserveAddr(addrs, addr, flags, false); + return virDomainPCIAddressReserveAddr(addrs, addr, flags, true); } int diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index d77a792d7c..69a64fdac5 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -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; } -- GitLab