From: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
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(a)linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
.../hostdev-vfio-multidomain.args | 2 +-
.../hostdev-vfio-multidomain.xml | 2 +-
tests/qemuxml2argvdata/hostdev-vfio.args | 2 +-
tests/qemuxml2argvdata/hostdev-vfio.xml | 2 +-
tests/qemuxml2argvdata/net-hostdev-fail.xml | 2 +-
tests/qemuxml2argvdata/net-hostdev-vfio.args | 2 +-
tests/qemuxml2argvdata/net-hostdev-vfio.xml | 2 +-
tests/qemuxml2xmloutdata/hostdev-vfio.xml | 2 +-
tests/qemuxml2xmloutdata/net-hostdev-vfio.xml | 2 +-
tests/virpcimock.c | 19 ++++++++++++++++++
tests/virpcitestdata/0000-06-12.0.config | Bin 0 -> 256 bytes
tests/virpcitestdata/0000-06-12.1.config | Bin 0 -> 256 bytes
tests/virpcitestdata/0000-06-12.2.config | Bin 0 -> 256 bytes
13 files changed, 28 insertions(+), 9 deletions(-)
create mode 100644 tests/virpcitestdata/0000-06-12.0.config
create mode 100644 tests/virpcitestdata/0000-06-12.1.config
create mode 100644 tests/virpcitestdata/0000-06-12.2.config
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args
b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args
index d098bff356..959d2a8888 100644
--- a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args
+++ b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.args
@@ -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
diff --git a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml
b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml
index 832458125b..7c34b65c7f 100644
--- a/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml
+++ b/tests/qemuxml2argvdata/hostdev-vfio-multidomain.xml
@@ -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'/>
diff --git a/tests/qemuxml2argvdata/hostdev-vfio.args
b/tests/qemuxml2argvdata/hostdev-vfio.args
index 79654f44bb..f2025afcd4 100644
--- a/tests/qemuxml2argvdata/hostdev-vfio.args
+++ b/tests/qemuxml2argvdata/hostdev-vfio.args
@@ -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
diff --git a/tests/qemuxml2argvdata/hostdev-vfio.xml
b/tests/qemuxml2argvdata/hostdev-vfio.xml
index 4d96b9f732..b2e6c62e7e 100644
--- a/tests/qemuxml2argvdata/hostdev-vfio.xml
+++ b/tests/qemuxml2argvdata/hostdev-vfio.xml
@@ -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'/>
diff --git a/tests/qemuxml2argvdata/net-hostdev-fail.xml
b/tests/qemuxml2argvdata/net-hostdev-fail.xml
index c815d68bd9..50b102c658 100644
--- a/tests/qemuxml2argvdata/net-hostdev-fail.xml
+++ b/tests/qemuxml2argvdata/net-hostdev-fail.xml
@@ -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'/>
diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.args
b/tests/qemuxml2argvdata/net-hostdev-vfio.args
index aa9e91db82..b0178a81bb 100644
--- a/tests/qemuxml2argvdata/net-hostdev-vfio.args
+++ b/tests/qemuxml2argvdata/net-hostdev-vfio.args
@@ -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
diff --git a/tests/qemuxml2argvdata/net-hostdev-vfio.xml
b/tests/qemuxml2argvdata/net-hostdev-vfio.xml
index 24034cad8b..aff681c0fb 100644
--- a/tests/qemuxml2argvdata/net-hostdev-vfio.xml
+++ b/tests/qemuxml2argvdata/net-hostdev-vfio.xml
@@ -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'/>
diff --git a/tests/qemuxml2xmloutdata/hostdev-vfio.xml
b/tests/qemuxml2xmloutdata/hostdev-vfio.xml
index 77bd62a129..15a845f4d1 100644
--- a/tests/qemuxml2xmloutdata/hostdev-vfio.xml
+++ b/tests/qemuxml2xmloutdata/hostdev-vfio.xml
@@ -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>
diff --git a/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml
b/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml
index 0523cd8d3b..3f057a8249 100644
--- a/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml
+++ b/tests/qemuxml2xmloutdata/net-hostdev-vfio.xml
@@ -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'/>
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index e9440e7910..b1651617a6 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -125,6 +125,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);
@@ -1022,6 +1032,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
index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03d9a349c6ea12e
GIT binary patch
literal 256
ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S
literal 0
HcmV?d00001
diff --git a/tests/virpcitestdata/0000-06-12.1.config
b/tests/virpcitestdata/0000-06-12.1.config
new file mode 100644
index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03d9a349c6ea12e
GIT binary patch
literal 256
ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S
literal 0
HcmV?d00001
diff --git a/tests/virpcitestdata/0000-06-12.2.config
b/tests/virpcitestdata/0000-06-12.2.config
new file mode 100644
index 0000000000000000000000000000000000000000..beee76534041a7020c08ae9ac03d9a349c6ea12e
GIT binary patch
literal 256
ycmXpOFlAt45MXi^VCG@qU|?VnU}yr8Sb;H6EeJS(Ng%<*sKv;@R0rb@MH&E<&;s)S
literal 0
HcmV?d00001
--
2.21.0