Skip to content

Commit 9221cb3

Browse files
committed
CLOUDSTACK-9101: resize root volume of stopped vm on KVM
1 parent d6e21f7 commit 9221cb3

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

scripts/storage/qcow2/resizevolume.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@ resizeqcow2() {
187187
# if this is a shrink operation, fail if commands will shrink the volume and we haven't signed of on shrinking
188188
failshrink
189189

190+
#move this back into cloudstack libvirt calls once the libvirt java bindings support block resize
191+
#we try to inform hypervisor of new size, but don't fail if we can't
192+
if `virsh help 2>/dev/null | grep -q blockresize`
193+
then
194+
if `virsh domstate $vmname >/dev/null 2>&1`
195+
then
196+
log "vm $vmname is running, use 'virsh blockresize' to resize the volume"
197+
notifyqemu
198+
if [ $? -eq 0 ]
199+
then
200+
log "performed successful resize - currentsize:$currentsize newsize:$newsize path:$path type:$ptype vmname:$vmname live:$liveresize shrink:$shrink"
201+
exit 0
202+
fi
203+
fi
204+
fi
205+
190206
output=`qemu-img resize $path $newsize 2>&1`
191207
retval=$?
192208

@@ -196,10 +212,6 @@ resizeqcow2() {
196212
exit 1
197213
fi
198214

199-
#move this back into cloudstack libvirt calls once the libvirt java bindings support block resize
200-
#we try to inform hypervisor of new size, but don't fail if we can't
201-
notifyqemu
202-
203215
log "performed successful resize - currentsize:$currentsize newsize:$newsize path:$path type:$ptype vmname:$vmname live:$liveresize shrink:$shrink"
204216
}
205217

@@ -244,7 +256,7 @@ then
244256
resizelvm
245257
elif [ "$ptype" == "QCOW2" ]
246258
then
247-
notifyqemu
259+
resizeqcow2
248260
elif [ "$ptype" == "NOTIFYONLY" ]
249261
then
250262
notifyqemu

0 commit comments

Comments
 (0)