Adjusting XenServer Dynamic Memory Minimum Limits (lower than 1024MB) through XE CLI

Share Button

If you’ve ever tried to provision a Windows 7 32-bit XenServer Virtual Machine with dynamic memory, you may have experienced a frustration I have with XenCenter only allowing 1024MB for the Win7 dynamic memory minimum value:

While 1024MB may be a reasonable minimum value for production or heavy usage scenarios, it doesn’t bode well for performing server density measurements or taking into account idle desktops. While it’s a bit of a hack, I’ve pieced together a nice little XE script that modifies the static minimum and dynamic minimum values of all powered off virtual machines (excluding Dom0, control domain).

function xe_param()
{
    PARAM=$1
    while read DATA; do
        LINE=$(echo $DATA | egrep "$PARAM")
        if [ $? -eq 0 ]; then
            echo "$LINE" | awk 'BEGIN{FS=": "}{print $2}'
        fi
    done
}

for VM_UUID in $(xe vm-list is-control-domain=false power-state=halted | xe_param uuid); do
 VMName=$(xe vm-list uuid=$VM_UUID | xe_param name)
 echo "Now processing " $VMName
 xe vm-param-set uuid=$VM_UUID memory-static-min=536870912
 xe vm-param-set uuid=$VM_UUID memory-dynamic-min=536870912
done

This script can be used in combination with PVS/MCS provisioning processes, prior to the newly provisioned machines being powered on.  Once run, the script lowers the default Windows 7 profile minimum values to allow you to set 512 MB minimums for your virtual machines:

I’ve typically only used this script when initially building out XenServer environments, so I haven’t added any advanced logic to process virtual machines matching a specific naming convention.  It’s really quick and dirty, so if you want to exclude any specific Virtual Machines the easiest way is to power them on.  The script will error out for powered on virtual machines so I am just excluding anything that’s not in a halted state.

To execute, simply hit the CLI of a XenServer host in your resource pool (direct or SSH) and paste in the text in the script block above. The only output provided is the name of the virtual machine currently being processed:

As I said, this is really just a quick and dirty script to enable some capabilities not available through the XenCenter GUI.  If this has helped your deployment or you would like to share any feedback, please feel free to leave a comment!

Thanks in advance,

–youngtech

Share Button

Leave a Reply