XenServer SDK FAQ

How can I install a VM from a template?

A Template records a commonly used configuration. Templates can be instantiated to create new VMs. To see a list of the templates available run:

   xe template-list

To install a VM from a template, and bind a shell variable to the uuid of the newly installed VM, run:

export myvm=`xe vm-install template=<template-name> new-name-label=vm`

Then, to investigate the properties of your new VM run:

xe vm-param-list uuid=$myvm params=all

To see the virtual disks and network interfaces that were created for your new VM (if any), run:

xe vm-disk-list uuid=$myvm
xe vm-vif-list uuid=$myvm

The output of these parameter listing commands will depend on the template you selected above.

Which host will my VM start on?

If you start a VM using (say):

xe vm-start uuid=<vm-uuid>

Then the VM may be started on any one of the hosts which has the resources it requires. If you start the VM, stop it and restart it then there is no reason to expect that it will come back on the same host as before.

Note that you can see the host that a VM is currently running on, by executing:

xe vm-param-get uuid=<vm-uuid> param-name=resident-on

If you prefer, you can specify the host you want a VM to start on explicitly like this:

xe vm-start uuid=<vm-uuid> on=<host-uuid>

The server will check that the host you requested has the required resources to start the VM, failing if not.

How can I enumerate the networks that a particular host can see?

Running the following xe command will return a comma-separated list of networks visisble from the host specified by <host-uuid>.

xe pif-list host-uuid=<host-uuid> params=network-uuid --minimal

This lists the PIF objects with host-uuid field set to <host-uuid>, displaying only the network-uuid field with minimal printing. (Note that in the command above <host-uuid> should be replaced with the actual host uuid you're interested in, whereas the string, network-uuid, should be typed as is - the latter specifies the field name to print.)

Why are there so many Storage Repositories?

Each host has its own local Storage Repositories, plus there are some shared Storage Repositories that can be seen by all hosts. To enumerate all storage repositories run:

xe sr-list

How can I enumerate the storage repositories that a particular host can see?

Running the following xe command will return a comma-separated list of Storage Repositories visible from the host specified by <host-uuid>:

xe pbd-list host=<host-uuid> params=sr-uuid --minimal

Note the similarity between this command, and the command used to enumerate the networks visible to particular host (above).