Contents

Previous Next

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. You should pass a string only 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 can 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 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 filename with another virtual machine disk file.
The following example uses a Windows host and guest to illustrate how you can use the service to retrieve a string containing what will become the virtual machine's machine name and IP address. In this example, W2K-VM is the machine name and 148.30.16.24 is 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\VMware GSX Server\vmware -s 'machine.id=W2K-VM 148.30.16.24' C:\Virtual Machines\win2000\win2000.vmx"
  • Note: Write the above command on one line.
    Note: On a Linux host, the machine ID passed on the command line takes precedence and is passed to the guest operating system if the following conditions are met:
  • A virtual machine ID is specified in a configuration file.
  • You use that file to launch a virtual machine.
  • You also specify a machine ID on the command line.
  • 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, add the following command before the network startup section:
    /etc/vmware/vmware-guestd --cmd 'machine.id.get'
    You need to further customize this startup script so it uses the string the 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 string 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 service. To do this, set the following line in your virtual machine's configuration file.
    isolation.tools.getMachineID.disable = TRUE


    Previous Next