Changes between Version 9 and Version 10 of VboxApps


Ignore:
Timestamp:
Sep 29, 2011, 5:14:01 PM (13 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • VboxApps

    v9 v10  
    22
    33= Running apps in VirtualBox virtual machines =
    4 BOINC's '''vboxwrapper''' program lets you run applications in virtual machines. This eliminates the need to build app versions for different architectures, and provides a stronger security sandbox than is otherwise available.
    5 
    6 To do this, create an application version of plan class "vbox" containing the following files:
    7 
    8  * The VM image (VirtualBox format). Must have the '''copy_file''' attribute. Must have logical name "vm_image.vdi".
    9  * An XML job description file (see below)
    10  * '''vboxwrapper''', compiled for the platform
     4
     5BOINC's '''vboxwrapper''' program lets you run applications in VirtualBox virtual machines.
     6This eliminates the need to build app versions for different architectures,
     7and provides a stronger security sandbox than is otherwise available.
     8
     9== Creating app versions ==
     10
     11You must create app versions for each platform you want to support;
     12the app versions differ only in one file.
     13
     14The application versions for a given platform are of plan class "vbox32"
     15(for 32-bit machines) or "vbox64" (for 64-bit machines),
     16and include the following files:
     17
     18 * The VM image, in VirtualBox format.
     19  * Must have the '''copy_file''' attribute.
     20  * Must have logical name "vm_image.vdi".
     21 * The application executable to be run in the VM image.
     22  If must have a logical name starting with '''shared/'''.
     23 * Other files needed by the application, all with logical names starting with '''shared/'''.
     24 * An XML job description file with logical name '''vbox_job.xml''' (see below)
     25 * '''vboxwrapper''', compiled for the platform.
     26  These executables can be downloaded from the BOINC site (see below).
    1127
    1228Include '''<dont_throttle/>''' in the version.xml file; VirtualBox does its own CPU throttling.
    1329
    14 == Job description file ==
    15 '''vboxwrapper''' takes an input file '''vbox_job.xml''' with the following structure:
     30Typically you can use the same VM image for multiple applications.
     31This reduces network traffic and client disk usage.
     32
     33The bitness of the VboxWrapper and VM image must match which plan class.
     34A 32-bit wrapper cannot use VirtualBox on a 64-bit machine.
     35
     36=== The job description file ===
     37
     38The job description file has logical name '''vbox_job.xml'''
     39(its physical name should include a version number and other info).
     40It has following structure:
    1641
    1742{{{
     
    2651
    2752 '''os_name''':: the name of the guest OS, e.g. "Linux26" or "Linux26_64".
     53   WHAT ARE THE OTHER POSSIBILITIES?
    2854
    2955 '''memory_size_mb''':: the amount of physical memory allocated to the VM, in megabytes.
    3056
    31  '''enable_network_access''':: if present, allow application in the VM to do network access
    32 
    33  '''enabled_shared_directory''':: if present, use a directory that is shared between the host OS and the guest OS.  Must be set if your application has input or output files.
     57 '''enable_network_access''':: if present, allow the VM to do network access.
     58
     59 '''enabled_shared_directory''':: if present, create a directory that is shared
     60   between the host OS and the guest OS.
     61   Must be set if your application has input or output files.
    3462
    3563== Requirements of the VM ==
    36 The VM image, when booted, must run the application. This is typically done using a script in /etc.
    37 
    38 When the application is finished, it must shut down the VM (e.g., by running '''shutdown''' on Linux).
    39 
    40 If the applications has input or output files, the VM must contain the VirtualBox "guest additions", and it must mount the shared directory using
    41 
    42 {{{
    43 mount -t vboxsf share ~/host
    44 }}}
    45 where "~/host" is the path where the shared directory is to be mounted. Typically it will then cd into that directory to run the application.
    46 
    47 [[Image(vmbootprocess.png)]]
     64
     65The VM, when booted, must do the following:
     66
     67 * If the applications has input or output files, mount the shared directory using
     68
     69{{{
     70mount -t vboxsf share ~/share
     71}}}
     72 where "~/share" is the path where the shared directory is to be mounted.
     73 In this case the VM must contain the VirtualBox "guest additions". EXPLAIN
     74
     75 * Run the application.
     76
     77 * When the application is finished, shut down the VM
     78  (e.g., by running '''shutdown''' on Linux).
     79
     80These steps are typically done by a '''startup script''' in the VM image.
     81An example startup script is given below.
     82This script runs the application by doing the following:
     83 * cd into the shared directory
     84 * execute '''boinc_app''', and wait for it to exit.
     85
     86Using this script,
     87your application executable must have logical name '''share/boinc_app'''.
     88It may be a compiled program or a script that runs other programs.
     89
     90== Creating jobs for VM apps ==
     91
     92The input and output files of a VM app must
     93
     94 * Have logical names starting with '''shared/'''.
     95 * Have the '''copy_file''' attribute
     96
     97This causes the BOINC client to copy them to and from the '''slot/x/shared/''' directory.
     98
     99== How it works: example ==
     100
     101Using the example startup script, the steps in running a vboxwrapper app are:
     102
     103 1. BOINC client
     104  * Create slot directory, say slot/0
     105  * Create '''slot/0/shared''', and copy input files there
     106  * Execute '''vboxwrapper''' in the slot directory
     107 1. vboxwrapper
     108  * Create and run virtual machine
     109 1. Virtual machine
     110  * Startup script
     111   * mounts '''shared''' directory
     112   * cd into shared directory
     113   * execute boinc_app
     114   * when boinc_app exits, shut down virtual machine
     115 1. vboxwrapper
     116  * delete virtual machine
     117  * call boinc_finish()
     118 1. BOINC client
     119  * copy output files from slot/0/shared to project directory
     120
     121== Example startup script ==
     122
     123The example startup script follows.
     124You can deploy it by appending to '''~root/.bashrc'''.
     125{{{
     126echo --- BOINC VM starting
     127sleep 5
     128}}}
     129
     130The "sleep 5" gives you time to break into a console session via CTRL-C
     131if you need to make changes to the VM in the future.
     132
     133{{{
     134echo --- Mounting shared directory
     135mount -t vboxsf shared /root/shared
     136if [ $? -ne 0 ]; then
     137    echo --- Failed to mount shared directory
     138    sleep 5
     139    shutdown -hP 0
     140fi
     141
     142echo -- Launching boinc_app
     143if [ -f ~/shared/boinc_app ]; then
     144    cd ~/shared
     145    bash ./boinc_app
     146else
     147    echo --- Failed to launch script
     148    sleep 5
     149fi
     150shutdown -hP 0
     151}}}
     152
     153== Creating VM images ==
     154
     155The easiest way to make a Linux VM is to install the network install of Debian within the VM.
     156You can find the netinst images [http://www.debian.org/distrib/netinst here].
     157
     158Advantages:
     159 * Small install size
     160 * !VirtualBox guest additions installed by default
     161
     162=== Role Selection ===
     163
     164During install you'll be asked what role should this Linux machine be configured for.
     165Make sure all roles are unselected before continuing.
     166
     167=== Updating Grub ===
     168
     169If you want to speed up the boot process,
     170change the default timeout for grub by modifing /etc/default/grub:
     171{{{
     172GRUB_TIMEOUT = 0
     173}}}
     174
     175After saving the update run:
     176{{{
     177update-grub
     178}}}
     179
     180=== Updating Inittab ===
     181
     182To configure Linux for automatic login you'll need to install
     183a different terminal handler.
     184mingetty works well for our purposes.
     185
     186To install mingetty:
     187{{{
     188root@boinc-vm-image:/etc/default# apt-get install mingetty
     189}}}
     190
     191Next you'll need to change the terminal handler assigned to the first virtual terminal.
     192Change line:
     193{{{
     1941:2345:respawn:/sbin/getty 38400 tty1
     195}}}
     196
     197To:
     198{{{
     1991:2345:respawn:/sbin/mingetty --autologin root --noclear tty1
     200}}}
     201
     202== Precompiled vboxwrapper ==
     203=== Windows ===
     204x86: [http://boinc.berkeley.edu/dl/vboxwrapper_6.20_windows_intelx86.exe.gz vboxwrapper_6.20_windows_intelx86.exe.gz]
     205
     206x64: [http://boinc.berkeley.edu/dl/vboxwrapper_6.20_windows_x86_64.exe.gz vboxwrapper_6.20_windows_x86_64.exe.gz]
     207
     208=== Mac ===
     209TBD
     210=== Linux ===
     211TBD
     212
     213== Premade Linux VM Images ==
     214
     215SAY SOMETHING ABOUT THESE
     216
     217x86: [http://boinc.berkeley.edu/dl/vmimagex86.vdi.gz vmimagex86.vdi.gz]
     218
     219x64: [http://boinc.berkeley.edu/dl/vmimagex64.vdi.gz vmimagex64.vdi.gz]
     220