Hello community,

here is the log from the commit of package virtualbox for openSUSE:Factory 
checked in at 2017-07-12 19:33:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/virtualbox (Old)
 and      /work/SRC/openSUSE:Factory/.virtualbox.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "virtualbox"

Wed Jul 12 19:33:32 2017 rev:136 rq:509284 version:5.1.22

Changes:
--------
--- /work/SRC/openSUSE:Factory/virtualbox/virtualbox.changes    2017-07-04 
11:54:05.989630428 +0200
+++ /work/SRC/openSUSE:Factory/.virtualbox.new/virtualbox.changes       
2017-07-12 19:33:33.577075187 +0200
@@ -1,0 +2,7 @@
+Mon Jul 10 18:22:25 UTC 2017 - larry.fin...@lwfinger.net
+
+- Fix several problems with the startup scripts. The SysV form is no longer 
used for most packages as proper systemd
+  service files have been created. These fixes address bsc#1037291, #1043532, 
and #1045871.
+- Increase reserved disk space from 4 to 5 GB. This change was suddested as a 
fix for the 32-bit failures. 
+
+-------------------------------------------------------------------

New:
----
  vboxdrv.sh

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ virtualbox.spec ++++++
--- /var/tmp/diff_new_pack.so2pns/_old  2017-07-12 19:33:35.840755803 +0200
+++ /var/tmp/diff_new_pack.so2pns/_new  2017-07-12 19:33:35.840755803 +0200
@@ -52,6 +52,7 @@
 Source16:       vboxconfig.sh
 Source17:       vboxguestconfig.sh
 Source18:       fix_usb_rules.sh
+Source19:       vboxdrv.sh
 Source98:       %{name}-rpmlintrc
 Source99:       %{name}-patch-source.sh
 #rework init scripts to fit suse needs
@@ -546,10 +547,7 @@
 install -m 755 out/linux.*/release/bin/additions/VBoxControl 
%{buildroot}%{_bindir}/VBoxControl
 install -m 755 out/linux.*/release/bin/additions/VBoxService 
%{buildroot}%{_sbindir}/VBoxService
 install -m 755 out/linux.*/release/bin/additions/mount.vboxsf 
%{buildroot}/sbin/mount.vboxsf
-install -m 744 src/VBox/Additions/linux/installer/vboxadd.sh 
%{buildroot}%{_sysconfdir}/init.d/vboxadd
-install -m 744 src/VBox/Additions/linux/installer/vboxadd-service.sh 
%{buildroot}%{_sysconfdir}/init.d/vboxadd-service
-ln -s %{_sysconfdir}/init.d/vboxadd %{buildroot}%{_sbindir}/rcvboxadd
-ln -s %{_sysconfdir}/init.d/vboxadd-service 
%{buildroot}%{_sbindir}/rcvboxadd-service
+install -m 744 src/VBox/Additions/linux/installer/vboxadd-service.sh 
%{buildroot}%{_vbox_instdir}/vboxadd-service
 # udev rule for guest (virtualbox-guest-tools)
 install -m 644 %{SOURCE3}                      
%{buildroot}%{_udevrulesdir}/60-vboxguest.rules
 # /media is used for auto-mounting of shared folders
@@ -634,10 +632,10 @@
 #install wrapper script
 install -m 644 %{SOURCE9}                      
%{buildroot}%{_bindir}/VirtualBox
 # modify and install the vboxdrv init script
-sed -i "s|%{NOLSB}%|yes|g;s|%{DEBIAN}%||g;s|%{PACKAGE}%|virtualbox|g" \
-                                               
src/VBox/Installer/linux/vboxdrv.sh
-install -m 744 src/VBox/Installer/linux/vboxdrv.sh 
%{buildroot}%{_sysconfdir}/init.d/vboxdrv
-ln -s %{_sysconfdir}/init.d/vboxdrv %{buildroot}%{_sbindir}/rcvboxdrv
+#sed -i "s|%{NOLSB}%|yes|g;s|%{DEBIAN}%||g;s|%{PACKAGE}%|virtualbox|g" \
+#                                              
src/VBox/Installer/linux/vboxdrv.sh
+install -m 0755 %{SOURCE19}                    
%{buildroot}%{_vbox_instdir}/vboxdrv.sh
+ln -s %{_vbox_instdir}/vboxdrv.sh              
%{buildroot}%{_sbindir}/rcvboxdrv
 # Service files to load kernel modules on boot
 install -m 0644 %{SOURCE14}                    
%{buildroot}%{_unitdir}/vboxdrv.service
 install -m 0644 %{SOURCE15}                    
%{buildroot}%{_unitdir}/vboxadd-service.service
@@ -728,7 +726,7 @@
 # Add groups for seamless mode and shared folders:
 getent group vboxguest >/dev/null || groupadd -r vboxguest
 getent group vboxsf >/dev/null || groupadd -r vboxsf
-%service_add_pre vboadd.service
+%service_add_pre vboxadd.service
 
 #######################################################
 # scriptlets - post
@@ -868,9 +866,10 @@
 %{_vbox_instdir}/components/*.xpt
 %dir %{_datadir}/virtualbox
 %config %{_sysconfdir}/default/virtualbox
-%config %{_sysconfdir}/init.d/vboxdrv
+%dir /usr/lib/virtualbox
 %dir %{_unitdir}
 %dir %{_unitdir}/multi-user.target.wants
+/usr/lib/virtualbox/vboxdrv.sh
 %{_unitdir}/vboxdrv.service
 %{_unitdir}/multi-user.target.wants/vboxdrv.service
 %dir %{_sysconfdir}/vbox
@@ -924,12 +923,9 @@
 /sbin/vboxguestconfig
 /sbin/mount.vboxsf
 %{_udevrulesdir}/60-vboxguest.rules
-%config %{_sysconfdir}/init.d/vboxadd
-%config %{_sysconfdir}/init.d/vboxadd-service
+%{_vbox_instdir}/vboxadd-service
 %{_unitdir}/vboxadd-service.service
 %{_unitdir}/multi-user.target.wants/vboxadd-service.service
-%{_sbindir}/rcvboxadd
-%{_sbindir}/rcvboxadd-service
 %if 0%{?suse_version} > 1320 || 0%{?sle_version} == 120300
 %dir /media
 %endif

++++++ _constraints ++++++
--- /var/tmp/diff_new_pack.so2pns/_old  2017-07-12 19:33:35.872751289 +0200
+++ /var/tmp/diff_new_pack.so2pns/_new  2017-07-12 19:33:35.872751289 +0200
@@ -4,5 +4,8 @@
     <physicalmemory>
       <size unit="M">8000</size>
     </physicalmemory>
+    <disk>
+      <size unit="G">5</size>
+    </disk>
   </hardware>
 </constraints>

++++++ vbox-vboxadd-init-script.diff ++++++
--- /var/tmp/diff_new_pack.so2pns/_old  2017-07-12 19:33:35.956739439 +0200
+++ /var/tmp/diff_new_pack.so2pns/_new  2017-07-12 19:33:35.960738875 +0200
@@ -16,7 +16,7 @@
  ### END INIT INFO
  
  ## @todo This file duplicates a lot of script with vboxdrv.sh.  When making
-@@ -108,11 +111,10 @@ fail()
+@@ -108,18 +111,9 @@ fail()
  
  dev=/dev/vboxguest
  userdev=/dev/vboxuser
@@ -25,11 +25,17 @@
  group=1
  
 -if test -r $config; then
-+if [[ -r $config ]] ; then
-   . $config
- else
-   fail "Configuration file $config not found"
-@@ -162,12 +164,6 @@ do_vboxguest_non_udev()
+-  . $config
+-else
+-  fail "Configuration file $config not found"
+-fi
+-test -n "$INSTALL_DIR" -a -n "$INSTALL_VER" ||
+-  fail "Configuration file $config not complete"
+-
+ running_vboxguest()
+ {
+     lsmod | grep -q "vboxguest[^_-]"
+@@ -162,12 +156,6 @@ do_vboxguest_non_udev()
              fail "Cannot create device $dev with major $maj and minor $min"
          }
      fi
@@ -42,7 +48,7 @@
  
      if [ ! -c $userdev ]; then
          maj=10
-@@ -178,12 +174,6 @@ do_vboxguest_non_udev()
+@@ -178,12 +166,6 @@ do_vboxguest_non_udev()
                  rmmod vboxguest 2>/dev/null
                  fail "Cannot create device $userdev with major $maj and minor 
$min"
              }
@@ -55,7 +61,7 @@
          fi
      fi
  }
-@@ -193,9 +183,8 @@ start()
+@@ -193,9 +175,8 @@ start()
      begin "Starting the VirtualBox Guest Additions" console;
      # If we got this far assume that the slow set-up has been done.
      QUICKSETUP=yes
@@ -67,16 +73,15 @@
              no_udev=1
          running_vboxguest || {
              rm -f $dev || {
-@@ -209,7 +198,7 @@ start()
+@@ -209,7 +190,6 @@ start()
              $MODPROBE vboxguest >/dev/null 2>&1 || {
                  setup
                  $MODPROBE vboxguest >/dev/null 2>&1 || {
 -                    ${INSTALL_DIR}/init/vboxadd-x11 cleanup
-+                    ${INSTALL_DIR}#/init/vboxadd-x11 cleanup
                      fail "modprobe vboxguest failed"
                  }
              }
-@@ -234,14 +223,14 @@ start()
+@@ -234,14 +214,14 @@ start()
      fi  # INSTALL_NO_MODULE_BUILDS
  
      # Put the X.Org driver in place.  This is harmless if it is not needed.
@@ -94,7 +99,7 @@
          # SELinux for the OpenGL libraries, so that gdm can load them during 
the
          # acceleration support check.  This prevents an "Oh no, something has 
gone
          # wrong!" error when starting EL7 guests.
-@@ -254,6 +243,15 @@ start()
+@@ -254,6 +234,15 @@ start()
              chcon -h  -t lib_t  "/var/lib/VBoxGuestAdditions/lib/libEGL.so.1"
          fi
          echo "/var/lib/VBoxGuestAdditions/lib" > 
/etc/ld.so.conf.d/00vboxvideo.conf
@@ -110,7 +115,7 @@
      fi
      ldconfig
  
-@@ -394,9 +392,9 @@ create_udev_rule()
+@@ -394,9 +383,9 @@ create_udev_rule()
          echo "KERNEL=${udev_fix}\"vboxuser\", NAME=\"vboxuser\", 
OWNER=\"vboxadd\", MODE=\"0666\"" >> /etc/udev/rules.d/60-vboxadd.rules
      fi
  }
@@ -123,7 +128,7 @@
      # And a post-installation script for rebuilding modules when a new kernel
      # is installed.
      mkdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d
-@@ -427,47 +425,18 @@ shared_folder_setup()
+@@ -427,47 +416,18 @@ shared_folder_setup()
      ## @todo It would be nicer if the kernel module just parsed parameters
      # itself instead of needing a separate binary to do that.
      ln -sf "$lib_path/$PACKAGE/mount.vboxsf" /sbin
@@ -175,7 +180,7 @@
          depmod
  
          # Remove old module sources
-@@ -477,13 +446,14 @@ cleanup()
+@@ -477,13 +437,14 @@ cleanup()
      fi
  
      # Clean-up X11-related bits

++++++ vboxadd-service.service ++++++
--- /var/tmp/diff_new_pack.so2pns/_old  2017-07-12 19:33:35.996733796 +0200
+++ /var/tmp/diff_new_pack.so2pns/_new  2017-07-12 19:33:36.000733232 +0200
@@ -13,8 +13,8 @@
 GuessMainPID=no
 RemainAfterExit=yes
 SuccessExitStatus=5 6
-ExecStart=/etc/init.d/vboxadd-service start
-ExecStop=/etc/init.d/vboxadd-service stop
+ExecStart=/usr/lib/virtualbox/vboxadd-service start
+ExecStop=/usr/lib/virtualbox/vboxadd-service stop
 
 [Install]
 WantedBy=multi-user.target.wants

++++++ vboxdrv.service ++++++
--- /var/tmp/diff_new_pack.so2pns/_old  2017-07-12 19:33:36.024729847 +0200
+++ /var/tmp/diff_new_pack.so2pns/_new  2017-07-12 19:33:36.024729847 +0200
@@ -1,21 +1,20 @@
 [Unit]
-Description=Start/Stop VirtualBox host kernel modules
-SourcePath=/etc/init.d/vboxdrv
-After=remote-fs.target
-Wants=remote-fs.target
+SourcePath=/usr/lib/virtualbox/vboxdrv.sh
+Description=VirtualBox Linux kernel module
+Before=runlevel2.target runlevel3.target runlevel5.target shutdown.target
+After=
+Conflicts=shutdown.target
 
 [Service]
-Type=simple
+Type=forking
 Restart=no
 TimeoutSec=5min
 IgnoreSIGPIPE=no
 KillMode=process
 GuessMainPID=no
 RemainAfterExit=yes
-SuccessExitStatus=5 6
-ExecStart=/etc/init.d/vboxdrv start
-ExecStop=/etc/init.d/vboxdrv stop
+ExecStart=/usr/lib/virtualbox/vboxdrv.sh start
+ExecStop=/usr/lib/virtualbox/vboxdrv.sh stop
 
 [Install]
-WantedBy=multi-user.target.wants
-
+WantedBy=multi-user.target

++++++ vboxdrv.sh ++++++
#! /bin/sh
# Oracle VM VirtualBox
# Linux kernel module init script

#
# Copyright (C) 2006-2015 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#

# chkconfig: 345 20 80
# description: VirtualBox Linux kernel module
#
### BEGIN INIT INFO
# Provides:       vboxdrv
# Required-Start: $syslog $remote_fs
# Required-Stop:  $syslog $remote_fs
# Default-Start:  2 3 5
# Default-Stop:   0 1 6
# Short-Description: VirtualBox Linux module
# Description: VirtualBox Linux kernel module
### END INIT INFO

## @todo This file duplicates a lot of script with vboxadd.sh.  When making
# changes please try to reduce differences between the two wherever possible.

## @todo Remove the stop_vms target so that this script is only relevant to
# kernel modules.  Nice but not urgent.

PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
DEVICE=/dev/vboxdrv
LOG="/var/log/vbox-install.log"
MODPROBE=/sbin/modprobe
SCRIPTNAME=vboxdrv.sh

# The below is GNU-specific.  See VBox.sh for the longer Solaris/OS X version.
TARGET=`readlink -e -- "${0}"` || exit 1
SCRIPT_DIR="${TARGET%/[!/]*}"

if $MODPROBE -c | grep -q '^allow_unsupported_modules  *0'; then
  MODPROBE="$MODPROBE --allow-unsupported-modules"
fi

[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
export BUILD_TYPE
export USERNAME
export USER=$USERNAME

if test -n "${INSTALL_DIR}" && test -x "${INSTALL_DIR}/VirtualBox"; then
    MODULE_SRC="${INSTALL_DIR}/src/vboxhost"
elif test -x /usr/lib/virtualbox/VirtualBox; then
    INSTALL_DIR=/usr/lib/virtualbox
    MODULE_SRC="/usr/share/virtualbox/src/vboxhost"
elif test -x "${SCRIPT_DIR}/VirtualBox"; then
    # Executing from the build directory
    INSTALL_DIR="${SCRIPT_DIR}"
    MODULE_SRC="${INSTALL_DIR}/src"
else
    # Silently exit if the package was uninstalled but not purged.
    # Applies to Debian packages only (but shouldn't hurt elsewhere)
    exit 0
fi
VIRTUALBOX="${INSTALL_DIR}/VirtualBox"
VBOXMANAGE="${INSTALL_DIR}/VBoxManage"
BUILDINTMP="${MODULE_SRC}/build_in_tmp"
if test -u "${VIRTUALBOX}"; then
    GROUP=root
    DEVICE_MODE=0600
else
    GROUP=vboxusers
    DEVICE_MODE=0660
fi

[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox

# Preamble for Gentoo
if [ "`which $0`" = "/sbin/rc" ]; then
    shift
fi

begin_msg()
{
    test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
    logger -t "${SCRIPTNAME}" "${1}."
}

succ_msg()
{
    logger -t "${SCRIPTNAME}" "${1}."
}

fail_msg()
{
    echo "${SCRIPTNAME}: failed: ${1}." >&2
    logger -t "${SCRIPTNAME}" "failed: ${1}."
}

failure()
{
    fail_msg "$1"
    exit 1
}

running()
{
    lsmod | grep -q "$1[^_-]"
}

## Output the vboxdrv part of our udev rule.  This is redirected to the right 
file.
udev_write_vboxdrv() {
    VBOXDRV_GRP="$1"
    VBOXDRV_MODE="$2"

    echo "KERNEL==\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", 
GROUP=\"$VBOXDRV_GRP\", MODE=\"$VBOXDRV_MODE\""
    echo "KERNEL==\"vboxdrvu\", NAME=\"vboxdrvu\", OWNER=\"root\", 
GROUP=\"root\", MODE=\"0666\""
    echo "KERNEL==\"vboxnetctl\", NAME=\"vboxnetctl\", OWNER=\"root\", 
GROUP=\"$VBOXDRV_GRP\", MODE=\"$VBOXDRV_MODE\""
}

## Output the USB part of our udev rule.  This is redirected to the right file.
udev_write_usb() {
    INSTALLATION_DIR="$1"
    USB_GROUP="$2"

    echo "SUBSYSTEM==\"usb_device\", ACTION==\"add\", 
RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh \$major \$minor 
\$attr{bDeviceClass}${USB_GROUP}\""
    echo "SUBSYSTEM==\"usb\", ACTION==\"add\", ENV{DEVTYPE}==\"usb_device\", 
RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh \$major \$minor 
\$attr{bDeviceClass}${USB_GROUP}\""
    echo "SUBSYSTEM==\"usb_device\", ACTION==\"remove\", 
RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh --remove \$major \$minor\""
    echo "SUBSYSTEM==\"usb\", ACTION==\"remove\", ENV{DEVTYPE}==\"usb_device\", 
RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh --remove \$major \$minor\""
}

## Generate our udev rule file.  This takes a change in udev rule syntax in
## version 55 into account.  It only creates rules for USB for udev versions
## recent enough to support USB device nodes.
generate_udev_rule() {
    VBOXDRV_GRP="$1"      # The group owning the vboxdrv device
    VBOXDRV_MODE="$2"     # The access mode for the vboxdrv device
    INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
    USB_GROUP="$4"        # The group that has permission to access USB devices
    NO_INSTALL="$5"       # Set this to "1" to remove but not re-install rules

    # Extra space!
    case "$USB_GROUP" in ?*) USB_GROUP=" $USB_GROUP" ;; esac
    case "$NO_INSTALL" in "1") return ;; esac
    udev_write_vboxdrv "$VBOXDRV_GRP" "$VBOXDRV_MODE"
    udev_write_usb "$INSTALLATION_DIR" "$USB_GROUP"
}

## Install udev rule (disable with INSTALL_NO_UDEV=1 in
## /etc/default/virtualbox).
install_udev() {
    VBOXDRV_GRP="$1"      # The group owning the vboxdrv device
    VBOXDRV_MODE="$2"     # The access mode for the vboxdrv device
    INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
    USB_GROUP="$4"        # The group that has permission to access USB devices
    NO_INSTALL="$5"       # Set this to "1" to remove but not re-install rules

    if test -d /etc/udev/rules.d; then
        generate_udev_rule "$VBOXDRV_GRP" "$VBOXDRV_MODE" "$INSTALLATION_DIR" \
                           "$USB_GROUP" "$NO_INSTALL"
    fi
    # Remove old udev description file
    rm -f /etc/udev/rules.d/10-vboxdrv.rules 2> /dev/null
}

## Create a usb device node for a given sysfs path to a USB device.
install_create_usb_node_for_sysfs() {
    path="$1"           # sysfs path for the device
    usb_createnode="$2" # Path to the USB device node creation script
    usb_group="$3"      # The group to give ownership of the node to
    if test -r "${path}/dev"; then
        dev="`cat "${path}/dev" 2> /dev/null`"
        major="`expr "$dev" : '\(.*\):' 2> /dev/null`"
        minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`"
        class="`cat ${path}/bDeviceClass 2> /dev/null`"
        sh "${usb_createnode}" "$major" "$minor" "$class" \
              "${usb_group}" 2>/dev/null
    fi
}

udev_rule_file=/etc/udev/rules.d/60-vboxdrv.rules
sysfs_usb_devices="/sys/bus/usb/devices/*"

## Install udev rules and create device nodes for usb access
setup_usb() {
    VBOXDRV_GRP="$1"      # The group that should own /dev/vboxdrv
    VBOXDRV_MODE="$2"     # The mode to be used for /dev/vboxdrv
    INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
    USB_GROUP="$4"        # The group that should own the /dev/vboxusb device
                          # nodes unless INSTALL_NO_GROUP=1 in
                          # /etc/default/virtualbox.  Optional.
    usb_createnode="$INSTALLATION_DIR/VBoxCreateUSBNode.sh"
    # install udev rule (disable with INSTALL_NO_UDEV=1 in
    # /etc/default/virtualbox)
    if [ "$INSTALL_NO_GROUP" != "1" ]; then
        usb_group=$USB_GROUP
        vboxdrv_group=$VBOXDRV_GRP
    else
        usb_group=root
        vboxdrv_group=root
    fi
    install_udev "${vboxdrv_group}" "$VBOXDRV_MODE" \
                 "$INSTALLATION_DIR" "${usb_group}" \
                 "$INSTALL_NO_UDEV" > ${udev_rule_file}
    # Build our device tree
    for i in ${sysfs_usb_devices}; do  # This line intentionally without quotes.
        install_create_usb_node_for_sysfs "$i" "${usb_createnode}" \
                                          "${usb_group}"
    done
}

cleanup_usb()
{
    # Remove udev description file
    rm -f /etc/udev/rules.d/60-vboxdrv.rules
    rm -f /etc/udev/rules.d/10-vboxdrv.rules

    # Remove our USB device tree
    rm -rf /dev/vboxusb
}

start()
{
    begin_msg "Starting VirtualBox services" console
    if [ -d /proc/xen ]; then
        failure "Running VirtualBox in a Xen environment is not supported"
    fi
    if ! running vboxdrv; then
        if ! rm -f $DEVICE; then
            failure "Cannot remove $DEVICE"
        fi
        if ! $MODPROBE vboxdrv > /dev/null 2>&1; then
            setup
            if ! $MODPROBE vboxdrv > /dev/null 2>&1; then
                failure "modprobe vboxdrv failed. Please use 'dmesg' to find 
out why"
            fi
        fi
        sleep .2
    fi
    # ensure the character special exists
    if [ ! -c $DEVICE ]; then
        MAJOR=`sed -n 's;\([0-9]\+\) vboxdrv$;\1;p' /proc/devices`
        if [ ! -z "$MAJOR" ]; then
            MINOR=0
        else
            MINOR=`sed -n 's;\([0-9]\+\) vboxdrv$;\1;p' /proc/misc`
            if [ ! -z "$MINOR" ]; then
                MAJOR=10
            fi
        fi
        if [ -z "$MAJOR" ]; then
            rmmod vboxdrv 2>/dev/null
            failure "Cannot locate the VirtualBox device"
        fi
        if ! mknod -m 0660 $DEVICE c $MAJOR $MINOR 2>/dev/null; then
            rmmod vboxdrv 2>/dev/null
            failure "Cannot create device $DEVICE with major $MAJOR and minor 
$MINOR"
        fi
    fi
    # ensure permissions
    if ! $MODPROBE vboxnetflt > /dev/null 2>&1; then
        failure "modprobe vboxnetflt failed. Please use 'dmesg' to find out why"
    fi
    if ! $MODPROBE vboxnetadp > /dev/null 2>&1; then
        failure "modprobe vboxnetadp failed. Please use 'dmesg' to find out why"
    fi
    if ! $MODPROBE vboxpci > /dev/null 2>&1; then
        failure "modprobe vboxpci failed. Please use 'dmesg' to find out why"
    fi
    # Create the /dev/vboxusb directory if the host supports that method
    # of USB access.  The USB code checks for the existance of that path.
    if grep -q usb_device /proc/devices; then
        mkdir -p -m 0750 /dev/vboxusb 2>/dev/null
        chown root:vboxusers /dev/vboxusb 2>/dev/null
    fi
    succ_msg "VirtualBox services started"
}

stop()
{
    begin_msg "Stopping VirtualBox services" console

    if running vboxpci; then
        if ! rmmod vboxpci 2>/dev/null; then
            failure "Cannot unload module vboxpci"
        fi
    fi
    if running vboxnetadp; then
        if ! rmmod vboxnetadp 2>/dev/null; then
            failure "Cannot unload module vboxnetadp"
        fi
    fi
    if running vboxdrv; then
        if running vboxnetflt; then
            if ! rmmod vboxnetflt 2>/dev/null; then
                failure "Cannot unload module vboxnetflt"
            fi
        fi
        if ! rmmod vboxdrv 2>/dev/null; then
            failure "Cannot unload module vboxdrv"
        fi
        if ! rm -f $DEVICE; then
            failure "Cannot unlink $DEVICE"
        fi
    fi
    succ_msg "VirtualBox services stopped"
}

# enter the following variables in /etc/default/virtualbox:
#   SHUTDOWN_USERS="foo bar"
#     check for running VMs of user foo and user bar
#   SHUTDOWN=poweroff
#   SHUTDOWN=acpibutton
#   SHUTDOWN=savestate
#     select one of these shutdown methods for running VMs
stop_vms()
{
    wait=0
    for i in $SHUTDOWN_USERS; do
        # don't create the ipcd directory with wrong permissions!
        if [ -d /tmp/.vbox-$i-ipc ]; then
            export VBOX_IPC_SOCKETID="$i"
            VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 
's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
            if [ -n "$VMS" ]; then
                if [ "$SHUTDOWN" = "poweroff" ]; then
                    begin_msg "Powering off remaining VMs"
                    for v in $VMS; do
                        $VBOXMANAGE --nologo controlvm $v poweroff
                    done
                    succ_msg "Remaining VMs powered off"
                elif [ "$SHUTDOWN" = "acpibutton" ]; then
                    begin_msg "Sending ACPI power button event to remaining VMs"
                    for v in $VMS; do
                        $VBOXMANAGE --nologo controlvm $v acpipowerbutton
                        wait=30
                    done
                    succ_msg "ACPI power button event sent to remaining VMs"
                elif [ "$SHUTDOWN" = "savestate" ]; then
                    begin_msg "Saving state of remaining VMs"
                    for v in $VMS; do
                        $VBOXMANAGE --nologo controlvm $v savestate
                    done
                    succ_msg "State of remaining VMs saved"
                fi
            fi
        fi
    done
    # wait for some seconds when doing ACPI shutdown
    if [ "$wait" -ne 0 ]; then
        begin_msg "Waiting for $wait seconds for VM shutdown"
        sleep $wait
        succ_msg "Waited for $wait seconds for VM shutdown"
    fi
}

cleanup()
{
    for i in /lib/modules/*; do
        # We could just do "rm -f", but we only want to try deleting folders if
        # we are sure they were ours, i.e. they had our modules in beforehand.
        if    test -e "${i}/misc/vboxdrv.ko" \
           || test -e "${i}/misc/vboxnetadp.ko" \
           || test -e "${i}/misc/vboxnetflt.ko" \
           || test -e "${i}/misc/vboxpci.ko"; then
            rm -f "${i}/misc/vboxdrv.ko" "${i}/misc/vboxnetadp.ko" \
                  "${i}/misc/vboxnetflt.ko" "${i}/misc/vboxpci.ko"
            # Remove the kernel version folder if it was empty except for us.
            test   "`echo ${i}/misc/* ${i}/misc/.?* ${i}/* ${i}/.?*`" \
                 = "${i}/misc/* ${i}/misc/.. ${i}/misc ${i}/.." &&
                rmdir "${i}/misc" "${i}"  # We used to leave empty folders.
            version=`expr "${i}" : "/lib/modules/\(.*\)"`
            depmod -a "${version}"
        fi
    done
}

# setup_script
setup()
{
#   Try to build the host kernel modules in case prepackaging has failed
    /sbin/vboxconfig
}

dmnstatus()
{
    if running vboxdrv; then
        str="vboxdrv"
        if running vboxnetflt; then
            str="$str, vboxnetflt"
            if running vboxnetadp; then
                str="$str, vboxnetadp"
            fi
        fi
        if running vboxpci; then
            str="$str, vboxpci"
        fi
        echo "VirtualBox kernel modules ($str) are loaded."
        for i in $SHUTDOWN_USERS; do
            # don't create the ipcd directory with wrong permissions!
            if [ -d /tmp/.vbox-$i-ipc ]; then
                export VBOX_IPC_SOCKETID="$i"
                VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 
's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
                if [ -n "$VMS" ]; then
                    echo "The following VMs are currently running:"
                    for v in $VMS; do
                       echo "  $v"
                    done
                fi
            fi
        done
    else
        echo "VirtualBox kernel module is not loaded."
    fi
}

case "$1" in
start)
    start
    ;;
stop)
    stop_vms
    stop
    ;;
stop_vms)
    stop_vms
    ;;
restart)
    stop && start
    ;;
setup)
    # Create udev rule and USB device nodes.
    ## todo Wouldn't it make more sense to install the rule to /lib/udev?  This
    ## is not a user-created configuration file after all.
    ## todo Do we need a udev rule to create /dev/vboxdrv[u] at all?  We have
    ## working fall-back code here anyway, and the "right" code is more complex
    ## than the fall-back.  Unnecessary duplication?
    stop && cleanup
    setup_usb "$GROUP" "$DEVICE_MODE" "$INSTALL_DIR"
    setup && start
    ;;
cleanup)
    stop && cleanup
    cleanup_usb
    ;;
force-reload)
    stop
    start
    ;;
status)
    dmnstatus
    ;;
*)
    echo "Usage: $0 {start|stop|stop_vms|restart|force-reload|status}"
    exit 1
esac

exit 0


Reply via email to