Monday, February 21, 2011

VirtualBox SMF

/lib/svc/method/vboxheadless:

#!/bin/sh
# Customise this file to start and stop your application as necessary.

. /lib/svc/share/smf_include.sh


    getproparg() {

            val=`svcprop -p $1 $SMF_FMRI`

            [ -n "$val" ] && echo $val

    }

VM=`getproparg vbox/VM`

    if [ -z $SMF_FMRI ]; then

            echo "Error: SMF framework variables are not initialized"

            exit $SMF_EXIT_ERR

    fi


case "$1" in
  'start') /opt/VirtualBox/VBoxHeadless -s $VM  &
  ;;
  'stop') /opt/VirtualBox/VBoxManage controlvm $VM savestate
  ;;
  'refresh') /opt/VirtualBox/VBoxManage controlvm $VM reset
  ;;
  *) echo "Usage: $0 { start | stop | refresh }"
  exit 1
  ;;
esac

exit $SMF_EXIT_OK


/var/svc/manifest/application/vboxheadless.xml:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<service_bundle type='manifest' name='vboxheadless'>

<service name='application/vboxheadless' type='service' version='1'>


<method_context>
  <method_credential user='root' group='root' />
</method_context>


<exec_method type='method' name='start'
     exec='/lib/svc/method/vboxheadless start'
     timeout_seconds="60" />

<exec_method type='method' name='stop'
     exec='/lib/svc/method/vboxheadless stop'
     timeout_seconds="60" />

<exec_method type='method' name='refresh'
     exec='/lib/svc/method/vboxheadless refresh'
     timeout_seconds="60" />
<property_group name="startd" type="framework">
<propval name="duration" type="astring" value="transient"/>
</property_group>

<instance name='w7' enabled='true'>
<property_group name='vbox' type='application'>
<propval name='VM' type='astring'
                        value='w7' />
</property_group>
</instance>

<stability value='Unstable' />

<template>
   <common_name>
      <loctext xml:lang='C'>VirtualBox Headless</loctext>
  </common_name>
  <documentation>
      <manpage title='VBoxManage' section='1m' manpath='/usr/share/man' />
      <doc_link name='homepage' uri='http://sgpit.com/smf' />
  </documentation>
</template>

</service>
</service_bundle>


Running VirtualBox in a zone under Solaris 11

When trying to run VirtualBox in a zone under Solaris 11 make sure fonts are installed in the zone or else VirtualBox will core dump.  Package list:

FSWfontconfig-devel-docs                      0.5.11-0.130    known      --o--
print/filter/ghostscript/fonts/gnu-gs-fonts-other 6.0-0.151.0.1   known      -----
print/filter/ghostscript/fonts/gnu-gs-fonts-std 6.0-0.151.0.1   known      -----
system/font/daewoo-misc                       1.0.1-0.151     known      -----
system/font/gnome-fonts                       0.5.11-0.151.0.1 installed  -----
system/font/isas-misc                         1.0.1-0.151     known      -----
system/font/jis-misc                          1.0.1-0.151     known      -----
system/font/misc-ethiopic                     1.0.1-0.151     known      -----
system/font/misc-meltho                       1.0.1-0.151     known      -----
system/font/truetype/arabeyes                 0.5.11-0.151.0.1 known      -----
system/font/truetype/arphic-ukai              0.5.11-0.151.0.1 known      -----
system/font/truetype/arphic-uming             0.5.11-0.151.0.1 known      -----
system/font/truetype/bh-luxi                  1.0.1-0.151     known      -----
system/font/truetype/bitstream-vera           1.10-0.151      known      -----
system/font/truetype/bpg-georgian             0.5.11-0.151.0.1 known      -----
system/font/truetype/dejavu                   2.31-0.151      known      -----
system/font/truetype/fonts-core               1.1-0.151.0.1   installed  -----
system/font/truetype/gentium                  0.5.11-0.151.0.1 known      -----
system/font/truetype/google-droid             0.2010.2.24-0.151 known      -----
system/font/truetype/hanyang-ko               0.5.11-0.151.0.1 known      -----
system/font/truetype/hanyang-ko-core          0.5.11-0.151.0.1 known      -----
system/font/truetype/indic-fonts-core         0.5.11-0.151.0.1 known      -----
system/font/truetype/ipafont                  0.5.11-0.151.0.1 known      -----
system/font/truetype/ipafont-mincho           0.5.11-0.151.0.1 known      -----
system/font/truetype/kacst                    0.5.11-0.151.0.1 known      -----
system/font/truetype/liberation               1.4-0.151       known      -----
system/font/truetype/lohit                    0.5.11-0.151.0.1 known      -----
system/font/truetype/mgopen                   0.5.11-0.151.0.1 known      -----
system/font/truetype/sil                      0.5.11-0.151.0.1 known      -----
system/font/truetype/thai-scalable            0.5.11-0.151.0.1 known      -----
system/font/truetype/ttf-fonts-core           1.1-1           known      --r--
system/font/truetype/unfonts-ko-core          0.5.11-0.151.0.1 known      -----
system/font/truetype/unfonts-ko-extra         0.5.11-0.151.0.1 known      -----
system/font/truetype/unifont                  0.5.11-0.151.0.1 known      -----
system/font/truetype/wqy-zenhei               0.5.11-0.151.0.1 known      -----
system/font/xorg/cyrillic                     1.0.2-0.151     known      -----
system/font/xorg/iso8859-1                    7.5-0.151       installed  -----
system/font/xorg/iso8859-10                   7.5-0.151       known      -----
system/font/xorg/iso8859-11                   7.5-0.151       known      -----
system/font/xorg/iso8859-13                   7.5-0.151       known      -----
system/font/xorg/iso8859-14                   7.5-0.151       known      -----
system/font/xorg/iso8859-15                   7.5-0.151       known      -----
system/font/xorg/iso8859-16                   7.5-0.151       known      -----
system/font/xorg/iso8859-2                    7.5-0.151       known      -----
system/font/xorg/iso8859-3                    7.5-0.151       known      -----
system/font/xorg/iso8859-4                    7.5-0.151       known      -----
system/font/xorg/iso8859-5                    7.5-0.151       known      -----
system/font/xorg/iso8859-7                    7.5-0.151       known      -----
system/font/xorg/iso8859-8                    7.5-0.151       known      -----
system/font/xorg/iso8859-9                    7.5-0.151       known      -----
system/font/xorg/xorg-core                    7.5-0.151       known      -----
system/library/fontconfig                     2.8.0-0.151     installed  -----
system/library/fontconfig/documentation       2.8.0-0.144     known      --r--
x11/font-utilities                            7.5-0.151       installed  -----
x11/library/libfontenc                        1.0.5-0.151     installed  -----
x11/library/libxfont                          1.4.1-0.151     installed  -----
x11/xfontsel                                  1.0.2-0.151     installed  -----