]> 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 27d26d5be5ceb480fc6cc4379e4037008b806cae..1cbd3d83b82fe365c3cf03598bbcffff5a54941d 100644 (file)
@@ -333,8 +333,9 @@ __PACKAGE__->register_method({
                my $orig_mp_param; # only used if $restore
                if ($restore) {
                    die "can't overwrite running container\n" if PVE::LXC::check_running($vmid);
-                   (my $orig_conf, $orig_mp_param) = PVE::LXC::Create::recover_config($archive);
-                   if ($is_root) {
+                   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
                        # 'lxc.idmap' entries. We need to make sure that the extracted contents
@@ -344,6 +345,9 @@ __PACKAGE__->register_method({
                }
                if ($storage_only_mode) {
                    if ($restore) {
+                       if (!defined($orig_mp_param)) {
+                           (undef, $orig_mp_param) = PVE::LXC::Create::recover_config($archive);
+                       }
                        $mp_param = $orig_mp_param;
                        die "rootfs configuration could not be recovered, please check and specify manually!\n"
                            if !defined($mp_param->{rootfs});
@@ -1602,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} = '/';
@@ -1630,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);
                    }
                }
            };