1
0
forked from pool/virtualbox

Accepting request 706136 from home:frispete:kernel

Hi Larry,

here we go..

this version of VB is tested successfully with TW and 15.0, builds
with 42.3, 15.0, 15.0 with Kernel:stable, 15.1, TW, and behaves 
properly autostart-wise.

So it's good to go from my POV.

Cheers,
Pete

- separate vboxautostart.sh from vboxdrv.sh
- add vboxautostart.service
- clean up vboxdrv.sh
- fix build of vboxvideo kernel module by replacing the relative
  drm include patch with an absolute include path (with sed)
- build vboxvideo kernel module for openSUSE >= 15.0
- apply fixes_for_Leap15.1.patch conditionally only
- add minimal patch fixes_for_Leap42.3.patch to build for 42.3
- fix path typo: %{_datadir}/pixmaps/virtalbox
              -> %{_datadir}/pixmaps/virtualbox

OBS-URL: https://build.opensuse.org/request/show/706136
OBS-URL: https://build.opensuse.org/package/show/Virtualization/virtualbox?expand=0&rev=489
This commit is contained in:
Larry Finger 2019-05-29 14:36:37 +00:00 committed by Git OBS Bridge
parent d72c0caca1
commit cbf52ea5f0
7 changed files with 218 additions and 83 deletions

13
fixes_for_Leap42.3.patch Normal file
View File

@ -0,0 +1,13 @@
Index: b/src/VBox/Additions/linux/sharedfolders/regops.c
===================================================================
--- a/src/VBox/Additions/linux/sharedfolders/regops.c
+++ b/src/VBox/Additions/linux/sharedfolders/regops.c
@@ -1436,7 +1436,7 @@ DECLINLINE(int) vbsf_lock_user_pages(uin
# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
ssize_t cPagesLocked = get_user_pages_unlocked(uPtrFrom, cPages, fWrite, 1 /*force*/, papPages);
# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 168) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
- ssize_t cPagesLocked = get_user_pages_unlocked(current, current->mm, uPtrFrom, cPages, papPages,
+ ssize_t cPagesLocked = get_user_pages_unlocked(uPtrFrom, cPages, papPages,
fWrite ? FOLL_WRITE | FOLL_FORCE : FOLL_FORCE);
# elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
ssize_t cPagesLocked = get_user_pages_unlocked(current, current->mm, uPtrFrom, cPages, fWrite, 1 /*force*/, papPages);

18
vboxautostart.service Normal file
View File

@ -0,0 +1,18 @@
[Unit]
SourcePath=/usr/lib/virtualbox/vboxautostart.sh
Description=VirtualBox Linux autostart module
Requires=vboxdrv.service
After=vboxdrv.service
After=network.target
After=time-sync.target
After=nss-user-lookup.target
[Service]
ExecStart=/usr/lib/virtualbox/vboxautostart.sh start
ExecStop=/usr/lib/virtualbox/vboxautostart.sh stop
Type=oneshot
RemainAfterExit=yes
TimeoutStopSec=0
[Install]
WantedBy=multi-user.target

126
vboxautostart.sh Normal file
View File

@ -0,0 +1,126 @@
#!/bin/sh
# VirtualBox autostart service init script.
#
# Copyright (C) 2012-2019 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 35 65
# description: VirtualBox autostart service
#
### BEGIN INIT INFO
# Provides: vboxautostart-service
# Required-Start: vboxdrv
# Required-Stop: vboxdrv
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: VirtualBox autostart service
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
SCRIPTNAME=vboxautostart.sh
# read vbox config
[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
# read autostart config
[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
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}."
}
vboxdrvrunning() {
lsmod | grep -q "vboxdrv[^_-]"
}
start_vms()
{
OLD_IFS=$IFS
IFS=$'\n'
[ -z "$VBOXAUTOSTART_DB" ] && return
[ -z "$VBOXAUTOSTART_CONFIG" ] && return
begin_msg "Starting VirtualBox VMs configured for autostart" console;
vboxdrvrunning || {
fail_msg "VirtualBox kernel module not loaded!"
exit 0
}
# read autostart config file
if [ -r $VBOXAUTOSTART_CONFIG ]; then
# prevent inheriting this setting to VBoxSVC
unset VBOX_RELEASE_LOG_DEST
# 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
begin_msg "Starting VMs for user $user" console
su - $user -c "/usr/lib/virtualbox/VBoxAutostart --start --config $VBOXAUTOSTART_CONFIG"
succ_msg "VMs for user $user started"
done
fi
IFS=$OLD_IFS
}
stop_vms()
{
OLD_IFS=$IFS
IFS=$'\n'
[ -z "$VBOXAUTOSTART_DB" ] && return
[ -z "$VBOXAUTOSTART_CONFIG" ] && return
# read autostart config file
if [ -r $VBOXAUTOSTART_CONFIG ]; then
# prevent inheriting this setting to VBoxSVC
unset VBOX_RELEASE_LOG_DEST
# 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
begin_msg "Stopping VMs for user $user" console
su - $user -c "/usr/lib/virtualbox/VBoxAutostart --stop --config $VBOXAUTOSTART_CONFIG"
succ_msg "VMs for user $user stopped"
done
fi
IFS=$OLD_IFS
}
case "$1" in
start)
start_vms
;;
stop)
stop_vms
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0

View File

@ -27,12 +27,6 @@
# 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"
@ -66,11 +60,6 @@ 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}."
@ -297,56 +286,6 @@ stop_drv()
succ_msg "VirtualBox services stopped"
}
stop_vms()
{
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
begin_msg "Stopping VMs for user $user" console
su - $user -c "/usr/lib/virtualbox/VBoxAutostart --stop --config $VBOXAUTOSTART_CONFIG"
succ_msg "VMs for user $user stopped"
done
fi
IFS=$OLD_IFS
}
start_vms()
{
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.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
begin_msg "Starting VMs for user $user" console
su - $user -c "/usr/lib/virtualbox/VBoxAutostart --start --config $VBOXAUTOSTART_CONFIG"
succ_msg "VMs for user $user started"
done
fi
IFS=$OLD_IFS
}
cleanup_vb()
{
for i in /lib/modules/*; do
@ -410,15 +349,10 @@ dmnstatus()
case "$1" in
start)
start_drv
start_vms
;;
stop)
stop_vms
stop_drv
;;
stop_vms)
stop_vms
;;
restart)
"$0" stop && "$0" start
;;

View File

@ -3,6 +3,6 @@
%dir /lib/modules/%2-%1/extra
/lib/modules/%2-%1/extra/vboxsf.ko
/lib/modules/%2-%1/extra/vboxguest.ko
%if 0%{?suse_version} == 1500
%if 0%{?suse_version} >= 1500
/lib/modules/%2-%1/extra/vboxvideo.ko
%endif

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Mon May 27 09:07:45 UTC 2019 - Hans-Peter Jansen <hpj@urpla.net>
- separate vboxautostart.sh from vboxdrv.sh
- add vboxautostart.service
- clean up vboxdrv.sh
- fix build of vboxvideo kernel module by replacing the relative
drm include patch with an absolute include path (with sed)
- build vboxvideo kernel module for openSUSE >= 15.0
- apply fixes_for_Leap15.1.patch conditionally only
- add minimal patch fixes_for_Leap42.3.patch to build for 42.3
- fix path typo: %{_datadir}/pixmaps/virtalbox
-> %{_datadir}/pixmaps/virtualbox
-------------------------------------------------------------------
Thu May 16 17:50:44 UTC 2019 - Larry Finger <Larry.Finger@gmail.com>

View File

@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@ -78,6 +78,8 @@ Source19: vboxdrv.sh
Source20: README.autostart
Source21: vboxweb-service.service
Source22: vboxweb-service.sh
Source23: vboxautostart.service
Source24: vboxautostart.sh
Source98: %{name}-rpmlintrc
Source99: %{name}-patch-source.sh
#rework init scripts to fit suse needs
@ -139,6 +141,8 @@ Patch125: remove_vbox_video_build.patch
Patch128: fix_lib_search.patch
# Fixes for modified kernel in Leap 15.1
Patch129: fixes_for_Leap15.1.patch
# Fixes for modified kernel in Leap 42.3
Patch130: fixes_for_Leap42.3.patch
# Fixes for Qt5.13
Patch131: fixes_for_qt5.13.patch
#endif
@ -441,11 +445,19 @@ as an "extpack" for VirtualBox. The implementation is licensed under GPL.
%patch123 -p1
%patch125 -p1
%patch128 -p1
# Tumbleweed, Leap 15.1 and above drm adjustments
%if 0%{?suse_version} > 1500 || (0%{?sle_version} >= 150100 && 0%{?is_opensuse})
%patch129 -p1
%endif
# Leap 42.3 adjustments
%if 0%{?sle_version} == 120300 && 0%{?is_opensuse}
%patch130 -p1
%endif
# Qt5.13 adjustments
%if %{qt5ver} >= 51300
%patch131 -p1
%endif
# make VB UI background colors look sane again
%patch999 -p1
#copy user manual
@ -473,6 +485,8 @@ echo "SED = $RPM_BUILD_DIR/VirtualBox-%{version}/kmk_sed" >> LocalConfig.kmk
####workaround kmk_sed --^
##########################
#
# fix build of vboxvideo kernel module: replace relative drm include path with absolute include path
sed -i 's:include/drm:/usr/src/linux/include/drm:' src/VBox/Additions/linux/drm/Makefile.module.kms
%build
# Disable LTO - Link Time Optimization
@ -525,7 +539,7 @@ install -D -m 644 "COPYING" "%{buildroot}%{_datadir}/licenses/LICENSE.vnc"
# host modules : vboxdrv,vboxnetflt,vboxnetadp,vboxpci
# guest modules : vboxguest,vboxsf vboxvideo (for Leap 15.1)
echo "build kernel modules"
%if 0%{?suse_version} == 1500
%if 0%{?suse_version} >= 1500
for vbox_module in out/linux.*/release/bin/src/vbox{drv,netflt,netadp,pci} \
out/linux.*/release/bin/additions/src/vbox{guest,sf,video}; do
%else
@ -553,14 +567,15 @@ for vbox_module in out/linux.*/release/bin/src/vbox{drv,netflt,netadp,pci} \
cp $PWD/modules_build_dir/$flavor/vboxdrv/Module.symvers \
$PWD/modules_build_dir/$flavor/$module_name
fi
# copy vboxguest (for guest) module symbols which are used by vboxsf km:
if [ "$module_name" = "vboxsf" ]; then
# copy vboxguest (for guest) module symbols which are used by vboxsf and vboxvideo km's:
if [ "$module_name" = "vboxsf" -o \
"$module_name" = "vboxvideo" ] ; then
cp $PWD/modules_build_dir/$flavor/vboxguest/Module.symvers \
$PWD/modules_build_dir/$flavor/$module_name
fi
# build the module for the specific flavor
make -j2 -C %{_prefix}/src/linux-obj/%{_target_cpu}/$flavor %{?linux_make_arch} modules \
M=$PWD/modules_build_dir/$flavor/$module_name
M=$PWD/modules_build_dir/$flavor/$module_name V=1
done
done
@ -597,7 +612,7 @@ export INSTALL_MOD_DIR=extra
export INITRD_IN_POSTTRANS=1
export KMP_NEEDS_MKINITRD=0
#to install modules we use here similar steps like in build phase, go through all the modules :
%if 0%{?suse_version} == 1500
%if 0%{?suse_version} >= 1500
for module_name in vbox{drv,netflt,pci,netadp,guest,sf,video}
%else
for module_name in vbox{drv,netflt,pci,netadp,guest,sf}
@ -712,13 +727,18 @@ install -m 0755 %{SOURCE18} %{buildroot}/sbin/vbox-fix-usb-rules.sh
install -m 0755 %{SOURCE19} %{buildroot}%{_vbox_instdir}/vboxdrv.sh
install -m 0644 %{SOURCE21} %{buildroot}%{_unitdir}/vboxweb-service.service
install -m 0755 %{SOURCE22} %{buildroot}%{_vbox_instdir}/vboxweb-service.sh
# Init script to start virtual boxes during boot
install -m 0644 %{SOURCE23} %{buildroot}%{_unitdir}/vboxautostart.service
ln -s -f %{_sbindir}/service %{buildroot}%{_sbindir}/rcvboxautostart
install -m 0755 %{SOURCE24} %{buildroot}%{_vbox_instdir}/vboxautostart.sh
# Init scripts to start virtualbox during boot
ln -sf %{_unitdir}/vboxdrv.service %{buildroot}%{_unitdir}/multi-user.target.wants/vboxdrv.service
ln -sf %{_unitdir}/vboxadd-service.service %{buildroot}%{_unitdir}/multi-user.target.wants/vboxadd-service.service
ln -sf %{_unitdir}/vboxautostart.service %{buildroot}%{_unitdir}/multi-user.target.wants/vboxautostart.service
# config file for vboxdrv script and vboxweb
# config file for vboxdrv and vboxweb
install -d -m 755 %{buildroot}%{_sysconfdir}/vbox
echo -e "#settings for vboxwebsrn\nVBOXWEB_USER=root" > %{buildroot}%{_sysconfdir}/vbox/vbox.cfg
# config file for vboxautostart
cat > %{buildroot}%{_sysconfdir}/vbox/autostart.cfg << EOF
default_policy = deny
# Create an entry for each user allowed to use autostart
@ -764,11 +784,11 @@ popd
######################################################
echo "entering virtualbox-guest-desktop-icons install section"
######################################################
install -d -m 755 %{buildroot}%{_datadir}/pixmaps/virtalbox
install -d -m 755 %{buildroot}%{_datadir}/pixmaps/virtualbox
pushd src/VBox/Frontends/VirtualBox/images
for icon in os_*.png; do
install -m 644 "$icon" %{buildroot}%{_datadir}/pixmaps/virtalbox/"$icon";
install -m 644 "$icon" %{buildroot}%{_datadir}/pixmaps/virtualbox/"$icon";
done
popd
#
@ -780,7 +800,7 @@ popd
#also some translation files are duplicated
%fdupes %{buildroot}/%{_datadir}/virtualbox/nls
#also some icon files are duplicated
%fdupes %{buildroot}/%{_datadir}/pixmaps/virtalbox
%fdupes %{buildroot}/%{_datadir}/pixmaps/virtualbox
#
#
@ -791,12 +811,13 @@ popd
%pre
getent group vboxusers >/dev/null || groupadd -r vboxusers
%service_add_pre vboxdrv.service
%service_add_pre vboxautostart.service
%pre guest-tools
# Add groups for seamless mode and shared folders:
getent group vboxguest >/dev/null || groupadd -r vboxguest
getent group vboxsf >/dev/null || groupadd -r vboxsf
%if 0%{?suse_version} == 1500
%if 0%{?suse_version} >= 1500
getent group vboxvideo >/dev/null || groupadd -r vboxvideo
%endif
%service_add_pre vboxadd-service.service
@ -816,6 +837,7 @@ getent group vboxvideo >/dev/null || groupadd -r vboxvideo
%set_permissions %{_vbox_instdir}/VBoxNetAdpCtl
%set_permissions %{_vbox_instdir}/VBoxHeadless
%service_add_post vboxdrv.service
%service_add_post vboxautostart.service
# add new autostart stuff to the existing default config, if missing
grep -q VBOXAUTOSTART /etc/default/virtualbox || {
cat >> /etc/default/virtualbox << EOF
@ -859,7 +881,9 @@ VBoxManage extpack install --replace "${EXTPACK}" --accept-license="${ACCEPT}" >
#######################################################
%preun
%stop_on_removal vboxautostart
%stop_on_removal vboxdrv
%service_del_preun vboxautostart.service
%service_del_preun vboxdrv.service
exit 0
@ -881,8 +905,10 @@ exit 0
%postun
/sbin/ldconfig
%restart_on_update vboxdrv
%restart_on_update vboxautostart
# immediately restarting virtualbox may not work. As such wait for the next reboot to restart
export DISABLE_RESTART_ON_UPDATE=yes
%service_del_postun vboxautostart.service
%service_del_postun vboxdrv.service
%postun guest-tools
@ -952,9 +978,13 @@ export DISABLE_RESTART_ON_UPDATE=yes
%dir %{_unitdir}
%dir %{_unitdir}/multi-user.target.wants
/usr/lib/virtualbox/vboxdrv.sh
/usr/lib/virtualbox/vboxautostart.sh
%{_unitdir}/vboxdrv.service
%{_unitdir}/vboxautostart.service
%{_unitdir}/multi-user.target.wants/vboxdrv.service
%{_unitdir}/multi-user.target.wants/vboxautostart.service
%{_sbindir}/rcvboxdrv
%{_sbindir}/rcvboxautostart
/sbin/vboxconfig
%{_vbox_instdir}/VBoxCreateUSBNode.sh
%verify(not mode) %attr(0750,root,vboxusers) %{_vbox_instdir}/VBoxNetNAT
@ -1064,8 +1094,8 @@ export DISABLE_RESTART_ON_UPDATE=yes
%files guest-desktop-icons
%defattr(-,root, root)
%dir %{_datadir}/pixmaps/virtalbox
%{_datadir}/pixmaps/virtalbox/*.png
%dir %{_datadir}/pixmaps/virtualbox
%{_datadir}/pixmaps/virtualbox/*.png
%files vnc
%defattr(-,root, root)