[pve-devel] [PATCH pve-storage 1/3] Make volume_resize() return new volume size

Dmitry Petuhov mityapetuhov at gmail.com
Fri Jan 13 08:11:33 CET 2017


Make volume_resize() return new volume size to be reported to qemu
instead of just true.

Signed-off-by: Dmitry Petuhov <mityapetuhov at gmail.com>
---
 PVE/Storage/LVMPlugin.pm      | 7 ++++---
 PVE/Storage/Plugin.pm         | 2 +-
 PVE/Storage/RBDPlugin.pm      | 2 +-
 PVE/Storage/SheepdogPlugin.pm | 2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
index 60a58e5..7d01a18 100644
--- a/PVE/Storage/LVMPlugin.pm
+++ b/PVE/Storage/LVMPlugin.pm
@@ -455,13 +455,14 @@ sub deactivate_volume {
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
 
-    $size = ($size/1024/1024) . "M";
+    my $msize = ($size/1024/1024) . "M";
 
     my $path = $class->path($scfg, $volname);
-    my $cmd = ['/sbin/lvextend', '-L', $size, $path];
+    my $cmd = ['/sbin/lvextend', '-L', $msize, $path];
     run_command($cmd, errmsg => "error resizing volume '$path'");
 
-    return 1;
+    #may theoretically be little smaller than requested because of rounding
+    return int($size/1024/1024)*1024*1024;
 }
 
 sub volume_snapshot {
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 6e73547..5db2947 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -670,7 +670,7 @@ sub volume_resize {
 
     die "can't resize this image format\n" if $volname !~ m/\.(raw|qcow2)$/;
 
-    return 1 if $running;
+    return $size if $running;
 
     my $path = $class->filesystem_path($scfg, $volname);
 
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 538a16a..e5973de 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -604,7 +604,7 @@ sub volume_size_info {
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
 
-    return 1 if $running;
+    return $size if $running;
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
diff --git a/PVE/Storage/SheepdogPlugin.pm b/PVE/Storage/SheepdogPlugin.pm
index d9542a8..ada35f8 100644
--- a/PVE/Storage/SheepdogPlugin.pm
+++ b/PVE/Storage/SheepdogPlugin.pm
@@ -379,7 +379,7 @@ sub volume_size_info {
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
 
-    return 1 if $running;
+    return $size if $running;
 
     my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
 	$class->parse_volname($volname);
-- 
2.1.4



More information about the pve-devel mailing list