Page 1 of 1

[FIXED]: Solaris 11.1 sru4.6 + VB 4.2.10 = autostart bugs

Posted: 8. Apr 2013, 23:56
by kburtch
I've been trying to get VirtualBox's autostart service working on Solaris 11.1 without success.
The VM I'm trying to start does run when manually launched, and does have autostart entabled:

Code: Select all

vbox@hostname:~$ VBoxManage list -l vms|grep -i auto
Autostart Enabled: on
Autostart Delay: 0
From the log after a reboot:

Code: Select all

[ Apr  8 20:59:59 Stopping because service restarting. ]
[ Apr  8 20:59:59 Invalid use of ":kill" as stop method for transient service. ]
[ Apr  8 21:01:58 Executing start method ("/opt/VirtualBox/smf-vboxautostart.sh start"). ]
Oracle Corporation      SunOS 5.11      11.1    January 2013
Oracle VM VirtualBox Autostart 4.2.10
(C) 2013 Oracle Corporation
All rights reserved.

[ Apr  8 21:01:58 Method "start" exited with status 0. ]
I dug into /opt/VirtualBox/smf-vboxautostart.sh and found a couple things.
First, it loops through all users in the staff group (which I'm not using).

Code: Select all

        for VW_USER in `logins -g staff`
(I'm not sure parsing the output of logins without cut or awk is a great idea, since it includes the username, UID, group, GID, and GECOS fields.)

Wouldn't it make a lot more sense to parse the vboxuser group, since that's the group users have to belong to for some of the functionality anyways?

Code: Select all

vbox@hostname:~$ diff /opt/VirtualBox/smf-vboxautostart.sh.orig /opt/VirtualBox/smf-vboxautostart.sh
54c54
<         for VW_USER in `logins -g staff`
---
>         for VW_USER in `logins -g vboxuser`
Even with the above modification, autostart fails silently when rebooting the system.
So, digging further into /opt/VirtualBox/smf-vboxautostart.sh, I find the command line being called is:

Code: Select all

exec su - "$VW_USER" -c "/opt/VirtualBox/VBoxAutostart --background --start --config \"$VW_CONFIG\" --logrotate \"$VW_ROTATE\" --logsize \"$VW_LOGSIZE\" --loginterval \"$VW_LOGINTERVAL\""
So, since this is being started as the user, I tried running it on the command line with all parameters that would be defined when the script ran:

Code: Select all

vbox@hostname:~$ /opt/VirtualBox/VBoxAutostart --background --start --config /etc/vbox/autostart.cfg --logrotate "" --logsize "" --loginterval ""
VBoxAutostart: error: vbox@hostname:~$ echo $?
2
I'm not sure what exit code 2 means, and didn't spot it skimming through the sources (I'm not a C++ coder, so just looked at the VBoxAutostart.cpp/.h, and a couple other headers).
It also doesn't make sense that the method log shows exit 0.

I decided to try it without passing options with null arguments:

Code: Select all

vbox@hostname:~$ /opt/VirtualBox/VBoxAutostart --background --start --config /etc/vbox/autostart.cfg 
Oracle VM VirtualBox Autostart 4.2.10
(C) 2013 Oracle Corporation 
All rights reserved.

VirtualBox Autostart 4.2.10 r84104 solaris.amd64 (Mar  5 2013 12:03:58) release log
00:00:00.000570 main     Log opened 2013-04-08T19:52:49.841748000Z
00:00:00.000578 main     OS Product: SunOS
00:00:00.000579 main     OS Release: 5.11
00:00:00.000580 main     OS Version: 11.1
00:00:00.000784 main     DMI Product Name: SUN FIRE X4170 M3     
00:00:00.000840 main     DMI Product Version:                       
00:00:00.000845 main     Executable: /opt/VirtualBox/amd64/VBoxAutostart
00:00:00.000846 main     Process ID: 10249
00:00:00.000847 main     Package type: SOLARIS_64BITS_GENERIC
vbox@hostname:~$ ps -ef | grep VB
    vbox 10255     1   0 21:52:50 ?           0:00 /opt/VirtualBox/amd64/VBoxSVC --auto-shutdown
    vbox 10258 10176   0 21:53:01 pts/2       0:00 grep VB
    root   786     1   0 21:01:59 ?           0:00 /opt/VirtualBox/VBoxZoneAccess
    vbox 10253     1   0 21:52:50 ?           0:00 /opt/VirtualBox/amd64/VBoxXPCOMIPCD
    vbox 10251     1   0 21:52:50 ?           0:00 /opt/VirtualBox/VBoxAutostart --background --start --config /etc/vbox/autostart
So, that worked.

After searching for information on the missing options, I came up completely dry. Here's the code that sets them (also in /opt/VirtualBox/smf-vboxautostart.sh):

Code: Select all

# Get svc configuration
VW_CONFIG=`/usr/bin/svcprop -p config/config $SMF_FMRI 2>/dev/null`
 [ $? != 0 ] && VW_CONFIG=
VW_ROTATE=`/usr/bin/svcprop -p config/logrotate $SMF_FMRI 2>/dev/null`
 [ $? != 0 ] && VW_ROTATE=
VW_LOGSIZE=`/usr/bin/svcprop -p config/logsize $SMF_FMRI 2>/dev/null`
 [ $? != 0 ] && VW_LOGSIZE=
VW_LOGINTERVAL=`/usr/bin/svcprop -p config/loginterval $SMF_FMRI 2>/dev/null`
 [ $? != 0 ] && VW_LOGINTERVAL=
Looking at the configurations in the service, I see only config/config exists:

Code: Select all

vbox@hostname:~$ svcprop -p config virtualbox/autostart
config/config astring /etc/vbox/autostart.cfg
vbox@hostname:~$ 
In case someone is curious, here's the content of /etc/vbox/autostart.cfg:

Code: Select all

# Default policy is to deny starting a VM, the other option is "allow".
default_policy = deny
#
vbox = {
        allow = true
        startup_delay = 10
}
kburtch = {
        allow = true
        startup_delay = 10
}
Did I miss something in the docs somewhere, or is something missing from the docs (or code)?
Surely /opt/VirtualBox/VBoxAutostart should be able to handle being passed null arguments to options (since the calling script is coded to pass them).

Re: Solaris 11.1 sru4.6 + VB 4.2.10 = possible autostart bug

Posted: 15. Apr 2013, 20:24
by kburtch
I found/fixed the problem and submitted a ticket:
https://www.virtualbox.org/ticket/11720

To fix, remove "exec" from the loop in smf-vboxautostart.sh and change "staff" to "vboxuser".

It now will start all autostart-enabled VMs for all users in the vboxuser group.