From 9221cb3e0d0e5a0ea374f10e889f7e32c2a3eda1 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 3 Dec 2015 14:31:55 +0100 Subject: [PATCH] CLOUDSTACK-9101: resize root volume of stopped vm on KVM --- scripts/storage/qcow2/resizevolume.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/storage/qcow2/resizevolume.sh b/scripts/storage/qcow2/resizevolume.sh index 1e6ffd648f5..da77cb1adca 100755 --- a/scripts/storage/qcow2/resizevolume.sh +++ b/scripts/storage/qcow2/resizevolume.sh @@ -187,6 +187,22 @@ resizeqcow2() { # if this is a shrink operation, fail if commands will shrink the volume and we haven't signed of on shrinking failshrink + #move this back into cloudstack libvirt calls once the libvirt java bindings support block resize + #we try to inform hypervisor of new size, but don't fail if we can't + if `virsh help 2>/dev/null | grep -q blockresize` + then + if `virsh domstate $vmname >/dev/null 2>&1` + then + log "vm $vmname is running, use 'virsh blockresize' to resize the volume" + notifyqemu + if [ $? -eq 0 ] + then + log "performed successful resize - currentsize:$currentsize newsize:$newsize path:$path type:$ptype vmname:$vmname live:$liveresize shrink:$shrink" + exit 0 + fi + fi + fi + output=`qemu-img resize $path $newsize 2>&1` retval=$? @@ -196,10 +212,6 @@ resizeqcow2() { exit 1 fi - #move this back into cloudstack libvirt calls once the libvirt java bindings support block resize - #we try to inform hypervisor of new size, but don't fail if we can't - notifyqemu - log "performed successful resize - currentsize:$currentsize newsize:$newsize path:$path type:$ptype vmname:$vmname live:$liveresize shrink:$shrink" } @@ -244,7 +256,7 @@ then resizelvm elif [ "$ptype" == "QCOW2" ] then - notifyqemu + resizeqcow2 elif [ "$ptype" == "NOTIFYONLY" ] then notifyqemu