From 9f878cbe6dcbd26e756546c1fc7a97994c7a311d Mon Sep 17 00:00:00 2001 From: Mate Lakat Date: Fri, 4 Oct 2013 09:56:24 +0100 Subject: [PATCH] xenapi: max out VCPU count Give as much VCPUs to the DevStack machine as possible. First asking xenapi about its CPU count, and as a fallback, count the CPUs in dom0. This should result in faster test runs. Change-Id: I1ffb99ecd435f1d7eb5754fe9cd99f0e8ceae6dc --- tools/xen/functions | 32 ++++++++++++++++++++++++++++++++ tools/xen/install_os_domU.sh | 3 +++ 2 files changed, 35 insertions(+) diff --git a/tools/xen/functions b/tools/xen/functions index a5c4b70bc3..c65d919e3f 100644 --- a/tools/xen/functions +++ b/tools/xen/functions @@ -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 +} diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh index 110bbd998c..e69cdea04f 100755 --- a/tools/xen/install_os_domU.sh +++ b/tools/xen/install_os_domU.sh @@ -263,6 +263,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"