On XenServer is there any way to read VM metadata (Custom fields, Tags, VM Name) from inside the VM using Linux (CentOS 5.8) ?

Basically what I want to do is:

  1. Create new VM using

    xe vm-install template=MYTEMPLATE new-name-label=MYVM

  2. Read metadata to configure VM hostname, IP address, etc

On EC2 you can pass an user-data-file containing a script when you launch a new VM. Once the VM comes up the script is executed. Similar to this:

ec2-run-instances --key KEYPAIR --user-data-file CONFIGURE-SCRIPT ami-bf5eb9d6

I can pass some information to the VM using "OS boot parameters" inside "BOOT OPTIONS"

# cat /proc/cmdline 
ro root=/dev/vg0/root console=xvc0  CUSTOMTEXT

This does not look very elegant to me and may interfere with some real Linux boot parameters. Another problem is that the CUSTOMTEXT will continue to be passed to the VM on every boot.

I just need a way to pass a few parameters once during VM creation and run a script that will use those parameters on first boot.

any ideas ?




After searching a bit more on Google, the answer to this problem is XenStore (http://wiki.xen.org/wiki/XenStore)

To get the VM name (domU) from Linux run:

xenstore-ls /local/domain/`xenstore-read domid`

Additional links with useful solutions:


How to find dom0 name from hosted domU



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.