diff --git a/README.autostart b/README.autostart new file mode 100644 index 0000000..2b4f3b2 --- /dev/null +++ b/README.autostart @@ -0,0 +1,36 @@ +Prerequisites +============= + +Users, that want to use the VirtualBox autostart feature, have to be +members of the vboxusers group. + +E.g.: +sudo usermod -aG vboxusers USERNAME + +Preparation +=========== + +For each autostart user, add a section in /etc/vbox/autostart.cfg: + +USERNAME = { +allow = true +} + +Users work +========== + +The *first* time a user configures autostart, the command: +VBoxManage setproperty autostartdbpath /etc/vbox +needs to be run. + +Note: The autostart options are stored in the /etc/vbox file, and in the +VM itself. If moving a VM, these options may need to be set again. + +Prepare a VM to start automatically: +VBoxManage modifyvm --autostart-enabled + +Choose a shut down mode: +VBoxManage modifyvm --autostop-type + +Restart the vboxdrv service to start the VMs in question +sudo service vboxdrv restart diff --git a/fixes_for_leap15.patch b/fixes_for_leap15.patch deleted file mode 100644 index 36b74de..0000000 --- a/fixes_for_leap15.patch +++ /dev/null @@ -1,44 +0,0 @@ -Index: VirtualBox-5.2.8/src/VBox/Runtime/r0drv/linux/waitqueue-r0drv-linux.h -=================================================================== ---- VirtualBox-5.2.8.orig/src/VBox/Runtime/r0drv/linux/waitqueue-r0drv-linux.h -+++ VirtualBox-5.2.8/src/VBox/Runtime/r0drv/linux/waitqueue-r0drv-linux.h -@@ -46,7 +46,7 @@ - typedef struct RTR0SEMLNXWAIT - { - /** The wait queue entry. */ --#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0) -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) - wait_queue_entry_t WaitQE; - #else - wait_queue_t WaitQE; -Index: VirtualBox-5.2.8/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c -=================================================================== ---- VirtualBox-5.2.8.orig/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c -+++ VirtualBox-5.2.8/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c -@@ -150,6 +150,10 @@ typedef struct VBOXNETFLTNOTIFIER *PVBOX - # endif - #endif - -+# if 1 -+#define SKB_GSO_UDP 0 -+#endif -+ - #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0) - # define VBOX_HAVE_SKB_VLAN - #else -Index: VirtualBox-5.2.8/src/VBox/Additions/linux/drm/vbox_mode.c -=================================================================== ---- VirtualBox-5.2.8.orig/src/VBox/Additions/linux/drm/vbox_mode.c -+++ VirtualBox-5.2.8/src/VBox/Additions/linux/drm/vbox_mode.c -@@ -401,11 +401,7 @@ static struct drm_encoder *vbox_best_sin - - /* pick the encoder ids */ - if (enc_id) --#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) - return drm_encoder_find(connector->dev, NULL, enc_id); --#else -- return drm_encoder_find(connector->dev, enc_id); --#endif - - return NULL; - } diff --git a/switch_to_python3.6.patch b/switch_to_python3.4+.patch similarity index 74% rename from switch_to_python3.6.patch rename to switch_to_python3.4+.patch index ea092df..e0422bb 100644 --- a/switch_to_python3.6.patch +++ b/switch_to_python3.4+.patch @@ -1,32 +1,32 @@ -Index: VirtualBox-5.2.20/configure +Index: b/configure =================================================================== ---- VirtualBox-5.2.20.orig/configure -+++ VirtualBox-5.2.20/configure -@@ -1959,17 +1959,17 @@ extern "C" int main(void) +--- a/configure ++++ b/configure +@@ -1963,17 +1963,17 @@ extern "C" int main(void) { Py_Initialize(); printf("found version %s", PY_VERSION); -#if PY_VERSION_HEX >= 0x02060000 -+#if PY_VERSION_HEX >= 0x03060000 ++#if PY_VERSION_HEX >= 0x03040000 printf(", OK.\n"); return 0; #else - printf(", expected version 2.6 or higher\n"); -+ printf(", expected version 3.6 or higher\n"); ++ printf(", expected version 3.4 or higher\n"); return 1; #endif } EOF found= - SUPPYTHONLIBS="python2.7 python2.6 python3.1 python3.2 python3.3 python3.4 python3.4m python3.5 python3.5m python3.6 python3.6m" -+ SUPPYTHONLIBS="python3.6m python3.6 python3.7m python3.7" ++ SUPPYTHONLIBS="python3.4 python3.4m python3.5 python3.5m python3.6m python3.6 python3.7m python3.7" for p in $PYTHONDIR; do for d in $SUPPYTHONLIBS; do for b in lib/x86_64-linux-gnu lib/i386-linux-gnu lib64 lib/64 lib; do -Index: VirtualBox-5.2.20/src/VBox/Installer/linux/routines.sh +Index: b/src/VBox/Installer/linux/routines.sh =================================================================== ---- VirtualBox-5.2.20.orig/src/VBox/Installer/linux/routines.sh -+++ VirtualBox-5.2.20/src/VBox/Installer/linux/routines.sh +--- a/src/VBox/Installer/linux/routines.sh ++++ b/src/VBox/Installer/linux/routines.sh @@ -375,8 +375,8 @@ terminate_proc() { maybe_run_python_bindings_installer() { VBOX_INSTALL_PATH="${1}" @@ -38,11 +38,11 @@ Index: VirtualBox-5.2.20/src/VBox/Installer/linux/routines.sh if sys.version_info >= (2, 6): print \"test\"' 2> /dev/null`" != "test" ]; then echo 1>&2 "Python 2.6 or later not available, skipping bindings installation." -Index: VirtualBox-5.2.20/src/bldprogs/scm.cpp +Index: b/src/bldprogs/scm.cpp =================================================================== ---- VirtualBox-5.2.20.orig/src/bldprogs/scm.cpp -+++ VirtualBox-5.2.20/src/bldprogs/scm.cpp -@@ -2031,7 +2031,7 @@ static int scmProcessFileInner(PSCMRWSTA +--- a/src/bldprogs/scm.cpp ++++ b/src/bldprogs/scm.cpp +@@ -2033,7 +2033,7 @@ static int scmProcessFileInner(PSCMRWSTA pszTreatAs = "shell"; else if ( (cchFirst >= 15 && strncmp(pchFirst, "/usr/bin/python", 15) == 0) || (cchFirst >= 19 && strncmp(pchFirst, "/usr/bin/env python", 19) == 0) ) @@ -51,10 +51,10 @@ Index: VirtualBox-5.2.20/src/bldprogs/scm.cpp else if ( (cchFirst >= 13 && strncmp(pchFirst, "/usr/bin/perl", 13) == 0) || (cchFirst >= 17 && strncmp(pchFirst, "/usr/bin/env perl", 17) == 0) ) pszTreatAs = "perl"; -Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/configure +Index: b/src/libs/libxml2-2.9.4/configure =================================================================== ---- VirtualBox-5.2.20.orig/src/libs/libxml2-2.9.4/configure -+++ VirtualBox-5.2.20/src/libs/libxml2-2.9.4/configure +--- a/src/libs/libxml2-2.9.4/configure ++++ b/src/libs/libxml2-2.9.4/configure @@ -15153,10 +15153,10 @@ PYTHON_SITE_PACKAGES= PYTHON_TESTS= pythondir= @@ -79,10 +79,10 @@ Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/configure { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PYTHON+:} false; then : -Index: VirtualBox-5.2.20/src/VBox/ValidationKit/testboxscript/setup.sh +Index: b/src/VBox/ValidationKit/testboxscript/setup.sh =================================================================== ---- VirtualBox-5.2.20.orig/src/VBox/ValidationKit/testboxscript/setup.sh -+++ VirtualBox-5.2.20/src/VBox/ValidationKit/testboxscript/setup.sh +--- a/src/VBox/ValidationKit/testboxscript/setup.sh ++++ b/src/VBox/ValidationKit/testboxscript/setup.sh @@ -644,7 +644,7 @@ import sys;\ x = sys.version_info[0] == 2 and (sys.version_info[1] >= 6 or (sys.version_info[1] == 5 and sys.version_info[2] >= 1));\ sys.exit(not x);\ @@ -92,10 +92,10 @@ Index: VirtualBox-5.2.20/src/VBox/ValidationKit/testboxscript/setup.sh do python=`which ${python} 2> /dev/null` if [ -n "${python}" -a -x "${python}" ]; then -Index: VirtualBox-5.2.20/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec +Index: b/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec =================================================================== ---- VirtualBox-5.2.20.orig/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec -+++ VirtualBox-5.2.20/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec +--- a/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec ++++ b/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec @@ -20,7 +20,7 @@ %define %PYTHON% 1 %define VBOXDOCDIR %{_defaultdocdir}/%NAME% @@ -114,10 +114,10 @@ Index: VirtualBox-5.2.20/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec %endif rm -rf sdk/installer mv nls $RPM_BUILD_ROOT/usr/share/virtualbox -Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml.spec.in +Index: b/src/libs/libxml2-2.9.4/libxml.spec.in =================================================================== ---- VirtualBox-5.2.20.orig/src/libs/libxml2-2.9.4/libxml.spec.in -+++ VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml.spec.in +--- a/src/libs/libxml2-2.9.4/libxml.spec.in ++++ b/src/libs/libxml2-2.9.4/libxml.spec.in @@ -101,11 +101,11 @@ rm -fr %{buildroot} make install DESTDIR=%{buildroot} @@ -133,10 +133,10 @@ Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml.spec.in rm -f $RPM_BUILD_ROOT%{_libdir}/*.la -Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml2.spec +Index: b/src/libs/libxml2-2.9.4/libxml2.spec =================================================================== ---- VirtualBox-5.2.20.orig/src/libs/libxml2-2.9.4/libxml2.spec -+++ VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml2.spec +--- a/src/libs/libxml2-2.9.4/libxml2.spec ++++ b/src/libs/libxml2-2.9.4/libxml2.spec @@ -103,7 +103,7 @@ make install DESTDIR=%{buildroot} %if 0%{?with_python3} @@ -146,10 +146,10 @@ Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml2.spec make install DESTDIR=%{buildroot} %endif # with_python3 -Index: VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/ErrorUtils.cpp +Index: b/src/libs/xpcom18a4/python/src/ErrorUtils.cpp =================================================================== ---- VirtualBox-5.2.20.orig/src/libs/xpcom18a4/python/src/ErrorUtils.cpp -+++ VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/ErrorUtils.cpp +--- a/src/libs/xpcom18a4/python/src/ErrorUtils.cpp ++++ b/src/libs/xpcom18a4/python/src/ErrorUtils.cpp @@ -439,8 +439,10 @@ char *PyTraceback_AsString(PyObject *exc { // a temp scope so I can use temp locals. #if PY_MAJOR_VERSION <= 2 @@ -162,10 +162,10 @@ Index: VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/ErrorUtils.cpp #endif result = (char *)PyMem_Malloc(strlen(tempResult)+1); if (result==NULL) -Index: VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/PyGBase.cpp +Index: b/src/libs/xpcom18a4/python/src/PyGBase.cpp =================================================================== ---- VirtualBox-5.2.20.orig/src/libs/xpcom18a4/python/src/PyGBase.cpp -+++ VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/PyGBase.cpp +--- a/src/libs/xpcom18a4/python/src/PyGBase.cpp ++++ b/src/libs/xpcom18a4/python/src/PyGBase.cpp @@ -183,7 +183,11 @@ PyG_Base::~PyG_Base() // Get the correct interface pointer for this object given the IID. void *PyG_Base::ThisAsIID( const nsIID &iid ) diff --git a/vboxdrv.sh b/vboxdrv.sh index f519390..57da4da 100644 --- a/vboxdrv.sh +++ b/vboxdrv.sh @@ -297,51 +297,27 @@ stop() 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 +OLD_IFS=$IFS +IFS=$'\n' +# read config file +[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox +[ -z "$VBOXAUTOSTART_DB" ] && return +[ -z "$VBOXAUTOSTART_CONFIG" ] && return +# read autostart config file +if [ -r $VBOXAUTOSTART_CONFIG ]; then +# find all the files of type username.stop + var=$(ls $VBOXAUTOSTART_DB | grep stop | grep -v auto) +# process each file of that type + for i in $var; do +# Extract the user name - the first word on the line + user=$(echo $i | head -n1 | cut -d "." -f1) +# autostop the VMs for that user + su - $user -c "/usr/lib/virtualbox/VBoxAutostart --stop --config $VBOXAUTOSTART_CONFIG" + done +fi +IFS=$OLD_IFS } start_vms() @@ -350,22 +326,21 @@ OLD_IFS=$IFS IFS=$'\n' # read config file [ -r /etc/default/virtualbox ] && . /etc/default/virtualbox -#echo "Symbols are $VBOXAUTOSTART_DB and $VBOXAUTOSTART_CONFIG" +[ -z "$VBOXAUTOSTART_DB" ] && return +[ -z "$VBOXAUTOSTART_CONFIG" ] && return # read autostart config file if [ -r $VBOXAUTOSTART_CONFIG ]; then - VBoxManage list vms -# find all the files of type user.start +# find all the files of type username.start var=$(ls $VBOXAUTOSTART_DB | grep start | grep -v auto) # process each file of that type for i in $var; do # Extract the user name - the first word on the line user=$(echo $i | head -n1 | cut -d "." -f1) # autostart the VMs for that user - su $user -c "/usr/lib/virtualbox/VBoxAutostart --start --config $VBOXAUTOSTART_CONFIG" + su - $user -c "/usr/lib/virtualbox/VBoxAutostart --background --start --config $VBOXAUTOSTART_CONFIG" done fi IFS=$OLD_IFS - } cleanup() diff --git a/virtualbox-default.virtualbox b/virtualbox-default.virtualbox index 7fbd434..1de1176 100644 --- a/virtualbox-default.virtualbox +++ b/virtualbox-default.virtualbox @@ -1,19 +1,10 @@ # /etc/default/virtualbox # # ------------------------------------------------------------------------------------------------- -# In the "SHUTDOWN_USERS" list all users for which a check for runnings VMs should be done during -# shutdown of "vboxdrv" resp. the server: -# SHUTDOWN_USERS="foo bar" -# -# Set "SHUTDOWN" to one of "poweroff", "acpibutton" or "savestate" depending on which of the -# shutdown methods for running VMs are wanted: -# SHUTDOWN="poweroff" -# SHUTDOWN="acpibutton" -# SHUTDOWN="savestate" +# Autostart # ------------------------------------------------------------------------------------------------- -# -#SHUTDOWN_USERS="foo bar" -#SHUTDOWN="savestate" +VBOXAUTOSTART_DB=/etc/vbox +VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg # ------------------------------------------------------------------------------------------------- # By default, vboxdrv creates a file /etc/udev/rules.d/60-vboxdrv.rules every time, it is started, diff --git a/virtualbox.changes b/virtualbox.changes index d26eada..bcb92ca 100644 --- a/virtualbox.changes +++ b/virtualbox.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Wed Dec 5 12:10:20 UTC 2018 - Hans-Peter Jansen + +- replace switch_to_python3.6.patch with switch_to_python3.4+.patch + +------------------------------------------------------------------- +Tue Dec 4 21:43:02 UTC 2018 - Hans-Peter Jansen + +- remove fixes_for_leap15.patch, upstream has incorporated it +- add conflict with i4l-vbox due to shared /etc/vbox +- adjust /etc/vbox permissions +- add /etc/vbox/autostart.cfg +- fix vboxdrv.sh: apply new autostart mechanics to stop_vms() +- remove obsolete shutdown section in /etc/default/virtualbox +- add VBOXAUTOSTART_{DB,CONFIG} to /etc/default/virtualbox +- supply README.autostart + ------------------------------------------------------------------- Tue Nov 27 01:04:06 UTC 2018 - Larry Finger diff --git a/virtualbox.spec b/virtualbox.spec index 9494a55..977b755 100644 --- a/virtualbox.spec +++ b/virtualbox.spec @@ -68,6 +68,7 @@ Source16: vboxconfig.sh Source17: vboxguestconfig.sh Source18: fix_usb_rules.sh Source19: vboxdrv.sh +Source20: README.autostart Source98: %{name}-rpmlintrc Source99: %{name}-patch-source.sh #rework init scripts to fit suse needs @@ -117,16 +118,14 @@ Patch115: vbox_fix_for_gcc7.patch Patch116: Fix_for_server_1.19.patch # Fix invalid use of internal headers Patch118: internal-headers.patch -# Fix kernel API change in Leap 15 -Patch119: fixes_for_leap15.patch # Fix rpmlint error for script /lib/usr/virtualbox/vboxshell.py Patch120: fixes_for_python.patch # Remove vboxvideo from build Patch121: remove_vbox_video_build.patch # Fix build for Qt 5.11 Patch122: fixes_for_Qt5.11.patch -# Switch to Python 3.6 -Patch123: switch_to_python3.6.patch +# Switch to Python 3.4+ +Patch123: switch_to_python3.4+.patch Patch124: fix_32_bit_builds.patch # Fix API changes for kernel 4.20+ Patch125: fixes_for_4.20.patch @@ -229,6 +228,10 @@ BuildRequires: xorg-x11-libXmu-devel-32bit BuildRequires: xorg-x11-libXt-devel-32bit %endif %{?systemd_requires} +# package i4l-vbox from source package i4l-base shares the directory /etc/vbox +# with us, but with different owner. +Conflicts: i4l-vbox + %posttrans %description @@ -427,9 +430,6 @@ as an "extpack" for VirtualBox. The implementation is licensed under GPL. %patch115 -p1 %patch116 -p1 %patch118 -p1 -%if 0%{suse_version} == 1500 -%patch119 -p1 -%endif %patch120 -p1 %patch121 -p1 %patch122 -p1 @@ -442,6 +442,8 @@ as an "extpack" for VirtualBox. The implementation is licensed under GPL. cp %{SOURCE1} UserManual.pdf #copy kbuild config cp %{SOURCE10} LocalConfig.kmk +#copy autostart doc +cp %{SOURCE20} README.autostart # ########################## ####workaround kmk_sed --v @@ -690,6 +692,7 @@ install -m 644 %{SOURCE9} %{buildroot}%{_bindir}/VirtualBox # Service files to load kernel modules on boot install -m 0644 %{SOURCE14} %{buildroot}%{_unitdir}/vboxdrv.service +ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rcvboxdrv install -m 0644 %{SOURCE15} %{buildroot}%{_unitdir}/vboxadd-service.service install -m 0755 %{SOURCE16} %{buildroot}/sbin/vboxconfig install -m 0755 %{SOURCE17} %{buildroot}/sbin/vboxguestconfig @@ -703,6 +706,14 @@ ln -sf %{_unitdir}/vboxadd-service.service %{buildroot}%{_unitdir}/multi-user.ta # config file for vboxdrv script and vboxweb install -d -m 755 %{buildroot}%{_sysconfdir}/vbox echo -e "#settings for vboxwebsrn\nVBOXWEB_USER=root" > %{buildroot}%{_sysconfdir}/vbox/vbox.cfg +cat > %{buildroot}%{_sysconfdir}/vbox/autostart.cfg << EOF +default_policy = deny +# Create an entry for each user allowed to use autostart +myusername = { +allow = true +} + +EOF # install udev helper script for creating usb devices install -m 0755 -D src/VBox/Installer/linux/VBoxCreateUSBNode.sh %{buildroot}%{_vbox_instdir}/VBoxCreateUSBNode.sh ###################################################### @@ -859,7 +870,7 @@ export DISABLE_RESTART_ON_UPDATE=yes %files %defattr(-, root, root) -%doc UserManual.pdf +%doc README.autostart UserManual.pdf %{_bindir}/VBoxManage %{_bindir}/VBoxHeadless %{_bindir}/VBoxTunctl @@ -916,9 +927,11 @@ export DISABLE_RESTART_ON_UPDATE=yes /usr/lib/virtualbox/vboxdrv.sh %{_unitdir}/vboxdrv.service %{_unitdir}/multi-user.target.wants/vboxdrv.service +%{_sbindir}/rcvboxdrv %dir %{_sysconfdir}/vbox -##%attr(1775,root,vboxusers) %{_sysconfdir}/vbox +%attr(1775,root,vboxusers) %{_sysconfdir}/vbox %config %{_sysconfdir}/vbox/vbox.cfg +%config %{_sysconfdir}/vbox/autostart.cfg /sbin/vboxconfig %{_vbox_instdir}/VBoxCreateUSBNode.sh %verify(not mode) %attr(0755,root,vboxusers) %{_vbox_instdir}/VBoxNetNAT