[Pkg-virtualbox-devel] Bug#451742: Bug#451742: Don't modprobe vboxadd

Kel Modderman kel at otaku42.de
Mon Nov 19 08:22:06 UTC 2007

Hi Michael,

On Sunday 18 November 2007 23:13:19 Michael Meskes wrote:
> On Sun, Nov 18, 2007 at 10:22:14PM +1000, Kel Modderman wrote:
> > If I put the software on a live debian cd, I can boot the same set of
> > software on real hardware or in a VM. The software should do the correct
> > thing in both the real and virtual worlds.
> Absolutely right. That's why the init script will check whether it is
> inside the VM before starting anything.

I have attached patch below to improve upon what is committed to
pkg-virtualbox in r116 and r118.

Remove the set -e bit, and do exit status checking ourselves with the
log_end_msg lsb function. set -e is generally unwanted in initscripts, and
it is not as if anything that this initscript will ever do should cause script
to bail out so hard.

$ grep 'set -e' /etc/init.d/skeleton
# Do NOT "set -e"

The committed lspci check will not work, because vendor id and device id is
not provided in the default lspci output stream. A better way would be to do a
direct lookup using known vendor_id:device_id with the '-d' option. If a string is
returned then the device is present. If nothing is returned, print a message
stating system is not in a Virtual Machine.

Put the check in a function, run it for the "start" and "stop" actions.

A warning should be printed in the case the script is ran outside of a VM.

Since now there is a check for emulated Vbox VGA hardware, the call to modprobe
could be retained, just do it quietly, so that we can warn if kernel support is
unavailable and exit before attempting to start the daemons.

Depend on pciutils, because it is called from the initscript unconditionally.

Thanks, Kel.

Index: debian/control
--- debian/control	(revision 120)
+++ debian/control	(working copy)
@@ -66,7 +66,7 @@
 Package: virtualbox-ose-guest-utils
 Architecture: amd64 i386
-Depends: ${shlibs:Depends}, ${misc:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}, pciutils
 Recommends: virtualbox-ose-guest-modules, virtualbox-ose-guest-source
 Description: PC virtualization solution - guest utils
  VirtualBox is a free PC virtualization solution allowing you to run a wide
Index: debian/virtualbox-ose-guest-utils.init
--- debian/virtualbox-ose-guest-utils.init	(revision 120)
+++ debian/virtualbox-ose-guest-utils.init	(working copy)
@@ -14,23 +14,40 @@
 . /lib/lsb/init-functions
-set -e
+	if [ -z "$(lspci -d 80ee:beef)" ]; then
+		log_action_begin_msg 'VirtualBox Additions Disabled';
+		log_warning_msg 'not in a Virtual Machine environemnt';
+		log_end_msg 0
+		return 1
+	fi
-(lspci|grep -q 80ee:beef) || exit 0 # not inside a vm
+	return 0
 case "$1" in
+  	in_virtual_machine || exit 0
   	log_action_begin_msg 'Starting VirtualBox Additions';
-	# udev should have already handled thismodule
-	# modprobe vboxadd
+	# udev should have already handled this module
+	# double check kernel support is present or die
+	modprobe --quiet vboxadd
+	if [ "$?" -ne 0 ]; then
+		# vboxadd not installed, or has a problem
+		log_failure_msg 'cannot modprobe vboxadd kernel module';
+		log_end_msg 1
+		exit 1
+	fi
 	start-stop-daemon --start --quiet --exec /usr/sbin/vboxadd-timesync -- --daemonize
-	log_end_msg 0
+	log_end_msg $?
+  	in_virtual_machine || exit 0
   	log_action_begin_msg 'Stopping VirtualBox Additions';
 	start-stop-daemon --stop --quiet --oknodo --exec /usr/sbin/vboxadd-timesync
-	log_end_msg 0
+	log_end_msg $?

More information about the Pkg-virtualbox-devel mailing list