*/
static virDomainPCIConnectFlags
qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
- virQEMUDriverPtr driver,
virDomainPCIConnectFlags pcieFlags,
virDomainPCIConnectFlags virtioFlags)
{
case VIR_DOMAIN_DEVICE_HOSTDEV: {
virDomainHostdevDefPtr hostdev = dev->data.hostdev;
- bool isExpress = false;
g_autoptr(virPCIDevice) pciDev = NULL;
virPCIDeviceAddressPtr hostAddr = &hostdev->source.subsys.u.pci.addr;
return pcieFlags;
}
- if (!driver->privileged) {
- /* unprivileged libvirtd is unable to read *all* of a
- * device's PCI config (it can only read the first 64
- * bytes, which isn't enough for the check that's done
- * in virPCIDeviceIsPCIExpress()), so instead of
- * trying and failing, we make an educated guess based
- * on the length of the device's config file - if it
- * is 256 bytes, then it is definitely a legacy PCI
- * device. If it's larger than that, then it is
- * *probably PCIe (although it could be PCI-x, but
- * those are extremely rare). If the config file can't
- * be found (in which case the "length" will be -1),
- * then we blindly assume the most likely outcome -
- * PCIe.
- */
- off_t configLen
- = virFileLength(virPCIDeviceGetConfigPath(pciDev), -1);
-
- if (configLen == 256)
- return pciFlags;
-
- return pcieFlags;
- }
-
- /* If we are running with privileges, we can examine the
- * PCI config contents with virPCIDeviceIsPCIExpress() for
- * a definitive answer.
- */
- isExpress = virPCIDeviceIsPCIExpress(pciDev);
-
- if (isExpress)
+ if (virPCIDeviceIsPCIExpress(pciDev))
return pcieFlags;
return pciFlags;
qemuDomainFillDevicePCIConnectFlagsIterData *data = opaque;
info->pciConnectFlags
- = qemuDomainDeviceCalculatePCIConnectFlags(dev, data->driver,
+ = qemuDomainDeviceCalculatePCIConnectFlags(dev,
data->pcieFlags,
data->virtioFlags);
return 0;
qemuDomainFillDevicePCIConnectFlagsIterInit(def, qemuCaps, driver, &data);
info->pciConnectFlags
- = qemuDomainDeviceCalculatePCIConnectFlags(dev, data.driver,
+ = qemuDomainDeviceCalculatePCIConnectFlags(dev,
data.pcieFlags,
data.virtioFlags);
}