On 11/1/25 07:24, Roman Bogorodskiy wrote:
> From: Alexander Shursha <[email protected]>
>
> Bhyve supports PCI device passthrough using the following syntax:
>
> bhyve ... -s 4:0,passthru,5/2/0 ...
>
> Where 5/2/0 is PCI address of the device in the host, and "4:0" is the
> address in the guest.
>
> Currently, user is responsible for reserving the device for passthrough,
> i.e. by configuring pptdevs in loader.conf(5), or using devctl(8) to
> detach the device.
>
> Co-authored-by: Roman Bogorodskiy <[email protected]>
> Signed-off-by: Alexander Shursha <[email protected]>
> ---
> src/bhyve/bhyve_command.c | 27 ++++++++++++++++
> src/bhyve/bhyve_domain.c | 6 ++++
> .../bhyvexml2argv-passthru.args | 10 ++++++
> .../bhyvexml2argv-passthru.ldargs | 4 +++
> .../bhyvexml2argv-passthru.xml | 31 +++++++++++++++++++
> tests/bhyvexml2argvtest.c | 1 +
> 6 files changed, 79 insertions(+)
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru.args
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru.ldargs
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru.xml
Please squash this in:
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 4224cdf0fc..0ceac618e8 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -218,7 +218,8 @@ bhyveBuildRNGArgStr(const virDomainDef *def G_GNUC_UNUSED,
}
static int
-bhyveBuildHostdevArgStr(const virDomainDef *def, virCommand *cmd)
+bhyveBuildHostdevArgStr(const virDomainDef *def,
+ virCommand *cmd)
{
size_t i;
@@ -227,8 +228,10 @@ bhyveBuildHostdevArgStr(const virDomainDef *def,
virCommand *cmd)
virDomainHostdevSubsys *subsys = &hostdev->source.subsys;
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
- subsys->type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+ subsys->type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
continue;
+ }
+
virCommandAddArg(cmd, "-s");
virCommandAddArgFormat(cmd, "%d:%d,passthru,%d/%d/%d",
hostdev->info->addr.pci.slot,
@@ -237,6 +240,7 @@ bhyveBuildHostdevArgStr(const virDomainDef *def, virCommand
*cmd)
subsys->u.pci.addr.slot,
subsys->u.pci.addr.function);
}
+
return 0;
}
Michal