提交 5a9dc4a5 编写于 作者: S Shivaprasad G Bhat 提交者: Michal Privoznik

virpcimock: Mock the SRIOV Virtual functions

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: NShivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 16c98903
...@@ -27,5 +27,5 @@ server,nowait \ ...@@ -27,5 +27,5 @@ server,nowait \
-usb \ -usb \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \ -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 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 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<hostdev mode='subsystem' type='pci' managed='yes'> <hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio'/> <driver name='vfio'/>
<source> <source>
<address domain='0x55aa' bus='32' slot='15' function='3'/> <address domain='0x0021' bus='222' slot='31' function='1'/>
</source> </source>
</hostdev> </hostdev>
<memballoon model='virtio'/> <memballoon model='virtio'/>
......
...@@ -27,5 +27,5 @@ server,nowait \ ...@@ -27,5 +27,5 @@ server,nowait \
-usb \ -usb \
-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \ -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 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 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<hostdev mode='subsystem' type='pci' managed='yes'> <hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio'/> <driver name='vfio'/>
<source> <source>
<address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/> <address domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
</source> </source>
</hostdev> </hostdev>
<memballoon model='virtio'/> <memballoon model='virtio'/>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<interface type='hostdev' managed='yes'> <interface type='hostdev' managed='yes'>
<mac address='00:11:22:33:44:55'/> <mac address='00:11:22:33:44:55'/>
<source> <source>
<address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/> <address type='pci' domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
</source> </source>
<model type='virtio'/> <model type='virtio'/>
<filterref filter='myfilter'/> <filterref filter='myfilter'/>
......
...@@ -27,5 +27,5 @@ server,nowait \ ...@@ -27,5 +27,5 @@ server,nowait \
-usb \ -usb \
-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -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 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 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<mac address='00:11:22:33:44:55'/> <mac address='00:11:22:33:44:55'/>
<driver name='vfio'/> <driver name='vfio'/>
<source> <source>
<address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/> <address type='pci' domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
</source> </source>
<vlan> <vlan>
<tag id='42'/> <tag id='42'/>
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<hostdev mode='subsystem' type='pci' managed='yes'> <hostdev mode='subsystem' type='pci' managed='yes'>
<driver name='vfio'/> <driver name='vfio'/>
<source> <source>
<address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/> <address domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
</source> </source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</hostdev> </hostdev>
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<mac address='00:11:22:33:44:55'/> <mac address='00:11:22:33:44:55'/>
<driver name='vfio'/> <driver name='vfio'/>
<source> <source>
<address type='pci' domain='0x0000' bus='0x03' slot='0x07' function='0x1'/> <address type='pci' domain='0x0000' bus='0x06' slot='0x12' function='0x1'/>
</source> </source>
<vlan> <vlan>
<tag id='42'/> <tag id='42'/>
......
...@@ -124,6 +124,7 @@ struct pciDevice { ...@@ -124,6 +124,7 @@ struct pciDevice {
int device; int device;
int klass; int klass;
int iommuGroup; int iommuGroup;
const char *physfn;
struct pciDriver *driver; /* Driver attached. NULL if attached to no driver */ struct pciDriver *driver; /* Driver attached. NULL if attached to no driver */
}; };
...@@ -545,6 +546,15 @@ pci_device_new_from_stub(const struct pciDevice *data) ...@@ -545,6 +546,15 @@ pci_device_new_from_stub(const struct pciDevice *data)
make_symlink(devsympath, devid, tmp); 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) if (pci_device_autobind(dev) < 0)
ABORT("Unable to bind: %s", devid); ABORT("Unable to bind: %s", devid);
...@@ -1020,6 +1030,15 @@ init_env(void) ...@@ -1020,6 +1030,15 @@ init_env(void)
MAKE_PCI_DEVICE("0000:0a:01.0", 0x8086, 0x0047, 8); 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:02.0", 0x8286, 0x0048, 8);
MAKE_PCI_DEVICE("0000:0a:03.0", 0x8386, 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 */
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册