On Mon, 2016-11-07 at 14:50 -0500, Laine Stump wrote:
This patch cleans up the connect flags for certain types/models of
devices that aren't PCI to return 0. In the future that may be used as
an indicator to the caller about whether or not a device needs a PCI
address. For now it's just ignored, except for in
virDomainPCIAddressEnsureAddr() - called during device hotplug - (and
in some cases actually needs to be re-set to PCI|HOTPLUGGABLE just in
case someone (in some old config) has manually set a PCI address for a
device that isn't PCI.
---
src/conf/domain_addr.c | 6 +++++
src/qemu/qemu_domain_address.c | 54 +++++++++++++++++++++++++-----------------
2 files changed, 38 insertions(+), 22 deletions(-)
[...]
@@ -817,6 +806,27 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def
ATTRIBUTE_UNUSED,
return 0;
}
+ /* If we get to here, the device has a PCI address assigned in the
This line is not aligned properly.
+ * config and we should mark it as in-use. But if the
+ * pciConnectFlags are 0, then this device shouldn't have a PCI
+ * address associated with it. *BUT* since there are cases in the
+ * past where we've apparently allowed that, we need to pretend
+ * for now that it's okay, otherwise an existing domain could
+ * "disappear" from the list of domains due to a parse failure. We
+ * can fix this by just forcing the pciConnectFlags to be
+ * PCI_DEVICE (and then relying on validation functions to report
+ * inappropriate address types.
+ */
+ if (info->pciConnectFlags == 0) {
You can turn this into
if (!info->pciConnectFlags) {
+ char *addrStr =
virDomainPCIAddressAsString(&info->addr.pci);
+
+ VIR_WARN("qemuDomainDeviceCalculatePCIConnectFlags() thinks that the
"
+ "device with PCI address %s should not have a PCI address",
+ addrStr ? addrStr : "(unknown)");
+ VIR_FREE(addrStr);
Please add an empty line here.
+ info->pciConnectFlags = VIR_PCI_CONNECT_TYPE_PCI_DEVICE;
+ }
+
/* Ignore implicit controllers on slot 0:0:1.0:
* implicit IDE controller on 0:0:1.1 (no qemu command line)
* implicit USB controller on 0:0:1.2 (-usb)
ACK
--
Andrea Bolognani / Red Hat / Virtualization