VMware Communities
supremedalek
Contributor
Contributor

Booting/suspending a vm in OSX: wait for who?

I installed Fusion 2 in a Snow Leopard box. It works fine but now I would like to be able to have aVM start/suspend when the computer starts up or shuts down/reboots. At first I tried what was suggested in and that seemed to be enough to just start the vm up. But, how about suspending it? Next attempt was to go to /Library/StartupItems and create a startup entry for the VM (called VMtest). Could anyone give me some pointers?Here is the script I wrote to start/suspend the vm:

#!/bin/sh

#

  1. /Library/StartupItems/VMtest/VMtest

#

  1. Suppress the annoying "$1: unbound variable" error when no option

  2. was given

if ; then

echo "Usage: $0 start "

exit 1

fi

  1. Source the common setup functions for startup scripts

test -r /etc/rc.common || exit 1

. /etc/rc.common

SCRIPT="/Library/Application Support/VMware Fusion/vmrun"

VMACHINE="/Users/mainstreetsoftworks/vms/VMtest/vmtest.vmx"

StartService ()

{

ConsoleMessage "Starting VMtest"

while http:// ! -e /var/run/vmnet-bridge-vmnet0.pid ; do

sleep 1

done

$SCRIPT start $VMACHINE > /dev/null 2>&1

}

StopService ()

{

ConsoleMessage "Stopping (Ok, pausing) VMtest"

$SCRIPT suspend $VMACHINE > /dev/null 2>&1

}

RestartService ()

{

ConsoleMessage "TBA"

  1. $SCRIPT restart > /dev/null 2>&1

}

if test -x $SCRIPT ; then

RunService "$1"

else

ConsoleMessage "Could not find VMware!"

fi

And here is so far what I have in StartupParameters.plist

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Description</key>

<string>VMtest</string>

<key>OrderPreference</key>

<string>Last</string>

<key>Provides</key>

<array>

<string>VMtest</string>

</array>

</dict>

</plist>

Could anyone show me what I am missing?

0 Kudos
1 Reply
WoodyZ
Immortal
Immortal

You can configure Fusion to suspend running Virtual Machine's without prompting and if Fusion is running when the Host is shutdown then Fusion should automatically suspend any running Virtual Machines and close.

VMware Fusion (menu bar) > Preferences... > General > When closing a virtual machine: > uncheck "Confirm before closing".

0 Kudos