]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Only detect PCI Express devices as root in udev nodedev driver
authorJán Tomko <jtomko@redhat.com>
Mon, 30 Jun 2014 13:18:23 +0000 (15:18 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 1 Jul 2014 14:30:32 +0000 (16:30 +0200)
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

index 50bb952bcb64cde3a4f342bdb5be365c7c7209a0..8a2e5fffa3390076f1f40d0eb66edc665517df52 100644 (file)
@@ -429,6 +429,7 @@ static int udevProcessPCI(struct udev_device *device,
     virPCIDeviceAddress addr;
     virPCIEDeviceInfoPtr pci_express = NULL;
     virPCIDevicePtr pciDev = NULL;
+    udevPrivate *priv = driverState->privateData;
     int tmpGroup, ret = -1;
     char *p;
     int rc;
@@ -544,7 +545,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;