VMware

VMware GSX Server 2.5.2


Features | Documentation | Knowledge Base | Discussion Forums

previous Prev   Contents   Last   Next next

About the VMware Guest Operating System Service

About the VMware Guest Operating System Service

When you install VMware Tools in a virtual machine, the VMware guest operating system service is one of the primary components installed. The guest service can do the following:

  • Synchronize the time of the guest operating system with the time in the host operating system.

  • Run scripts in a virtual machine when the power state changes. See Executing Scripts When the Virtual Machine's Power State Changes.

  • Execute commands in the virtual machine when you shut down or restart the guest operating system.

  • Send a heartbeat to GSX Server so that it knows the guest operating system is running. A gauge for this heartbeat appears in the VMware Management Interface. For more information, see Using the Status Monitor.

  • Pass information from the host operating system to the guest operating system.

  • Pass information between the guest operating system and a VMware Scripting API script.

The guest service starts automatically when you boot the guest operating system.

In a Windows guest, the guest service program file is called VMwareService.exe. Help is available by right-clicking the VMware Tools icon in the system tray and choosing Help.

In a Linux guest, the guest service is called vmware-guestd. To display help about the guest service, including a list of all options, use the following command:
/etc/vmware/vmware-guestd --help

Synchronizing the Time in the Guest with the Host Operating System

Synchronizing the Time in the Guest with the Host Operating System

The guest service can synchronize the date and time in the guest operating system with the time in the host operating system once every minute. To enable time synchronization for a Windows guest, see Setting Options with VMware Tools. To enable time synchronization for a Linux or FreeBSD guest, see Setting Options with VMware Tools. To enable time synchronization for a NetWare guest, see Setting Options with VMware Tools.

If you want to change the time synchronization setting without using the VMware Tools control panel, you can set the configuration file option tools.syncTime to TRUE or FALSE to enable or disable time synchronization.

In addition, the guest service can synchronize the date and time in the guest with the time in the host in response to various system events; for example, when you resume from disk. You can disable this in the configuration file by setting
time.synchronize.resume.disk = FALSE

Executing Commands After You Power Off or Reset a Virtual Machine

Executing Commands After You Power Off or Reset a Virtual Machine

In a Linux guest, you can have the guest service execute specific commands when you shut down or restart the guest operating system. This is in addition to any script that you may have specified to run when you shut down the guest operating system.

In order to execute these commands, you need to modify /etc/vmware-tools/tools.conf. The commands are:

halt-command = <command>

(where <command> is the command to execute when you shut down the guest operating system)

reboot-command = <command>

(where <command> is the command to execute when you restart the guest operating system)

Passing a String from the Host Operating System to the Guest Operating System

Passing a String from the Host Operating System to the Guest Operating System

With GSX Server and knowledge of a scripting language like Perl or NetShell (in a Windows 2000 guest operating system), you can pass a string from your virtual machine's configuration file in the host operating system to the guest operating system when you use the configuration file to launch a virtual machine.

What you pass to the guest operating system is up to you. This should only be done if you have a good understanding of a scripting language and know how to modify system startup scripts.

There are two ways of passing strings to a virtual machine's guest operating system:

  1. You can place a string in the virtual machine's configuration file by setting the string to the machine.id parameter.

    For example, you can set this string:
    machine.id = "Hello World."

  2. You pass the string to the guest operating system from the command line when you launch the virtual machine. See example 1 below.

You could pass items like the Windows system ID (SID), a machine name or an IP address. Inside the guest operating system startup script, you have the guest service retrieve this string, which can then be used in another script you write and include in the startup script to set your virtual machine's system ID, machine name or IP address.

This way, you can make copies of the same configuration file, add a different string to each (either in the configuration file itself or at the command line), then use these variations of the same configuration file to launch the same virtual disk in nonpersistent mode multiple times in a training or testing environment, for example.

This is what portions of two configuration files that point to the same virtual disk might look like. Each configuration file contains its own unique string set for the machine.id parameter.

<config_file_1>.vmx contains:

ide0:0.present = TRUE
ide0:0.fileName = "my_common_virtual_hard_drive.vmdk"
machine.id = "the_string_for_my_first_vm"

<config_file_2>.vmx contains:

ide0:0.present = TRUE
ide0:0.fileName = "my_common_virtual_hard_drive.vmdk"
machine.id = "the_string_for_my_second_vm"

Passing a string is also useful in situations where you want to deploy virtual machines on a network using a common configuration file, while providing each machine with its own unique identity. In this case, you specify the string at the command line (you need to launch each virtual machine with the vmware -s command) when you launch each virtual machine using this configuration file. See example 1 below.

Each virtual machine disk file must be copied into its own directory if it shares its file name with another virtual machine disk file.

In the following example, we use a Windows host and guest to illustrate how you can use the guest service to retrieve a string containing what will become the virtual machine's machine name and IP address. We use W2K-VM as the machine name and 148.30.16.24 as the IP address.

  1. Define a string. Do this by either:

    • Adding the following line to your virtual machine's configuration file:
      machine.id = "W2K-VM 148.30.16.24"
      then launching a virtual machine using this configuration file.
    • Launching a virtual machine from the command line. At the command line, type:
      C:\Program Files\VMware\Programs\vmware -s 'machine.id=W2K-VM 148.30.16.24' \
      C:\Documents and Settings\<username>\Local Settings\My Documents\My Virtual Machines\win2000\win2000.vmx

      Note: The above command must be written on one line with the backslash ("\") at the end of the first line removed.

      Note: On a Linux host, if a virtual machine ID is specified in a configuration file, and you use that file to launch a virtual machine, but you also specify a machine ID on the command line, the machine ID passed on the command line takes precedence and is passed to the guest operating system.

  2. Retrieve the string in the virtual machine. In a Windows guest, the command to retrieve the string is
    VMwareService --cmd machine.id.get

    Note: In your Linux guest operating system's startup script, before the network startup section, add the following command:
    /etc/vmware/vmware-guestd --cmd 'machine.id.get'

You need to further customize this startup script so it uses the string the guest service retrieved during startup to set the virtual machine's network name to W2K-VM and its IP address to 148.30.16.24. This should be located in the script before the network services are started. If you're using a Windows 2000 guest operating system, for example, you can call the NetShell utility (netsh) and pass it the contents of the string, which then uses the string accordingly (that is, it can set a new IP address for the virtual machine, if that is what was passed in the string originally).

From your host operating system, you can prevent a string from being passed to the guest operating system via the guest service. To do this, set the following line in your virtual machine's configuration file.

isolation.tools.machine.id.get.disable = TRUE

Passing Information Between the Guest Operating System and a VMware Scripting API Script

Passing Information Between the Guest Operating System and a VMware Scripting API Script

When the guest operating system is running inside a virtual machine, the VMware guest operating system service allows you to pass information from a VMware Scripting API script you created (that is running in another host machine) to the guest operating system and from the guest operating system to a script.

For more information, visit the VMware Web site at www.vmware.com/support/developer/.

previous Prev   Contents   Last   Next next