[PATCH 2/4] Only detect PCI Express devices as root in udev nodedev driver

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

 



This stops the error message spam when running unprivileged
libvirtd:
2014-06-30 12:38:47.990+0000: 631: error : virPCIDeviceConfigOpen:300 :
Failed to open config space file
'/sys/bus/pci/devices/0000:00:00.0/config': Permission denied

Reported by Daniel Berrange:
https://www.redhat.com/archives/libvir-list/2014-June/msg01082.html
---
 src/node_device/node_device_udev.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 50bb952..fe3dd26 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -429,10 +429,13 @@ static int udevProcessPCI(struct udev_device *device,
     virPCIDeviceAddress addr;
     virPCIEDeviceInfoPtr pci_express = NULL;
     virPCIDevicePtr pciDev = NULL;
+    udevPrivate *priv = NULL;
     int tmpGroup, ret = -1;
     char *p;
     int rc;
 
+    priv = driverState->privateData;
+
     syspath = udev_device_get_syspath(device);
 
     if (udevGetUintProperty(device,
@@ -544,7 +547,8 @@ static int udevProcessPCI(struct udev_device *device,
                                    data->pci_dev.function)))
         goto out;
 
-    if (virPCIDeviceIsPCIExpress(pciDev) > 0) {
+    /* We need to be root to read PCI device configs */
+    if (priv->privileged && virPCIDeviceIsPCIExpress(pciDev) > 0) {
         if (VIR_ALLOC(pci_express) < 0)
             goto out;
 
-- 
1.8.5.5

--
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]