[pve-devel] [PATCH container] Fix #2109: resize rbd volume for container failed

Alwin Antreich a.antreich at proxmox.com
Tue Mar 5 11:25:43 CET 2019


The returned path of the volume was not a mapped device. This patch uses
un-/map_volume for rbd storage to get a device mapped and its path.

Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
 src/PVE/API2/LXC.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 27d26d5..f06046f 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1582,6 +1582,9 @@ __PACKAGE__->register_method({
 
 	    PVE::Storage::activate_volumes($storage_cfg, [$volid]);
 
+	    my $store_type = $storage_cfg->{ids}->{$storeid}->{type};
+	    my $path = PVE::Storage::map_volume($storage_cfg, $volid, undef) if ($store_type eq 'rbd');
+
 	    my $size = PVE::Storage::volume_size_info($storage_cfg, $volid, 5);
 	    $newsize += $size if $ext;
 	    $newsize = int($newsize);
@@ -1602,7 +1605,7 @@ __PACKAGE__->register_method({
 		PVE::LXC::Config->write_config($vmid, $conf);
 
 		if ($format eq 'raw') {
-		    my $path = PVE::Storage::path($storage_cfg, $volid, undef);
+		    $path = PVE::Storage::path($storage_cfg, $volid, undef) if ($store_type ne 'rbd');
 		    if ($running) {
 
 			$mp->{mp} = '/';
@@ -1630,6 +1633,8 @@ __PACKAGE__->register_method({
 			    PVE::Tools::run_command(['resize2fs', $path]);
 			};
 			warn "Failed to update the container's filesystem: $@\n" if $@;
+
+			PVE::Storage::unmap_volume($storage_cfg, $volid, undef) if ($store_type eq 'rbd');
 		    }
 		}
 	    };
-- 
2.11.0





More information about the pve-devel mailing list