]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Forbid assigning a pci-bridge to a guest
authorShivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Mon, 23 Jan 2017 13:36:29 +0000 (19:06 +0530)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 23 Jan 2017 16:23:03 +0000 (17:23 +0100)
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>
src/util/virhostdev.c

index 0673afb7b6d4d33d3c6b60f0b0ccabafdda08770..86ca8e0473fa52370bc943fc7d58cf3228354478 100644 (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,