I guess I never blogged about the VMWare solution to this. I wanted a node to detect if it was a VMWare guest, and if it was, to register the name of it’s host as an iClassify attribute. Originally the solution to know what VMWare server host a guest was on was to put it in it’s hostname when you created the node, like ‘vm03-somecrap’. That just sucked. With the information in iclassify, it was easy to write a ruby script to give me a list of hosts and their guests. And that worked alright. I’d run a script on the host against each guest something like:
#!/bin/bash VMWARECMD=/usr/bin/vmware-cmd # vmware config files returned by 'vmware-cmd -l' often have spaces, by default bash for treats spaces as a field seperator IFS=$'\n' if [ "$1" == "" ]; then echo $0: requires vmware host hostname as an argument exit 1 fi for config in `$VMWARECMD -l` ; do $VMWARECMD "$config" setguestinfo host $1 done
Which one could then read on the guest if the vmware-guest tools where installed with:
/usr/sbin/vmware-guestd --cmd 'info-get guestinfo.host'
Finding the syntax for vmware-guestd took forever. I don’t know why I didn’t blog that.
I want to do something similar for KVM. I use libvirt, so the first step was looking at the configuration file options for libvirt and the command line options for qemu to see if anything nice matched up. I played a bit with the serial pipe option, which you can use even though it’s not listed on the libvirt page because I saw it in the source, but I couldn’t get it to do much. I had thought about having a daemon return hostname or such to the FIFO whenever queried with a \n or something.
I figured I could find something to pass to the kernel cmdline in an append option, but I really don’t want to have to template the libvirt template files just to stuff a hostname in there.
I really want something I can pass to SMBIOS that I can pull with dmidecode on the guest. I started digging into the LinuxBIOS/coreboot code that comes with the ubuntu kvm source package and in bios/rombios32.c, I found a function called uuid_probe that sets the uuid variable. I just posted to the coreboot mailing list asking about it. #qemu on irc.freenode.net just got me this when I asked about it:
15:29 < aliguori> in linux bios? it's stuff that shouldn't be there
Googling for 0x564d5868 revealed it’s indicative of the VMWare backdoor stuff. This lead me to what appears to be some emulation of this called VMPort in QEMU. I have no idea yet what it does, if it ever worked, and thus if I can interact with it yet.
Pingback: How I dealt with KVM host identification at btm.geek