Page 2 of 2

Re: Added possibility to start VMs during system boot

Posted: 28. Sep 2012, 17:36
by Andrew Brehm
ChipMcK wrote:
Andrew Brehm wrote:I also searched this forum.
This forum is for OS X Hosts. The feature was developed for Linux Hosts viewforum.php?f=7 .
There are a number of posts on that forum for the feature.
The feature was developed for all hosts.

And launchctl certainly only exists on Mac OS X.

Re: Added possibility to start VMs during system boot

Posted: 7. Nov 2012, 22:58
by mlcampbe
Check the /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh and see if the execute permissions are set on it or not. I found that it was not set on mine. Once I changed the file to 755 then I was able to manually run:

sudo /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh --start /Users/mikecampbell/tools/vboxautostart.cfg

This started the image that was set with autostart. Have not tried it on a reboot but before I changed the permissions the above command did not run and returned a "command not found" error. After setting the correct permissions it now returns:

VirtualBox Autostart 4.2.4 r81684 darwin.amd64 (Oct 26 2012 19:04:51) release log
00:00:00.000237 main Log opened 2012-11-07T20:57:37.106319000Z
00:00:00.000248 main OS Product: Darwin
00:00:00.000252 main OS Release: 11.4.2
00:00:00.000256 main OS Version: Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64
00:00:00.001173 main DMI Product Name: iMac11,3
00:00:00.001815 main DMI Product Version: 1.0
00:00:00.001829 main Host RAM: 32768MB total, 14748MB available
00:00:00.001831 main Executable: /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart
00:00:00.001832 main Process ID: 84262
00:00:00.001832 main Package type: DARWIN_64BITS_GENERIC

Re: Added possibility to start VMs during system boot

Posted: 13. Nov 2012, 06:28
by kevinyank
Finally got this working on Mountain Lion with VirtualBox 4.2.4. The sample org.virtualbox.vboxautostart.plist file that is provided within the VirtualBox application bundle contains a couple of problematic keys:

Code: Select all

  <key>Disabled</key>
  <true/>
  <key>KeepAlive</key>
  <false/>
The VirtualBox documentation makes a point of instructing you to set the Disabled key to <false/>, but you also need to set KeepAlive to <true/> in order to get launchd to automatically start the service at boot (rather than waiting for some undeclared request to trigger the service launch).

My working org.virtualbox.vboxautostart.plist file is:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Disabled</key>
  <false/>
  <key>KeepAlive</key>
  <true/>
  <key>Label</key>
  <string>org.virtualbox.vboxautostart</string>
  <key>ProgramArguments</key>
  <array>
    <string>/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh</string>
    <string>--start</string>
    <string>/etc/vbox/autostart.cfg</string>
  </array>
</dict>
</plist>
My working /etc/vbox/autostart.cfg file is:

Code: Select all

default_policy = allow
(Although the documentation suggests setting the default_policy to deny and allowing individual users to autostart VMs, I couldn’t get this to work. When my autostart.cfg file was configured that way, the VBoxAutostartDarwin.sh script would output an error stating that the user was not allowed to autostart VMs.)

Re: Added possibility to start VMs during system boot

Posted: 25. Nov 2012, 00:28
by Andrew Brehm
mlcampbe wrote:Check the /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh and see if the execute permissions are set on it or not. I found that it was not set on mine. Once I changed the file to 755 then I was able to manually run:

sudo /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh --start /Users/mikecampbell/tools/vboxautostart.cfg
Thank you. That was (part of) it.

Now I cannot set the autostartdbpath.

Code: Select all

$ sudo vx setproperty autostartdbpath /var/vbox
VBoxManage: error: Cannot set the autostart database path (VERR_NOT_SUPPORTED)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SystemProperties, interface ISystemProperties, callee nsISupports
VBoxManage: error: Context: "COMSETTER(AutostartDatabasePath)(Bstr(a->argv[1]).raw())" at line 871 of file VBoxManageMisc.cpp
Any ideas?

Re: Added possibility to start VMs during system boot

Posted: 23. Dec 2012, 04:14
by Hète
Got exactly the same prob,

it will be very nice if we can get an exemple of config files 8)

Re: Added possibility to start VMs during system boot

Posted: 25. Dec 2012, 02:01
by Sova
Problem was fixed by myself.

first - change mode of file to run by launchd:
sudo chmod +x /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh

second - I got error: 12/25/12 3:23:19.125 AM su[23603]: BAD SU mylogin to mylogin on tty
I fixed it by patching /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostartDarwin.sh file.
I changed from: su ${user} -c "...."
to sudo -u ${user} ...

and last. I added key, and switched off KeepAlive to /Library/LaunchDaemons/org.virtualbox.vboxautostart.plist :
<key>KeepAlive</key>
<false/>
<key>RunAtLoad</key>
<true/>

After that I have Machine running...

Re: Added possibility to start VMs during system boot

Posted: 25. Dec 2012, 02:19
by Sova
Andrew Brehm wrote: Thank you. That was (part of) it.

Now I cannot set the autostartdbpath.

Code: Select all

$ sudo vx setproperty autostartdbpath /var/vbox
VBoxManage: error: Cannot set the autostart database path (VERR_NOT_SUPPORTED)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SystemProperties, interface ISystemProperties, callee nsISupports
VBoxManage: error: Context: "COMSETTER(AutostartDatabasePath)(Bstr(a->argv[1]).raw())" at line 871 of file VBoxManageMisc.cpp
Any ideas?
Are you really sure that you need that?
You need only to run by user (not sudo): VBoxManage modifyvm YourVM --autostart-enabled on
To get YourVM name (not sudo): VBoxManage list vms

Run all this commands by user you have created VM.