VMware

VMware ESX Server 2.0

Features | Documentation | Knowledge Base | Discussion Forums

previous Prev   Contents   Last   Next next

Passing a String from the Service Console to the Guest Operating System

Passing a String from the Service Console to the Guest Operating System

With ESX 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 to the guest operating system when you use the configuration file to launch a virtual machine. This string is known as machine.id. The content of the string you pass to the guest operating system is up to you.

For additional details and sample scripts, including information on passing messages both ways between the service console and a guest, see the VMware Scripting API documentation at www.vmware.com/support/developer/scripting-API/doc/Scripting_API.pdf.

You should use this feature only if you have a good understanding of a scripting language and know how to modify system startup scripts.

Example of Passing a String from the Service Console to the Guest

Example of Passing a String from the Service Console to the Guest

If you use multiple configuration files that point to the same virtual disk, each configuration file can contain its own unique machine.id line.

<config_file_1>.vmx contains:

scsi0:1.present = TRUE
scsi0:1.name = "my_common_virtual_hard_drive.dsk"
scsi0:1.mode = "persistent"
machine.id = "the_id_for_my_first_vm"

<config_file_2>.vmx contains:

scsi0:1.present = TRUE
scsi0:1.name = "my_common_virtual_hard_drive.dsk"
scsi0:1.mode = "persistent"
machine.id = "the_id_for_my_second_vm"

Using machine.id, you may pass such strings as the Windows system ID (SID), a machine name or an IP address. In the guest operating system startup script, you may then have the guest service retrieve this string, which can then be used by your script to set your virtual machine's system ID, machine name or IP address.

In the following example, we use a Linux guest to illustrate how you can use the guest service to retrieve a string containing what becomes the virtual machine's machine name and IP address. We use RedHat62VM as the machine name and 148.30.16.24 as the IP address.

  1. Define the machine.id string. Define the following option in your virtual machine's configuration file (as described in Modifying the Configuration File Directly (Advanced Users Only)):
    machine.id = "RedHat62VM 148.30.16.24"

    Then launch a virtual machine using this configuration file.

  2. Retrieve the machine.id string in the virtual machine. In your system startup script, before the network startup section, add the following command:
    /etc/vmware/vmware-guestd --cmd 'machine.id.get'

    Note: in a Windows guest, the command to retrieve the string is
    VMwareService --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 RedHat62VM 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 it can then use appropriately (that is, it can set a new IP address for the virtual machine, if that is what was passed in the string originally).

From the service console, you can prevent the service console from passing a string 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

previous Prev   Contents   Last   Next next