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
F102199627: D43270.diff
Fri, Nov 8, 8:58 PM
Unknown Object (File)
Wed, Nov 6, 9:14 PM
Unknown Object (File)
Wed, Nov 6, 9:14 PM
Unknown Object (File)
Wed, Nov 6, 9:14 PM
Unknown Object (File)
Wed, Nov 6, 9:14 PM
Unknown Object (File)
Wed, Nov 6, 9:04 PM
Unknown Object (File)
Sat, Oct 26, 5:43 AM
Unknown Object (File)
Oct 9 2024, 6:52 PM
Subscribers

Diff Detail

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

Event Timeline

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

share/examples/bhyve/vmrun.sh
90

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.

359
share/examples/bhyve/vmrun.sh
90

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
359

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

share/examples/bhyve/vmrun.sh
90

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?

357

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

share/examples/bhyve/vmrun.sh
90

Sure.

357

Thank you, definitely better this way

share/examples/bhyve/vmrun.sh
357

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
354–359

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

355

Sorry, I meant to write "bsf".

christos marked 2 inline comments as done.

Address Mark's comments.

share/examples/bhyve/vmrun.sh
357

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

share/examples/bhyve/vmrun.sh
355

Sorry, I meant to write "bsf".

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

357

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