]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: make virPCIDeviceIsPCIExpress() more intelligent
authorLaine Stump <laine@redhat.com>
Tue, 8 Dec 2020 19:34:19 +0000 (14:34 -0500)
committerLaine Stump <laine@redhat.com>
Sat, 12 Dec 2020 23:36:48 +0000 (18:36 -0500)
commitc00b6b1ae3bea8b5e6407b0991f0b1f16f129645
tree3d5b44a343798d0f89e498f69642b3b73d7baf1e
parent4b8245653d47dd0f875e3693db3d781f113a095c
util: make virPCIDeviceIsPCIExpress() more intelligent

Until now there has been an extra bit of code in
qemuDomainDeviceCalculatePCIConnectFlag() (one of the two callers of
virPCIDeviceIsPCIExpress()) that tries to determine if a device is
PCIe by looking at the *length* of its sysfs config file; it only does
this when libvirt is running as a non-root process.

This patch takes advantage of our newfound ability to tell the
difference between "I read a 0 from the device PCI config file" and "I
couldn't read the PCI Express Capabilities because I don't have
sufficient permission" to put the file length check down in
virPCIDeviceIsPCIExpress(), and do that check any time we fail while
reading the config file (not only when the process is non-root).

Fixes: https://bugzilla.redhat.com/1901685
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virpci.c