Re: [PATCH v2 1/2] util: virhostdev: disallow assigning a pci-bridge to a guest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 23, 2017 at 07:06:29PM +0530, Shivaprasad G Bhat wrote:
Non-endpoint devices like pci-bridges cannot be passedthrough to guests.

"disallow" is a mouthful, I would also use "assigned" instead of
"passedthrough".

Prevent such attempts.

Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx>
---
src/util/virhostdev.c |   10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 0673afb..b23fe1f 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -532,6 +532,16 @@ 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", _("PCI bridge devices "
+                           "cannot be assigned to guests"));

Actually, you should continue the string in the same column it was
started, just start the long strings on their own lines, it's more
readable.

FTFY, ACK and pushed.

I wanted you to make it part of virPCIDeviceIsAssignable(), but we use
it kind of weirdly, so I'll keep it as-is, Laine (Cc'd) will know more
about whether we want to move it there or not.  And we can do that later.

+            goto cleanup;
+        }

        if (!usesVFIO && !virPCIDeviceIsAssignable(pci, strict_acs_check)) {
            virReportError(VIR_ERR_OPERATION_INVALID,

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux