2

Let's say I have multiple Citrix XenServer VMs with the same name. Or, the names are garbage, doesn't matter.

From the guest OS on one of those VMs, how can I programatically determine the ID of the VM? I was hoping the UUID of the VM would should as the guest OS's BIOS serial number, but it doesn't. Have looked everywhere, registry, WMI, you name it.

Now, the reason I won't just use the hostname, is that I might have multiple machines with same hostname (e.g. a full lab with copies of VMs).

Using XenServer 5.x and 6.x.

Cheers.

Chalky
  • 1,624
  • 18
  • 20

1 Answers1

1

Ah, you can get the UUID from the guest this way (as I hoped) in Xen Server v6.x: Serial number of the BIOS. For a Windows guest, you can use WMI to query that either locally or remotely. I suspect this ID-as-BIOS-serial was only introduced in Xen Server v5.6.

For earlier versions, you can get the UUID from the guest by running the old client tools. For a Windows guest, the executable is xenstore_client.exe, run that with parameter of 'read vm'. The output of that is a string, and the part after the forward slash is the UUID. Note you could use PSEXEC to remotely execute xenstore_client.exe.

Chalky
  • 1,624
  • 18
  • 20
  • I hope it's not bad form to accept my own answer. I have spent a lot of time researching this and getting it right, I've never seen another answer anywhere. – Chalky Jun 10 '14 at 07:46
  • It seems to work also with VMware and VirtualBox. For a Linux guest, one can use: `dmidecode -s system-uuid` if dmidecode is installed. Note that I'm using the system UUID and not serial number. On VMware both returns comparable values, but on VirtualBox, the serial number is not provided, only the UUID is. – Huygens Feb 05 '15 at 14:13
  • However, this technique fails to work properly when the VM is moved to another hypervisor instance. Once moved, the UUID is different. Therefore I use a combination of UUID, MAC address and hostname to detect if a VM has been cloned or moved. – Huygens Feb 05 '15 at 14:14