提交 fcdf87d3 编写于 作者: L Laine Stump

conf: simplify logic when checking for AUTOASSIGN PCI addresses

Old behavior: If the address was manually provided by config, copy
device AUTOASSIGN flag into the bus flag, and then later on in the
function *always* check for a match of the flags (which will always
match if the address came from config, since we just copied it).

New behavior: Don't mess with the bus flags - just directly check if
the AUTOASSIGN flag matches in bus and dev, but only make the check if
the address didn't come from config (i.e. it was auto-assigned by
libvirt).
Signed-off-by: NLaine Stump <laine@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 7c98f5e3
...@@ -358,18 +358,22 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr, ...@@ -358,18 +358,22 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
*/ */
if (busFlags & VIR_PCI_CONNECT_TYPES_ENDPOINT) if (busFlags & VIR_PCI_CONNECT_TYPES_ENDPOINT)
busFlags |= VIR_PCI_CONNECT_TYPES_ENDPOINT; busFlags |= VIR_PCI_CONNECT_TYPES_ENDPOINT;
/* Also allow manual specification of bus to override
* libvirt's assumptions about whether or not hotplug
* capability will be required.
*/
if (devFlags & VIR_PCI_CONNECT_AUTOASSIGN)
busFlags |= VIR_PCI_CONNECT_AUTOASSIGN;
/* if the device is a pci-bridge, allow manually /* if the device is a pci-bridge, allow manually
* assigning to any bus that would also accept a * assigning to any bus that would also accept a
* standard PCI device. * standard PCI device.
*/ */
if (devFlags & VIR_PCI_CONNECT_TYPE_PCI_BRIDGE) if (devFlags & VIR_PCI_CONNECT_TYPE_PCI_BRIDGE)
devFlags |= VIR_PCI_CONNECT_TYPE_PCI_DEVICE; devFlags |= VIR_PCI_CONNECT_TYPE_PCI_DEVICE;
} else if ((devFlags & VIR_PCI_CONNECT_AUTOASSIGN) &&
!(busFlags & VIR_PCI_CONNECT_AUTOASSIGN)) {
if (reportError) {
virReportError(errType,
_("The device at PCI address %s was auto-assigned "
"this address, but the PCI controller "
"with index='%d' doesn't allow auto-assignment"),
addrStr, addr->bus);
}
return false;
} }
/* If this bus doesn't allow the type of connection (PCI /* If this bus doesn't allow the type of connection (PCI
...@@ -419,17 +423,6 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr, ...@@ -419,17 +423,6 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
addrStr, addr->bus, connectStr); addrStr, addr->bus, connectStr);
return false; return false;
} }
if ((devFlags & VIR_PCI_CONNECT_AUTOASSIGN) &&
!(busFlags & VIR_PCI_CONNECT_AUTOASSIGN)) {
if (reportError) {
virReportError(errType,
_("The device at PCI address %s requires "
"hotplug capability, but the PCI controller "
"with index='%d' doesn't support hotplug"),
addrStr, addr->bus);
}
return false;
}
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册