XenServer

VM placement

XenServer provides a number of ways that you can define which host in a pool VMs are started on or migrated to:

  • Anti-affinity placement groups: When VMs in a VM group with anti-affinity placement rules are started or evacuated from a host, XenServer places the VM on a host that enables the group to most closely follow the group rules. For more information, see Anti-affinity placement groups.
  • Home server: This VM setting defines the host where XenServer attempts to start the VM. If a home server is set, this setting has higher priority than any VM group placement rules on the same VM. For more information, see Home server.
  • Workload Balancing: A virtual appliance that monitors your pool and provides rebalancing and placement recommendations to maximise VM density or resource performance. By default, Workload Balancing placements take priority over home server and anti-affinity placement group settings. Workload Balancing placement recommendations can breach the anti-affinity rules. For more information, see Workload Balancing.

Anti-affinity placement groups

You can assign your VMs to VM groups that are started on hosts in your pool according to the placement rules of the group. The available placement types are “anti-affinity” and “normal”.

VM groups with normal placement do not have any special behavior.

VM groups with anti-affinity placement have the following rules:

  1. No single host is the only place all VMs in a particular group are running.
  2. The count of VMs within the group for each host is as even as possible.

When a VM in a VM group with anti-affinity placement rules is started or evacuated from a host, XenServer chooses to place the VM on a host that enables the VM group to follow these anti-affinity placement rules as closely as possible. If the VM start or host evacuate cannot be done without breaching the placement rules, XenServer prioritizes completing the action over following the placement rules.

If the anti-affinity rules are breached, you receive an alert. Alerts are generated if all the running VMs in an anti-affinity group reside on a single host. If this changes, the alert is cleared. This alert is not generated if only one of the VMs in the group is running or no VMs in the group are running. For more information, see XenCenter Alerts.

In the following scenarios the VM group placement rules do not take effect:

  • In pools with Workload Balancing (WLB) enabled, the VM group is not used for starting, restarting, resuming, or migrating the VM. Instead, Workload Balancing nominates the best server for the VM by analyzing XenServer resource pool metrics and by recommending optimizations. These recommendations can cause the VM anti-affinity rules to be breached.
  • If the VM has a home server defined, this setting takes priority over the VM group setting.

Considerations when using VM groups:

  • Only 5 anti-affinity groups per pool are supported.
  • When you clone a VM that is in a VM group, the new VM is not added to the same VM group. You must explicitly set the VM group for the new VM.
  • If you revert a VM to a previous snapshot, the VM retains its current VM group setting. This setting does not change to the value it had when you took the snapshot.
  • Exporting a VM does not retain the VM group setting. If you import this VM again, it is not added to a VM group. You must explicitly set the VM group for the imported VM.

Adding a VM to a group

You can add a VM to only one VM group.

In XenCenter, use one the following methods to add a VM to a group:

  • In the New VM wizard on the VM group tab, you can select a VM group to add the VM to or you can create a new one. For more information, see Create a new VM.
  • In the Resources pane of XenCenter, you can right-click on a VM or a selected set of VMs and choose Assign to VM group. The submenu shows the available VM groups and also gives you the option to create a new VM group. The current VM group for the VM is marked with a check.
  • In the Resources pane of XenCenter, you can right-click on the pool and choose Manage VM groups. For more information, see Manage VM groups.
  • In the XenCenter main menu, you can select VM > Assign to VM group. The submenu shows the available VM groups and also gives you the option to create a new VM group. The current VM group for the VM is marked with a check.
  • In the XenCenter main menu, you can select Pool > Manage VM groups. For more information, see Manage VM groups.

To use the xe CLI to add a VM to a group, run the following command:

xe vm-param-set uuid=<vm_uuid> groups=<vm_group_uuid>
<!--NeedCopy-->

To get the UUIDs of the VM and the VM anti-affinity group, you can use the commands xe vm-list and xe vm-group-list.

Changing the group for a VM

A VM can be part of only one VM group. If you select to add a VM to a group, it is removed from the group it was previously a member of.

To change the group a VM is in:

In XenCenter, you can update the group for a VM in one of the following places:

  • In the Resources pane of XenCenter, you can right-click on a VM and choose Assign to VM group. The submenu shows the available VM groups and also gives you the option to create a new VM group. The current VM group for the VM is marked with a check.
  • In the Resources pane of XenCenter, you can right-click on the pool and choose Manage VM groups. For more information, see Manage VM groups.
  • In the XenCenter main menu, you can select VM > Assign to VM group. The submenu shows the available VM groups and also gives you the option to create a new VM group. The current VM group for the VM is marked with a check.
  • In the XenCenter main menu, you can select Pool > Manage VM groups. For more information, see Manage VM groups.

To use the xe CLI to change the group for a VM, run the following command:

xe vm-param-set uuid=<vm_uuid> groups=<vm_group_uuid>
<!--NeedCopy-->

To get the UUIDs of the VM and the VM anti-affinity group, you can use the commands xe vm-list and xe vm-group-list.

You can also use this command to remove the VM from an affinity group. To do this, leave the value of the groups parameter blank.

xe vm-param-set uuid=<vm_uuid> groups=
<!--NeedCopy-->

Working with VM groups

You can manage your VM groups in XenCenter by using the Manage VM group dialog box. For more information, see Manage VM groups.

XenServer provides the following xe CLI commands for working with VM groups:

To create a VM group:

xe vm-group-create placement=anti-affinity name-label=<name_label>
<!--NeedCopy-->

Replace <name-label> with the name for your group. You can also provide an optional name-description parameter that sets a description for the group. To create a group whose members follow the anti-affinity placement rules, specify placement=anti-affinity. The option normal is also available for the parameter placement. Normal placement groups have no special behavior or rules.

To see the available VM groups:

xe vm-group-list
<!--NeedCopy-->

To delete a VM group:

xe vm-group-destroy uuid=<vm_group_uuid>
<!--NeedCopy-->

You can list the available VM groups to find the group UUID.

If you delete a VM group that has VMs in it, the VMs are no longer associated with a group, but are not otherwise affected.

Home server

A home server is the server which provides the resources for a VM in a pool. When you nominate a home server for a VM, XenServer always attempts to start up the VM on that server if it can. If XenServer cannot start the VM on that server, an alternate server within the same pool is selected automatically.

In the following scenarios, the home server nomination does not take effect:

  • In pools with Workload Balancing (WLB) enabled, the nominated home server is not used for starting, restarting, resuming, or migrating the VM. Instead, Workload Balancing nominates the best server for the VM by analyzing XenServer resource pool metrics and by recommending optimizations.
  • If a VM has one or more virtual GPUs assigned to it, the home server nomination does not take effect. Instead, the server nomination is based on the virtual GPU placement policy set by the user. For more information, see GPU Placement Policy.

Nominating the home server

To set a home server when first creating the VM:

In XenCenter:

  • To nominate a home server for the VM in the New VM wizard, select Place the VM on this server and choose a server from the list.
  • If you do not want to nominate a home server, click Don’t assign this VM a home server. The VM uses the resources on the most suitable available server.

For more information, see Create a new VM.

By using the xe CLI:

  • To nominate a home server, during VM create, run the command xe vm-param-set uuid=<vm_uuid> affinity=<host_uuid>.

Note:

If you are creating a BIOS-customized VM, the OEM server from which you copy the BIOS strings is automatically selected as the home server for the new VM.

Changing the home server

To change the home server configuration for a VM:

In XenCenter:

  • Go to the VM’s Properties dialog box, then to the Home Server tab. For more information, see Change VM properties.

By using the xe CLI:

  • To change the home server, run the command xe vm-param-set uuid=<vm_uuid> affinity=<host_uuid>.
  • To remove the home server from a VM, run the command xe vm-param-set uuid=<vm_uuid> affinity=. (Leave the value of affinity blank.)
VM placement