Page MenuHomeFreeBSD

vmrun.sh: allow device name arguments in pci-passthru option
ClosedPublic

Authored by christos on Jan 2 2024, 11:15 AM.
Tags
None
Referenced Files
F115299498: D43270.id132126.diff
Tue, Apr 22, 9:10 AM
F115288883: D43270.id132126.diff
Tue, Apr 22, 7:04 AM
F115224967: D43270.id132124.diff
Mon, Apr 21, 2:41 PM
Unknown Object (File)
Thu, Apr 17, 3:58 PM
Unknown Object (File)
Wed, Apr 16, 8:42 PM
Unknown Object (File)
Sat, Apr 12, 5:19 PM
Unknown Object (File)
Sat, Apr 12, 12:50 AM
Unknown Object (File)
Thu, Apr 3, 8:57 PM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 55197
Build 52086: arc lint + arc unit

Event Timeline

Diff against D43269 since it logically depends on it. My bad.

share/examples/bhyve/vmrun.sh
90–91

In my experience, if you want to pass a device through to the VM, the host driver has to be detached, in which case it'll show up in pciconf -l output as none@pci.... So I'm not sure how this can work.

360
share/examples/bhyve/vmrun.sh
90–91

The example is indeed incorrect, as the driver would have to be detached first. bhyve works by passing it a ppt driver, so none (although the script will still be able to fetch its bus/slot/func) isn't supposed to be used either.

https://wiki.freebsd.org/bhyve/pci_passthru

The example should say ppt0 instead of ehci0.

share/examples/bhyve/vmrun.sh
360

I'll fix this in another commit because there are multiple other instances of this.

share/examples/bhyve/vmrun.sh
90–91

Ah right, ok.

Can we please also preserve backward compatibility? That is, if the passthrough device is of the form a/b/c, avoid treating it as a device name?

358

I think you can replace this pipe with passno=$(pciconf -l | awk -F: '{print $2"/"$3"/"$4}').

share/examples/bhyve/vmrun.sh
90–91

Sure.

358

Thank you, definitely better this way

share/examples/bhyve/vmrun.sh
358

Sorry, I meant to write pciconf -l $pass| awk -F: '{print $2"/"$3"/"$4}'.

I'd also name the variable something more accurate, maybe "bsl" (bus slot function).

christos retitled this revision from vmrun.sh: pass pci device name instead of bus/slot/func to vmrun.sh: allow device name arguments in pci-passthru option.Jan 2 2024, 5:43 PM
christos marked 4 inline comments as done.

Address Mark's comments. Preserve backwards compatibility.

Fix indentation and use if-else than test.

share/examples/bhyve/vmrun.sh
355

[0-9]* matches the empty string, but we don't want that.

356

Sorry, I meant to write "bsf".

christos marked 2 inline comments as done.

Address Mark's comments.

share/examples/bhyve/vmrun.sh
358

Don't we need to preserve the domain as well?

share/examples/bhyve/vmrun.sh
356

Sorry, I meant to write "bsf".

I didn't think about it at all, thanks.

358

bhyve expects bus/slot/entry as input, so the domain field is not needed in this case.

This revision is now accepted and ready to land.Jan 2 2024, 6:14 PM