[libvirt] [RESEND] pci: add support for VMD domains

Jon Derrick jonathan.derrick at intel.com
Wed Aug 9 16:46:10 UTC 2017

Hi Laine,

Here's an alternate patch which is probably a lot less potentially
harmful. Please let me know what you think:

commit 931ac8a0a32c3399c92efd18e4478342aedec9e1
Author: Jon Derrick <jonathan.derrick at intel.com>
Date:   Wed Aug 9 13:10:01 2017 -0600

    pci: Restrict devices to 16-bit domains

    Most pci devices are limited to 16-bit domains, but VMD uses 32-bit
    domains for child devices. In the current VMD model, child devices
    cannot be assigned to VMs. So restrict the domains to 16-bits rather
    than allowing virpci to attempt to enumerate the devices and failing
    with the following error message:

    internal error: dev->name buffer overflow: 10000:00:00.0

    Signed-off-by: Jon Derrick <jonathan.derrick at intel.com>

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 2c1b758..7aaaddd 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1769,6 +1769,12 @@ virPCIDeviceNew(unsigned int domain,
     dev->address.slot = slot;
     dev->address.function = function;

+    /* This is already implied by the following snprintf, but restrict
+     * to 16-bit domains to prevent the error message
+     */
+    if (domain > 0xffff)
+        return NULL;
     if (snprintf(dev->name, sizeof(dev->name), "%.4x:%.2x:%.2x.%.1x",
                  domain, bus, slot, function) >= sizeof(dev->name)) {

More information about the libvir-list mailing list