#!/bin/sh XL=./ldxl ROOTPOOL=Pool-0 NUMAPREFIX=Pool-node numnodes=`xl info | sed -e 's/^nr_nodes *: \([0-9]*\)/\1/;t;d'` numcores=`xl info | sed -e 's/^nr_cpus *: \([0-9]*\)/\1/;t;d'` if [ ! -x ${XL} ] then XL=xl fi if [ $# -gt 0 ]; then action=$1 else action=create fi if [ "$action" = "create" ] then $XL cpupool-rename $ROOTPOOL ${NUMAPREFIX}0 for i in `seq 1 $((numnodes-1))` do echo "Removing CPUs from Pool 0" $XL cpupool-cpu-remove ${NUMAPREFIX}0 node:$i echo "Rewriting config file" sed -i -e "s/${NUMAPREFIX}./${NUMAPREFIX}${i}/" cpupool.test echo "Creating new pool" $XL cpupool-create cpupool.test echo "Populating new pool" $XL cpupool-cpu-add ${NUMAPREFIX}${i} node:$i done elif [ "$action" = "create2" ] then $XL cpupool-rename $ROOTPOOL ${NUMAPREFIX}0 echo "Removing CPUs from Pool 0" for i in `seq 1 $((numnodes-1))` do $XL cpupool-cpu-remove ${NUMAPREFIX}0 node:$i done for i in `seq 1 $((numnodes-1))` do echo "Rewriting config file" sed -i -e "s/${NUMAPREFIX}./${NUMAPREFIX}${i}/" cpupool.test echo "Creating new pool" $XL cpupool-create cpupool.test echo "Populating new pool" $XL cpupool-cpu-add ${NUMAPREFIX}${i} node:$i done elif [ "$action" = "revert" ] then for i in `seq 1 $((numnodes-1))` do echo "Destroying Pool $i" $XL cpupool-destroy ${NUMAPREFIX}${i} echo "adding freed CPUs to pool 0" $XL cpupool-cpu-add ${NUMAPREFIX}0 node:$i done $XL cpupool-rename ${NUMAPREFIX}0 $ROOTPOOL elif [ "$action" = "remove" ] then for i in `seq 1 $((numcores-1))` do echo "Removing CPU $i from Pool-0" $XL cpupool-cpu-remove $ROOTPOOL $i done elif [ "$action" = "add" ] then for i in `seq 1 $((numcores-1))` do echo "Removing CPU $i from Pool-0" $XL cpupool-cpu-add $ROOTPOOL $i done fi