Merge "xenapi: max out VCPU count"

This commit is contained in:
Jenkins 2013-10-14 18:14:13 +00:00 committed by Gerrit Code Review
commit ffae1057ae
2 changed files with 35 additions and 0 deletions

View File

@ -287,3 +287,35 @@ function set_vm_memory() {
dynamic-max=${memory}MiB \
uuid=$vm
}
function max_vcpus() {
local vm_name_label
vm_name_label="$1"
local vm
local host
local cpu_count
host=$(xe host-list --minimal)
vm=$(_vm_uuid "$vm_name_label")
cpu_count=$(xe host-param-get \
param-name=cpu_info \
uuid=$host |
sed -e 's/^.*cpu_count: \([0-9]*\);.*$/\1/g')
if [ -z "$cpu_count" ]; then
# get dom0's vcpu count
cpu_count=$(cat /proc/cpuinfo | grep processor | wc -l)
fi
# Assert cpu_count is not empty
[ -n "$cpu_count" ]
# Assert ithas a numeric nonzero value
expr "$cpu_count" + 0
xe vm-param-set uuid=$vm VCPUs-max=$cpu_count
xe vm-param-set uuid=$vm VCPUs-at-startup=$cpu_count
}

View File

@ -268,6 +268,9 @@ $THIS_DIR/prepare_guest_template.sh "$GUEST_NAME"
# Set virtual machine parameters
set_vm_memory "$GUEST_NAME" "$OSDOMU_MEM_MB"
# Max out VCPU count for better performance
max_vcpus "$GUEST_NAME"
# start the VM to run the prepare steps
xe vm-start vm="$GUEST_NAME"