OS X, Fusion, command line, VMs as daemons…

somewhat random string of notes created while exploring options to run VMware Fusion VMs on system boot (prior to user login).  ie., looking at ways to start the VMs from a system level daemon… launchd, continuously running, independent of user logins.

* don’t want to leave this as root… need to create a service account for starting/running the VMs… and allow specific users to SU to that service if/when they need to use the Fusion app for gui interaction with the running VM(s).

… resume this later …

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

start & stop VMs with command line (or script)

  • OS X 10.8.2 Mountain Lion
  • VMware Fusion 5.0.2
  • 2012 MacBook Pro Retina 13″, 2.5Ghz i5, 8GB Ram

some command line options for vmrun:

sudo su

  • if vmrun is executed as root, the resulting PID will belong to root.  if a user uses the desktop gui to launch “VMware Fusion.app”, they will not be able to interact with the VM… and attempting to launch it from the GUI Virtual Machine Library will display an error (the executing PID will be unaffected).
  • if vmrum is executed as a user, the resulting PID will belong to that user.  if the same user then used the desktop guy to launch “VMware Fusion.app”, Fusion will immediately create a GUI display for the running VM(s).  Although the VM was launched from the command line as “nogui”, starting Fusion effectively converted the VM to “gui” mode.  Any attempt to quit/close the Fusion GUI will result in the closure/shutdown of the running VM(s).
  • if vmrun is executed as root, and then “/Applications/VMware\ Fusion.app/Contents/MacOS/VMware\ Fusion” is also executed as root… this will result in a desktop GUI instance of Fusion with a connection to the VMs… ie., converts the VM from “nogui” to “gui”.  Closing the Fusion app via it’s menu options will shutdown the VM… however, using the Activity Monitor “Quit Process” function seems to leave the VM running just fine.
  • follow up by testing with a “service account” instead of “sudo su”.
  • and verify the VM remains functional with remote login/tests to the VM(s).

So…

  • to start a VM in “headless” mode… use the command line “nogui” option.
  • to make a “gui” connection to the VM, launch the Fusion app using the same user.
  • to resume “headless” mode, close Fusion gui with Activity Monitor “Quit Process”.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • /Applications/VMware Fusion.app/Contents/Library/vmrun
  • vmrun -T fusion <path to VM> nogui
  • vmrun -T fusion list

…/vmrun -T fusion start …/[vmname].vmwarevm/[vmname].vmx nogui

/Applications/VMware\ Fusion.app/Contents/Library/vmrun -T fusion start $HOME/VMwareVMs/TestImage.vmwarevm/TestImage.vmx nogui

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

…/vmrun -T fusion list

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

…/vmrun -T fusion stop …/[vmname].vmwarevm/[vmname].vmx soft

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To see ALL the daemons currently running, you need to type:

sudo launchctl list

And then you can remove it, for example:

sudo launchctl remove com.sassafras.KeyAccess.daemon

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GUI utility to view/edit agents & daemons.

Lingon 2.1.1 by Peter Borg.  Displays existing items. Edits plist files.  Creates the plist file when creating a new agent.

note: Newer versions of the app are only available from the Mac App Store and (due to GateKeeper / app rules) no longer have the ability to work on system agents/daemons.  The App Store version is limited to the current log’d in user only.  But the older 2.1.1 (2008-12-18) still works under Mountain Lion OS X 10.8.2 and is able to create or edit new agents and daemons.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

d

d

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s