jump to navigation

VMWare – Simple communication between Host and Guest January 2, 2008

Posted by xk0der in : Programming , 2comments

Recently I’ve been working on a project which required VMWare as one of the component. As part of this project some sort of communication, albeit simple in nature,was required between the host and the guest machine.

Here are two simple commands, one to be run on host and one on the guest, using which you can pass simple information between the host and the guest virtual machine.

(single line command may wrap to next line … please note this)

Host machine commands:

Syntax:
$ vmware-cmd <path-to-machine.vmx> getguestinfo <variable>
$ vmware-cmd <path-to-machine.vmx> setguestinfo <variable> <value>

Example:
$ vmware-cmd /vmware-stuff/Ubuntu.vmx setguestinfo some_counter 12
$ vmware-cmd /vmware-stuff/Ubuntu.vmx getguestinfo some_counter

The first command, above, will set variable ’some_counter’ to value ‘12′ and the second one will fetch the value of ’some_counter’ on/from the virtual machine specified by /vmware-stuff/Ubuntu.vmx

VMWare typically identifies different virtual machines by their configuration files (.vmx)

To set/get info from other machine use the configuration file path of that virtual machine.

The above variables may be accessed on the guest (Virtual machine), in our case Ubuntu.vmx using the commands shown below (see example).

And yes! make sure the Virtual machine is powered on :)
Guest machine commands:

Syntax:
$ vmware-guestd --cmd 'info-set guestinfo.<variable> <value>'
$ vmware-guestd --cmd 'info-get guestinfo.<variable>'

Example:
$ vmware-guestd --cmd 'info-set guestinfo.some_counter 35'
$ vmware-guestd --cmd 'info-get guestinfo.some_counter'

Variables set in Virtual Machine (Guest) may be accessed on Host and vice-versa.

I tested this on VMWare-Server as it is free :) … hopefully and very likely the same is applicable for VMWare-Workstation.

For more hardcore scripting, you may Use Perl-SDK provided by VMWare (On windows you may use COM-SDK).

Please leave comments if you found this info helpful (or even otherwise).

– xk0der

Like this post?