This allows bhyve and bhyveload to boot directly from an
unmodified bsdinstall.
Reported by: pat@patmaddox.com
Sponsored by: SkunkWerks, GmbH
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 69960 Build 66843: arc lint + arc unit
Event Timeline
I still haven't figured out when the hook is triggered, but this is already pretty neat.
The idea is to give loader enough smarts to be able to directly boot a VM from a clean
install without further modifications.
If I'm reading this right, it means no more virtio_p9fs_load="YES" needed in loader.conf? If so that would be very cool.
I'm torn on this...
I'd rather have a regexp -> modules to load table that we cruise through so we can also do zfs
But at the same time, I don't want errors for people that have zfs or the p9fs modules in the kernel (I thought my playing with this required an additional module).
So this fills a need, but it's the end of the road for things like this...
- move check earlier, I don't think I can use a hook this early
- actually works now
testing
- untar base.txz and kernel.txz somewhere
- copy in config.lua from this patch
cp -av /usr/src/stand/lua/config.lua /tmp/root/boot/lua/ # bhyvectl --destroy --vm=vm0 # bhyveload -m 1G \ -h /tmp/root/ \ -e vfs.root.mountfrom=p9fs:devroot \ vm0 # bhyve -m 1G -A \ -l com1,stdio \ -s 0,hostbridge \ -s 3,virtio-9p,devroot=/tmp/root \ -s 31,lpc \ vm0
I like the idea behind this, just have one question...
| stand/lua/config.lua | ||
|---|---|---|
| 529 | Still haven't answered my question: what about the warning this will cause when virtio_p9fs is compiled into the kernel for normal installs. A warning that can't be suppressed. | |
| stand/lua/config.lua | ||
|---|---|---|
| 525 | Maybe you add an if that checks to see if autoload_rootfs_module is false, and then return w/o loading the module? We can default it to true in defaults/loader.conf, but that lets people set something to avoid the message that I'm worried about here. + docs, etc. That would be ideal and gives you an actionable way to address my request. | |
My preference would be that we add in a config.isModuleDisabled():
diff --git a/stand/lua/config.lua b/stand/lua/config.lua index 26f65ecc17b6..32978c4da7de 100644 --- a/stand/lua/config.lua +++ b/stand/lua/config.lua @@ -902,6 +902,14 @@ function config.isModuleEnabled(modname) return not blacklist[modname] end +function config.isModuleDisabled(modname) + if not modules[modname] then + return false + end + + return not config.isModuleEnabled(modname) +end + function config.getModuleInfo() return { modules = modules,
... and use that to avoid loading it if it's explicitly disabled. If virtio_p9fs isn't mentioned at all (the default), then it autoloads. One then explicitly disables the module with _load="NO", and that scales a little better past p9fs if we expand this.
(Scales a little better in the sense that one can have an image that can do any number of multiple fs, and they can only disable autoloading of specific rootfs)