From: Roman Bogorodskiy Date: Wed, 2 Apr 2025 11:20:11 +0000 (+0200) Subject: bhyve: auto-assign PCI addresses for hostdevs X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=HEAD;p=thirdparty%2Flibvirt.git bhyve: auto-assign PCI addresses for hostdevs Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- 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 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + + + + 1 + + hvm + + + destroy + destroy + destroy + + + + + +
+ + + +
+ +
+ + + +
+ + + + +
+ + + + 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 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + + + + 1 + + hvm + + + + destroy + destroy + destroy + + + + + +
+ + + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + 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");