VirtualBox kernel modules

John Hein emul-jfbml at snkmail.com
Fri Jan 11 22:50:29 UTC 2013


Bernhard Fröhlich wrote at 16:34 +0100 on Jan 11, 2013:
 > On Fri, Jan 11, 2013 at 4:19 PM, Brandon Gooch
 > <jamesbrandongooch at gmail.com> wrote:
 > > On Thu, Jan 10, 2013 at 10:31 PM, Warren Block <wblock at wonkity.com> wrote:
 > >
 > >> On Thu, 10 Jan 2013, Ryan Stone wrote:
 > >>
 > >>  As I recall, a make installkernel will first mv /boot/kernel
 > >>> /boot/kernel.old
 > >>>
 > >>> Should ports put modules in /boot/modules to avoid this kind of thing?
 > >>>
 > >>
 > >> I thought so, but the Porter's Handbook doesn't say anything about it.
 > >> multimedia/cuse4bsd-kmod installs a module there.
 > >
 > >
 > >  The previous versions of this port did indeed install the modules into
 > > /boot/modules; only with the most recent version (4.2.6) has this changed.
 > > For example:
 > >
 > > $ tar tvf /usr/ports/packages/All/virtualbox-ose-kmod-4.1.22.txz
 > > [...]
 > > -r-xr-xr-x  0 root   wheel  297288 Sep 19 09:19 /boot/modules/vboxdrv.ko
 > > -r-xr-xr-x  0 root   wheel    9544 Sep 19 09:19 /boot/modules/vboxnetadp.ko
 > > -r-xr-xr-x  0 root   wheel   26648 Sep 19 09:19 /boot/modules/vboxnetflt.ko
 > > [...]
 > >
 > > $ tar tvf /usr/ports/packages/All/virtualbox-ose-kmod-4.2.6.txz
 > > [...]
 > > -r-xr-xr-x  0 root   wheel  337912 Jan  6 13:13 /boot/kernel/vboxdrv.ko
 > > -r-xr-xr-x  0 root   wheel    9696 Jan  6 13:13 /boot/kernel/vboxnetadp.ko
 > > -r-xr-xr-x  0 root   wheel   26808 Jan  6 13:13 /boot/kernel/vboxnetflt.ko
 > > [...]
 > >
 > > I don't know WHY this changed, or if it was just an oversight during the
 > > update -- perhaps it by (re)design...
 >
 > I think this is an unwanted side effect. In fact I changed the defintion of
 > where the kernel module should be installed in virtualbox-ose-kmod/Makefile
 > from KMODDIR=/boot/modules to KMODDIR?=/boot/modules to allow
 > overwriting the KMODDIR in case you want to have a non default directory
 > for your kernel modules (like in a jail).
 >
 > I haven't found yet where KMODDIR is set to /boot/kernel but it obviously is
 > defined somewhere. I'm also not sure if that is really a virtualbox
 > problem or if
 > we better should fix that in Mk and set KMODDIR or create a new variable for
 > ports kernel modules.
 >
 > In the meantime overwriting KMODDIR to /boot/modules in your make.conf
 > should help.

It's in /usr/share/mk/bsd.own.mk (which is included early by make(1) -
due to bsd.own.mk inclusion in /usr/shar/mk/bsd.port.mk)...

..if defined(MODULES_WITH_WORLD)
KMODDIR?=       /boot/modules
..else
KMODDIR?=       /boot/kernel
..endif

And from make.conf(5) ...

     MODULES_WITH_WORLD
                   (bool) Set to build modules with the system instead of the
                   kernel.

Not the best named knob for the KMODDIR adjustment.

% cd emulators/virtualbox-ose-kmod
% grep ^KMODDIR Makefile
KMODDIR?=       /boot/modules
% make -V KMODDIR MODULES_WITH_WORLD=1
/boot/modules

MODULES_WITH_WORLD is also used in /sys/conf/kern.post.mk and
/usr/src/Makefile.inc1 (the latter is, of course, irrelevant to
modules built in ports).

Probably the ports infrastructure should be set to have KMODDIR point
to /boot/modules by default (and allow overrides - e.g., for jails).

One way to do that might be defining MODULES_WITH_WORLD for ports
builds.

And another... somewhere in Mk/bsd.ports.mk perhaps:

..undef KMODDIR
KMODDIR?= /boot/modules

(and then you can remove all the KMODDIR=/boot/modules from all
individual ports' Makefiles)



More information about the freebsd-emulation mailing list