Getting enlightened drivers to load only when Hyper-V (or Azure) is detected

John Baldwin jhb at
Thu Jan 24 19:52:41 UTC 2013

On Thursday, January 24, 2013 9:50:54 am Larry Melia (Insight Global) wrote:
> We're preparing our Hyper-V, enlightened drivers to be included in the 
CURRENT build, but need some help with the loader configuration. The drivers 
should only load or remain resident when Hyper-V is present. On Linux, the 
installer program was modified to detect the presence of Hyper-V/Azure, and 
only then are the Hyper-V drivers installed (starting with the VM Bus driver). 
What's the best way to do this on FreeBSD? Any help would be greatly 
> Thanks in advance!
> Larry Melia
> Enlightened driver team for FreeBSD on Hyper-V

Currently the approach we seem to be taking with these sorts of things is 
either to use a custom kernel config (such as XENHVM), or to include drivers 
by default (such as with virtio now being in the default x86 kernels).  We do 
have a mechanism in place for auto-loading drivers post-boot (devd), but you 
need to have your root filesystem in place, and I suspect you want to use an 
enlightened driver for your root filesystem. :)

Currently we don't really autoload any drivers at the boot loader stage.  We 
did do that for ACPI for a while but have since moved to just including ACPI 
by default.  The place to do this would be in the /boot/loader code.  You can 
see an example of triggering this in sys/boot/i386/libi386/biosacpi.c.  The 
way this was achieved for ACPI was to have code that was run during 
/boot/loader's startup set the 'acpi_load' variable if ACPI was detected.  The 
loader will auto-load any module 'foo' if the 'foo_load' variable is set 
before it boots the kernel.  If you want to go the dynamic route (vs having a 
HYPERV kernel config, or just including the relevant drivers in GENERIC), then 
that is what you will need to do.

John Baldwin

More information about the freebsd-virtualization mailing list