]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/API2/LXC.pm
Fix #2109: resize rbd volume for container failed
[pve-container.git] / src / PVE / API2 / LXC.pm
index 1cc29790b431a4ba070ed6f398c818804c1e0006..1cbd3d83b82fe365c3cf03598bbcffff5a54941d 100644 (file)
@@ -331,10 +331,10 @@ __PACKAGE__->register_method({
            my $vollist = [];
            eval {
                my $orig_mp_param; # only used if $restore
-               my $orig_conf;
                if ($restore) {
                    die "can't overwrite running container\n" if PVE::LXC::check_running($vmid);
                    if ($is_root && $archive ne '-') {
+                       my $orig_conf;
                        ($orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($archive);
                        # When we're root call 'restore_configuration' with ristricted=0,
                        # causing it to restore the raw lxc entries, among which there may be
@@ -345,7 +345,7 @@ __PACKAGE__->register_method({
                }
                if ($storage_only_mode) {
                    if ($restore) {
-                       if (!defined $orig_mp_param) {
+                       if (!defined($orig_mp_param)) {
                            (undef, $orig_mp_param) = PVE::LXC::Create::recover_config($archive);
                        }
                        $mp_param = $orig_mp_param;
@@ -1606,7 +1606,7 @@ __PACKAGE__->register_method({
                PVE::LXC::Config->write_config($vmid, $conf);
 
                if ($format eq 'raw') {
-                   my $path = PVE::Storage::path($storage_cfg, $volid, undef);
+                   my $path = PVE::Storage::map_volume($storage_cfg, $volid) // PVE::Storage::path($storage_cfg, $volid);
                    if ($running) {
 
                        $mp->{mp} = '/';
@@ -1634,6 +1634,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);
                    }
                }
            };