]> xenbits.xensource.com Git - libvirt.git/commitdiff
virpcimock: Mock the SRIOV Virtual functions
authorShivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Thu, 29 Aug 2019 19:18:59 +0000 (16:18 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 9 Sep 2019 14:44:24 +0000 (16:44 +0200)
The softlink to physfn is the way to know if the device is
VF or not. So, the patch softlinks 'physfn' to the parent function.
The multifunction PCI devices dont have 'physfn' softlinks.

The patch adds few Virtual functions to the mock environment and
changes the existing VFIO test xmls using the VFs to use the newly
added VFs for their use case.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
13 files changed:
tests/qemuxml2argvdata/hostdev-vfio-multidomain.args
tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml
tests/qemuxml2argvdata/hostdev-vfio.args
tests/qemuxml2argvdata/hostdev-vfio.xml
tests/qemuxml2argvdata/net-hostdev-fail.xml
tests/qemuxml2argvdata/net-hostdev-vfio.args
tests/qemuxml2argvdata/net-hostdev-vfio.xml
tests/qemuxml2xmloutdata/hostdev-vfio.xml
tests/qemuxml2xmloutdata/net-hostdev-vfio.xml
tests/virpcimock.c
tests/virpcitestdata/0000-06-12.0.config [new file with mode: 0644]
tests/virpcitestdata/0000-06-12.1.config [new file with mode: 0644]
tests/virpcitestdata/0000-06-12.2.config [new file with mode: 0644]

index d098bff356963a4c9011044afef8e7002eab8e0a..959d2a888880a355df42eb52c00e6e76746f3125 100644 (file)
@@ -27,5 +27,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--device vfio-pci,host=55aa:20:0f.3,id=hostdev0,bus=pci.0,addr=0x3 \
+-device vfio-pci,host=0021:de:1f.1,id=hostdev0,bus=pci.0,addr=0x3 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
index 832458125b04ff804de1906372e5ac3a903c54c7..7c34b65c7f00da1ac3548004f44de6524bd73262 100644 (file)
@@ -25,7 +25,7 @@
     <hostdev mode='subsystem' type='pci' managed='yes'>
       <driver name='vfio'/>
       <source>
-        <address domain='0x55aa' bus='32' slot='15' function='3'/>
+        <address domain='0x0021' bus='222' slot='31' function='1'/>
       </source>
     </hostdev>
     <memballoon model='virtio'/>
index 79654f44bb1b161b9f1c53f62b4db7d53c375a09..f2025afcd473ff5674526c62d1eb58984e02fc07 100644 (file)
@@ -27,5 +27,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--device vfio-pci,host=0000:06:12.5,id=hostdev0,bus=pci.0,addr=0x3 \
+-device vfio-pci,host=0000:06:12.1,id=hostdev0,bus=pci.0,addr=0x3 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
index 4d96b9f7322d40a633134f8cbdefbb58973ffa95..b2e6c62e7e368fdb4babe01f4892e628da073ce3 100644 (file)
@@ -27,7 +27,7 @@
     <hostdev mode='subsystem' type='pci' managed='yes'>
       <driver name='vfio'/>
       <source>
-        <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+        <address domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
       </source>
     </hostdev>
     <memballoon model='virtio'/>
index c815d68bd9362ca89f8b2cf1ca933362493b7857..50b102c658cf76fa9eb605c8bfe9723334dcd4c9 100644 (file)
@@ -25,7 +25,7 @@
     <interface type='hostdev' managed='yes'>
       <mac address='00:11:22:33:44:55'/>
       <source>
-        <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/>
+        <address type='pci' domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
       </source>
       <model type='virtio'/>
       <filterref filter='myfilter'/>
index aa9e91db825e694a7cdd40b0f8dccc880407441d..b0178a81bbf9fdab2e3de42789dbbc2c2447bfd9 100644 (file)
@@ -27,5 +27,5 @@ server,nowait \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
 -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
--device vfio-pci,host=0000:03:07.1,id=hostdev0,bus=pci.0,addr=0x3 \
+-device vfio-pci,host=0000:06:12.1,id=hostdev0,bus=pci.0,addr=0x3 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
index 24034cad8be488f65b4862f436ee122ca44c9601..aff681c0fbd7f06c4d037ac61272a1488fc17134 100644 (file)
@@ -26,7 +26,7 @@
       <mac address='00:11:22:33:44:55'/>
       <driver name='vfio'/>
       <source>
-        <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/>
+        <address type='pci' domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
       </source>
       <vlan>
         <tag id='42'/>
index 77bd62a1293b3e82699ee6fd5f43b70a3714e686..15a845f4d1b7d12c2c5370a4a8f0d92fd2c197b7 100644 (file)
@@ -32,7 +32,7 @@
     <hostdev mode='subsystem' type='pci' managed='yes'>
       <driver name='vfio'/>
       <source>
-        <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+        <address domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
       </source>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </hostdev>
index 0523cd8d3b786e6198908befb36f39b02bf64e5f..3f057a8249429ed1b0a1cce34523c624f73ca7cd 100644 (file)
@@ -31,7 +31,7 @@
       <mac address='00:11:22:33:44:55'/>
       <driver name='vfio'/>
       <source>
-        <address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/>
+        <address type='pci' domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
       </source>
       <vlan>
         <tag id='42'/>
index 9f6ca247376d3030df358a1211fbb693f3d338e4..47d151e0bc00406c47a785757da4fd480d8f85a2 100644 (file)
@@ -124,6 +124,7 @@ struct pciDevice {
     int device;
     int klass;
     int iommuGroup;
+    const char *physfn;
     struct pciDriver *driver;   /* Driver attached. NULL if attached to no driver */
 };
 
@@ -545,6 +546,15 @@ pci_device_new_from_stub(const struct pciDevice *data)
 
     make_symlink(devsympath, devid, tmp);
 
+    if (dev->physfn) {
+        if (snprintf(tmp, sizeof(tmp),
+                     "%s%s/devices/%s", fakerootdir,
+                     SYSFS_PCI_PREFIX, dev->physfn) < 0) {
+            ABORT("@tmp overflow");
+        }
+        make_symlink(devpath, "physfn", tmp);
+    }
+
     if (pci_device_autobind(dev) < 0)
         ABORT("Unable to bind: %s", devid);
 
@@ -1020,6 +1030,15 @@ init_env(void)
     MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047, 8);
     MAKE_PCI_DEVICE("0000:0a:02.0", 0x8286, 0x0048, 8);
     MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 0x0048, 8);
+    MAKE_PCI_DEVICE("0000:06:12.0", 0x8086, 0x0047, 9);
+    MAKE_PCI_DEVICE("0000:06:12.1", 0x8086, 0x0047, 10,
+                    .physfn = "0000:06:12.0"); /* Virtual Function */
+    MAKE_PCI_DEVICE("0000:06:12.2", 0x8086, 0x0047, 11,
+                    .physfn = "0000:06:12.0"); /* Virtual Function */
+    MAKE_PCI_DEVICE("0021:de:1f.0", 0x8086, 0x0047, 12);
+    MAKE_PCI_DEVICE("0021:de:1f.1", 0x8086, 0x0047, 13,
+                    .physfn = "0021:de:1f.0"); /* Virtual Function */
+
 }
 
 
diff --git a/tests/virpcitestdata/0000-06-12.0.config b/tests/virpcitestdata/0000-06-12.0.config
new file mode 100644 (file)
index 0000000..beee765
Binary files /dev/null and b/tests/virpcitestdata/0000-06-12.0.config differ
diff --git a/tests/virpcitestdata/0000-06-12.1.config b/tests/virpcitestdata/0000-06-12.1.config
new file mode 100644 (file)
index 0000000..beee765
Binary files /dev/null and b/tests/virpcitestdata/0000-06-12.1.config differ
diff --git a/tests/virpcitestdata/0000-06-12.2.config b/tests/virpcitestdata/0000-06-12.2.config
new file mode 100644 (file)
index 0000000..beee765
Binary files /dev/null and b/tests/virpcitestdata/0000-06-12.2.config differ