]> git.proxmox.com Git - pve-container.git/commitdiff
api: reassign volume: allow to reassign to self
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 15 Apr 2022 12:02:00 +0000 (14:02 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 15 Apr 2022 12:02:00 +0000 (14:02 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/API2/LXC.pm

index 39db5d89e37854c85d788bae00432e6b8b57999d..64724cb35406a9d9d72bc1cc06f2db09e456e3f7 100644 (file)
@@ -2083,8 +2083,13 @@ __PACKAGE__->register_method({
 
            my $source_conf = PVE::LXC::Config->load_config($vmid);
            PVE::LXC::Config->check_lock($source_conf);
-           my $target_conf = PVE::LXC::Config->load_config($target_vmid);
-           PVE::LXC::Config->check_lock($target_conf);
+           my $target_conf;
+           if ($target_vmid eq $vmid) {
+               $target_conf = $source_conf;
+           } else {
+               $target_conf = PVE::LXC::Config->load_config($target_vmid);
+               PVE::LXC::Config->check_lock($target_conf);
+           }
 
            die "Can't move volumes from or to template CT\n"
                if ($source_conf->{template} || $target_conf->{template});
@@ -2212,11 +2217,6 @@ __PACKAGE__->register_method({
            $rpcenv->check_vm_perm($authuser, $target_vmid, undef, ['VM.Config.Disk'])
                if $authuser ne 'root@pam';
 
-           if ($vmid eq $target_vmid) {
-               my $msg = "must be different than source VMID to move disk to another container";
-               raise_param_exc({ 'target-vmid' => $msg });
-           }
-
            my (undef, undef, $drive) = $load_and_check_reassign_configs->();
            my $storeid = PVE::Storage::parse_volume_id($drive->{volume});
            $rpcenv->check($authuser, "/storage/$storeid", ['Datastore.AllocateSpace']);