Trouble running a virtual machine in the background on osx server

mac-osxmac-osx-servervirtual-machinesvmware-fusion

On a computer running OSX (snow leopard server) with VMWare Fusion installed I'm trying to start a VM via SSH without being directly logged in to the GUI.

Based on looking around I figured the following command should do the trick

vmrun -T fusion start /path/to/VM nogui

However it is returning this error

vmware-vmx[24770] <Warning>: 3891612: (connectAndCheck) Untrusted apps are not allowed to connect to or launch Window Server before login.
vmware-vmx[24770] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.

which makes me think that it's not getting the 'nogui' part of the command or there is something with how OSX is setup that I don't understand.

Best Answer

The "nogui" part is known to be problematic with MOSX because of security parameters that disallow "rogue" apps to start and operate (the untrusted part). To run headless, I've always just killed the GUI application once I've launched the VMs the old fashion way.

You can, however, create a launchd items to circumvent the (un)trust(ed) issue. It will have to run in the right security context and be in /Libary/LaunchAgents and include these parameters.

    <key>LimitLoadToSessionType</key>
    <string>LoginWindow</string>

Here's a good article to review: http://communities.vmware.com/message/1648085 -- the author uses a launchd item without the above parameters, but the VM runs as a specific user, which might be nice. For good info on launchd in general, check out this article: http://www.mactech.com/articles/mactech/Vol.25/25.10/2510MacEnterprise-SnowLeopard-launchdandLunch/index.html