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

Alwin Antreich a.antreich at proxmox.com
Tue Mar 5 12:07:16 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>
---
V1 -> V2: implemented suggestions from Thomas
	https://pve.proxmox.com/pipermail/pve-devel/2019-March/035896.html

 src/PVE/API2/LXC.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 27d26d5..b8d3f42 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1582,6 +1582,8 @@ __PACKAGE__->register_method({
 
 	    PVE::Storage::activate_volumes($storage_cfg, [$volid]);
 
+	    my $path = PVE::Storage::map_volume($storage_cfg, $volid) // PVE::Storage::path($storage_cfg, $volid);
+
 	    my $size = PVE::Storage::volume_size_info($storage_cfg, $volid, 5);
 	    $newsize += $size if $ext;
 	    $newsize = int($newsize);
@@ -1602,7 +1604,6 @@ __PACKAGE__->register_method({
 		PVE::LXC::Config->write_config($vmid, $conf);
 
 		if ($format eq 'raw') {
-		    my $path = PVE::Storage::path($storage_cfg, $volid, undef);
 		    if ($running) {
 
 			$mp->{mp} = '/';
@@ -1630,6 +1631,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);
 		    }
 		}
 	    };
-- 
2.11.0





More information about the pve-devel mailing list