From 81f5058c01a4df000ede1605adf7ecf6975dc91d Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Mon, 6 Aug 2012 11:57:27 +0200 Subject: [PATCH] plugins : add volume_resize this add qemu-img resize for file devices (raw - qcow2) if vm is offline. otherwise we need to use online qmp block_resize Signed-off-by: Alexandre Derumier --- PVE/Storage/Plugin.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index a50b602..be1189a 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -488,6 +488,22 @@ sub volume_size_info { } +sub volume_resize { + my ($class, $scfg, $storeid, $volname, $size, $running) = @_; + + die "can't resize this image format" if $volname !~ m/\.(raw|qcow2)$/; + + return 1 if $running; + + my $path = $class->path($scfg, $volname); + + my $cmd = ['/usr/bin/qemu-img', 'resize', $path , $size]; + + run_command($cmd, timeout => 1); + + return undef; +} + sub list_images { my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;