VMware Communities
systame
Contributor
Contributor
Jump to solution

Starting virtual machine with LaunchAgent

I've got the following launchctl .plist file below. When I load it, I get usage output from vmrun. Anyone know what's wrong? Anyone done this?

Reply
0 Kudos
1 Solution

Accepted Solutions
WoodyZ
Immortal
Immortal
Jump to solution

The following is a working example located on my system at: /Users/WKZ/Library/LaunchAgents/com.vmrun.test.plist

<?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></false>
	<key>Label</key>
	<string>com.vmrun.test</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Library/Application Support/VMware Fusion/vmrun</string>
		<string>-T</string>
		<string>fusion</string>
		<string>start</string>
		<string>/Users/WKZ/Documents/Virtual Machines.localized/DSL1.vmwarevm</string>
	</array>
	<key>QueueDirectories</key>
	<array></array>
	<key>RunAtLoad</key>
	<true></true>
	<key>WatchPaths</key>
	<array></array>
</dict>
</plist>

View solution in original post

Reply
0 Kudos
5 Replies
WoodyZ
Immortal
Immortal
Jump to solution

The following is a working example located on my system at: /Users/WKZ/Library/LaunchAgents/com.vmrun.test.plist

<?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></false>
	<key>Label</key>
	<string>com.vmrun.test</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Library/Application Support/VMware Fusion/vmrun</string>
		<string>-T</string>
		<string>fusion</string>
		<string>start</string>
		<string>/Users/WKZ/Documents/Virtual Machines.localized/DSL1.vmwarevm</string>
	</array>
	<key>QueueDirectories</key>
	<array></array>
	<key>RunAtLoad</key>
	<true></true>
	<key>WatchPaths</key>
	<array></array>
</dict>
</plist>

Reply
0 Kudos
WoodyZ
Immortal
Immortal
Jump to solution

BTW... A handy utility to use for things like this is: Lingon

Reply
0 Kudos
systame
Contributor
Contributor
Jump to solution

That did it.

To note for any one else who got frustrated with this.

Main differences between my script and yours:

-- no 'Program' key, just 'ProgramArguments' with vmrun as 1st arg

-- ending the virtual machine name arg with .vmwarevm rather than the full path to .vmx extension

-- no need to encapsulate strings in quotes

Reply
0 Kudos
systame
Contributor
Contributor
Jump to solution

I can now start 2 separate vms manually in terminal using command like 'launchctl load vm.plist'.

But, on login, only the Mac OS vm starts. Get an error showing on the 'Virtual Machine Library' window within Fusion saying the vm is already in use for my Fedora vm. If I try to start it I get the choice to 'Take ownership' but it doesn't work.

Could it be I need to sleep the 2nd LaunchAgent script till the 1st completes?

Reply
0 Kudos
systame
Contributor
Contributor
Jump to solution

After more experimenting trying to get my Fedora VM .plist to load by itself (with the OSXS .plist removed) it still wouldn't start. Got this error in system.log:

Dec 12 10:47:46 www com.apple.launchctl.Aqua[2163]: FusionFedora11: Already loaded.

The job apparently didn't unload at logout.

BUT -- I found a much simpler way to accomplish this. I just opened the 'Accounts' pane in 'System Preferences', clicked on 'Login Items', then dragged and dropped my vm files into it. It works.

Reply
0 Kudos