util: Forbid assigning a pci-bridge to a guest

Non-endpoint devices like pci-bridges cannot be assigned to guests.
Prevent such attempts.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
This commit is contained in:
Shivaprasad G Bhat 2017-01-23 19:06:29 +05:30 committed by Martin Kletzander
parent 5f580d82f3
commit bec9b9b01a

View File

@ -532,6 +532,17 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr,
bool strict_acs_check = !!(flags & VIR_HOSTDEV_STRICT_ACS_CHECK);
bool usesVFIO = (virPCIDeviceGetStubDriver(pci) == VIR_PCI_STUB_DRIVER_VFIO);
struct virHostdevIsPCINodeDeviceUsedData data = { mgr, dom_name, usesVFIO };
int hdrType = -1;
if (virPCIGetHeaderType(pci, &hdrType) < 0)
goto cleanup;
if (hdrType != VIR_PCI_HEADER_ENDPOINT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Non-endpoint PCI devices cannot be assigned "
"to guests"));
goto cleanup;
}
if (!usesVFIO && !virPCIDeviceIsAssignable(pci, strict_acs_check)) {
virReportError(VIR_ERR_OPERATION_INVALID,