Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
src/bhyve/bhyve_device.c | 10 ++++
.../bhyvexml2argv-passthru-multiple-devs.args | 12 +++++
...hyvexml2argv-passthru-multiple-devs.ldargs | 4 ++
.../bhyvexml2argv-passthru-multiple-devs.xml | 41 ++++++++++++++++
tests/bhyvexml2argvtest.c | 1 +
...bhyvexml2xmlout-passthru-multiple-devs.xml | 48 +++++++++++++++++++
tests/bhyvexml2xmltest.c | 1 +
7 files changed, 117 insertions(+)
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru-multiple-devs.xml
diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index 49cfccaeba..ead52ae704 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -196,6 +196,16 @@ bhyveAssignDevicePCISlots(virDomainDef *def,
return -1;
}
+ for (i = 0; i < def->nhostdevs; i++) {
+ if (!virDeviceInfoPCIAddressIsWanted(def->hostdevs[i]->info))
+ continue;
+ if (virDomainPCIAddressReserveNextAddr(addrs,
+ def->hostdevs[i]->info,
+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
+ -1) < 0)
+ return -1;
+ }
+
return 0;
}
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.args b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.args
new file mode 100644
index 0000000000..97647987bd
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.args
@@ -0,0 +1,12 @@
+bhyve \
+-c 1 \
+-m 214 \
+-S \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 7:1,passthru,3/0/4 \
+-s 3:0,passthru,4/0/0 \
+-s 4:0,passthru,5/2/0 \
+bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.ldargs
new file mode 100644
index 0000000000..5905f4b3e6
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.ldargs
@@ -0,0 +1,4 @@
+bhyveload \
+-m 214 \
+-d /tmp/freebsd.img \
+bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.xml
new file mode 100644
index 0000000000..bcea7aa033
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-passthru-multiple-devs.xml
@@ -0,0 +1,41 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <memoryBacking>
+ <locked/>
+ </memoryBacking>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type>hvm</type>
+ </os>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <source>
+ <address domain='0x0000' bus='0x03' slot='0x00' function='0x4'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <source>
+ <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <source>
+ <address domain='0x0000' bus='0x05' slot='0x02' function='0x0'/>
+ </source>
+ </hostdev>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 5d234b39fa..f7411ee094 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -223,6 +223,7 @@ mymain(void)
DO_TEST("localtime");
DO_TEST("net-e1000");
DO_TEST("passthru");
+ DO_TEST("passthru-multiple-devs");
DO_TEST("uefi");
DO_TEST("uefi-nvram");
DO_TEST("uefi-nvram-template-set");
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru-multiple-devs.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru-multiple-devs.xml
new file mode 100644
index 0000000000..dbb2a03cd3
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru-multiple-devs.xml
@@ -0,0 +1,48 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <memoryBacking>
+ <locked/>
+ </memoryBacking>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <source>
+ <address domain='0x0000' bus='0x03' slot='0x00' function='0x4'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <source>
+ <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='pci' managed='no'>
+ <source>
+ <address domain='0x0000' bus='0x05' slot='0x02' function='0x0'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </hostdev>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index 226eaccc6a..97c8647192 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -119,6 +119,7 @@ mymain(void)
DO_TEST_DIFFERENT("4-consoles");
DO_TEST_DIFFERENT("nvme");
DO_TEST_DIFFERENT("2-nvme-2-controllers");
+ DO_TEST_DIFFERENT("passthru-multiple-devs");
/* Address allocation tests */
DO_TEST_DIFFERENT("addr-single-sata-disk");
--
2.51.0
© 2016 - 2025 Red Hat, Inc.