diff --git a/tools/xen/functions b/tools/xen/functions index 7616a5fd4d..a5c4b70bc3 100644 --- a/tools/xen/functions +++ b/tools/xen/functions @@ -268,3 +268,22 @@ function attach_network() { xe network-attach uuid=$net host-uuid=$host } + +function set_vm_memory() { + local vm_name_label + local memory + + vm_name_label="$1" + memory="$2" + + local vm + + vm=$(_vm_uuid "$vm_name_label") + + xe vm-memory-limits-set \ + static-min=${memory}MiB \ + static-max=${memory}MiB \ + dynamic-min=${memory}MiB \ + dynamic-max=${memory}MiB \ + uuid=$vm +} diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh index a012a08561..b49504d9e9 100755 --- a/tools/xen/install_os_domU.sh +++ b/tools/xen/install_os_domU.sh @@ -228,8 +228,11 @@ if [ -z "$templateuuid" ]; then $THIS_DIR/scripts/install-os-vpx.sh \ -t "$UBUNTU_INST_TEMPLATE_NAME" \ -n "$UBUNTU_INST_BRIDGE_OR_NET_NAME" \ - -l "$GUEST_NAME" \ - -r "$OSDOMU_MEM_MB" + -l "$GUEST_NAME" + + set_vm_memory "$GUEST_NAME" "$OSDOMU_MEM_MB" + + xe vm-start vm="$GUEST_NAME" # wait for install to finish wait_for_VM_to_halt @@ -255,6 +258,9 @@ fi # Install XenServer tools, and other such things $THIS_DIR/prepare_guest_template.sh "$GUEST_NAME" +# Set virtual machine parameters +set_vm_memory "$GUEST_NAME" "$OSDOMU_MEM_MB" + # start the VM to run the prepare steps xe vm-start vm="$GUEST_NAME" diff --git a/tools/xen/scripts/install-os-vpx.sh b/tools/xen/scripts/install-os-vpx.sh index 8ee8b675a9..c94a593e3d 100755 --- a/tools/xen/scripts/install-os-vpx.sh +++ b/tools/xen/scripts/install-os-vpx.sh @@ -20,8 +20,6 @@ set -eux BRIDGE= -RAM= -BALLOONING= NAME_LABEL= TEMPLATE_NAME= @@ -29,7 +27,7 @@ usage() { cat << EOF - Usage: $0 -t TEMPLATE_NW_INSTALL -l NAME_LABEL [-n BRIDGE] [-r RAM] [-b] + Usage: $0 -t TEMPLATE_NW_INSTALL -l NAME_LABEL [-n BRIDGE] Install a VM from a template @@ -37,9 +35,6 @@ cat << EOF -h Shows this message. -t template VM template to use - -b Enable memory ballooning. When set min_RAM=RAM/2 max_RAM=RAM. - -r MiB Specifies RAM used by the VPX, in MiB. - By default it will take the value from the XVA. -l name Specifies the name label for the VM. -n bridge The bridge/network to use for eth0. Defaults to xenbr0 EOF @@ -53,12 +48,6 @@ get_params() h) usage exit 1 ;; - b) - BALLOONING=1 - ;; - r) - RAM=$OPTARG - ;; n) BRIDGE=$OPTARG ;; @@ -119,19 +108,6 @@ create_vif() } -set_memory() -{ - local v="$1" - if [ "$RAM" != "" ] - then - echo "Setting RAM to $RAM MiB." - [ "$BALLOONING" == 1 ] && RAM_MIN=$(($RAM / 2)) || RAM_MIN=$RAM - xe vm-memory-limits-set static-min=16MiB static-max=${RAM}MiB \ - dynamic-min=${RAM_MIN}MiB dynamic-max=${RAM}MiB \ - uuid="$v" - fi -} - # Make the VM auto-start on server boot. set_auto_start() @@ -161,5 +137,3 @@ set_auto_start "$vm_uuid" create_vif "$vm_uuid" xe vm-param-set other-config:os-vpx=true uuid="$vm_uuid" xe vm-param-set actions-after-reboot=Destroy uuid="$vm_uuid" -set_memory "$vm_uuid" -xe vm-start uuid=$vm_uuid