-
Notifications
You must be signed in to change notification settings - Fork 0
/
vmresize
49 lines (40 loc) · 1.24 KB
/
vmresize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
#set -x
scriptdir=$(dirname $(realpath $0))
configdir=$scriptdir/config
[[ -z $VMARCH ]] && [[ -a $configdir/VMARCH ]] \
&& VMARCH=$(cat $configdir/VMARCH)
[[ -z $VMHOST ]] && [[ -a $configdir/${VMARCH}.host ]] \
&& VMHOST=$(cat $configdir/${VMARCH}.host)
vmhost=${VMHOST}
if [[ $vmhost != $(hostname) ]]; then
pre="ssh -x $vmhost"
pretty="ssh -x -t $vmhost"
else
unset pre
unset pretty
fi
arch=${VMARCH:-$($pre uname -i)}
base=${VMBASEVM:-basevm-$arch}
domain=$1
cpus=$2
ram=$3
if [[ -z $domain ]]; then
echo "USAGE:vmvresize <name> [cpus] [ram]"
echo " where name is a the name of one of your existing vms:"
$pre virsh list --all | grep -v $base
echo " You can use vmnew to create a new one from the base."
echo " Base vm is $base ... you should not use this one directly"
exit -1
fi
if [[ -z $cpus && -z $ram ]]; then
echo "$DOMAIN: cpus: $($pre virsh vcpucount)"
$pre virsh setmem ${DOMAIN} ${VMMEM} --config
$pre virsh setvcpus ${DOMAIN} ${VMCPUS} --config
if ! $pretty virsh console --force $domain; then
$pre virsh start $domain
if ! $pretty virsh console --force $domain; then
echo "WTF: can't seem to start or attach to kele console" > /dev/stderr
exit -1
fi
fi