]> xenbits.xensource.com Git - libvirt.git/commitdiff
node_device: udev driver does not handle SR-IOV devices
authorChris Wright <chrisw@redhat.com>
Fri, 24 Dec 2010 18:41:52 +0000 (10:41 -0800)
committerEric Blake <eblake@redhat.com>
Mon, 3 Jan 2011 16:05:10 +0000 (09:05 -0700)
The udev driver does not update a PCI device with its SR-IOV capabilities,
when applicable, the way the hal driver does.  As a result, dumping the
device's XML will not include the relevant physical or virtual function
information.

With this patch, the XML is correct:

# virsh nodedev-dumpxml pci_0000_09_00_0
<device>
  <name>pci_0000_09_00_0</name>
  <parent>pci_0000_00_1c_0</parent>
  <driver>
    <name>vxge</name>
  </driver>
  <capability type='pci'>
    <domain>0</domain>
    <bus>9</bus>
    <slot>0</slot>
    <function>0</function>
    <product id='0x5833'>X3100 Series 10 Gigabit Ethernet PCIe</product>
    <vendor id='0x17d5'>Neterion Inc.</vendor>
    <capability type='virt_functions'>
      <address domain='0x0000' bus='0x0a' slot='0x00' function='0x1'/>
      <address domain='0x0000' bus='0x0a' slot='0x00' function='0x2'/>
      <address domain='0x0000' bus='0x0a' slot='0x00' function='0x3'/>
    </capability>
  </capability>
</device>

# virsh nodedev-dumpxml pci_0000_0a_00_1
<device>
  <name>pci_0000_0a_00_1</name>
  <parent>pci_0000_00_1c_0</parent>
  <driver>
    <name>vxge</name>
  </driver>
  <capability type='pci'>
    <domain>0</domain>
    <bus>10</bus>
    <slot>0</slot>
    <function>1</function>
    <product id='0x5833'>X3100 Series 10 Gigabit Ethernet PCIe</product>
    <vendor id='0x17d5'>Neterion Inc.</vendor>
    <capability type='phys_function'>
      <address domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
    </capability>
  </capability>
</device>

Cc: Dave Allan <dallan@redhat.com>
Signed-off-by: Chris Wright <chrisw@redhat.com>
src/node_device/node_device_udev.c

index 02e44a1cdeda46c1663a6722b6cce4fdaddc8596..379af86f56a9062f68c606fa121f104a99acd1ef 100644 (file)
@@ -419,11 +419,11 @@ out:
 static int udevProcessPCI(struct udev_device *device,
                           virNodeDeviceDefPtr def)
 {
-    const char *devpath = NULL;
+    const char *syspath = NULL;
     union _virNodeDevCapData *data = &def->caps->data;
     int ret = -1;
 
-    devpath = udev_device_get_devpath(device);
+    syspath = udev_device_get_syspath(device);
 
     if (udevGetUintProperty(device,
                             "PCI_CLASS",
@@ -432,7 +432,7 @@ static int udevProcessPCI(struct udev_device *device,
         goto out;
     }
 
-    char *p = strrchr(devpath, '/');
+    char *p = strrchr(syspath, '/');
 
     if ((p == NULL) || (udevStrToLong_ui(p+1,
                                          &p,
@@ -487,6 +487,9 @@ static int udevProcessPCI(struct udev_device *device,
         goto out;
     }
 
+    get_physical_function(syspath, data);
+    get_virtual_functions(syspath, data);
+
     ret = 0;
 
 out: