I finally had some extra time this weekend to sit down and finish an SMF manifest to support headless VirtualBox guests. Overall, I am quite pleased with the result:
The source for the service manifest and method script is available here. These files should be copied to /var/svc/manifest/application/virtualbox/ and /lib/svc/method/, respectively.
I have also created an IPS package for OpenSolaris users; if you are interested in installing the package, you will need to add my private IPS repository first:
% pfexec pkg set-authority -O http://arf.ubound.org/pkg/ arf.ubound.orgOnce the repository has been added, you can then install the
virtualbox-headless package:% pfexec pkg install virtualbox-headlessOnce the files are in place, you may need to import the manifest manually; since there are no default instances,
svc:/system/manifest-import:default has a tendency to skip the manifest during a bulk import (this issue seems to affect the IPS package as well):% pfexec svccfg import /var/svc/manifest/application/virtualbox/virtualbox-headless.xmlOnce you have imported the manifest, it is time to add each guest you wish to manage. I have written the manifest such that a guest is identified by the name of the instance itself. For example, if I wanted to add a guest named
qnx641, I would issue the following:% pfexec svccfg -s virtualbox/headless add qnx641You may then enable the instance via
svcadm(1M):% pfexec svcadm enable virtualbox/headless:qnx641Two properties are provided to control the start and stop behavior of each instance:
- The
vbox/start_typeproperty corresponds to the--typeargument passed toVBoxManage startvm; by default, it is set toheadless. Possible values are:gui,sdl,vrdp, andheadless, however only the last two really make any sense when used with SMF. - The
vbox/stop_methodproperty corresponds to the argument passed toVBoxManage controlvmwhich is responsible for stopping the instance; by default it is set tosavestate. Possible values are:pause,resume,reset,poweroff,savestate,acpipowerbutton, andacpisleepbutton
% pfexec svccfg -s virtualbox/headless:qnx641Since this is a "wait" model service, it does not properly support a user shutting down the guest outside of
svc:/application/virtualbox/headless:qnx641> addpg vbox application
svc:/application/virtualbox/headless:qnx641> setprop vbox/stop_method = astring: "poweroff"
^D
svcadm(1M) invocations; the service will continue to report its status as online. In this case, a simple disable or restart will resolve the problem.Enjoy!

Sweet. I wrote an init.d script for that but this is better. Thanks for the good work.
ReplyDeleteproposal for an improvement:
ReplyDeletechange
74 <propval name='duration' type='astring' value='transient'/>
to
74 <propval name='duration' type='astring' value='child'/>
and use
start)
/usr/bin/VBoxHeadless --startvm "$2" --vrdp \
`/usr/bin/svcprop -c -p vbox/start_type $SMF_FMRI`
as startmethod. major advantage: the process will be observed and automatically restarted which leads to a proper shutdown of the virtualmachine, when using acpipowerbutton. i've describe the problem of shutdown here. the possible options for starting the virtualmachine will change to on|off|config. i can send you the changed files if you are interested.
Is it possible to parameterize the user which runs the VirtualBox VM? I just modified the manifest for now... but it'd be nice to do this more cleanly.
ReplyDeleteAll links to the files are dead.
ReplyDeleteAny chance of these files making a comeback? I'd love to compare your implementation to the one posted here http://adumont.serveblog.net/2009/07/21/virtualbox-smf/
ReplyDeleteYou can find the files here...
ReplyDeletehttp://arf.ubound.org/repos/opensolaris/specfiles/file/7a0e006040a4
Scroll down to the bottom and you'll see `virtualbox-headless.spec` and `virtualbox-headless.xml`
Andy