[pve-devel] applied: [PATCH qemu-server] disk reassign: add unused disks directly to config

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Nov 11 10:09:45 CET 2021


On November 10, 2021 6:00 pm, Aaron Lauterer wrote:
> Using $update_vm_api for unused disks will cause them to end up as a
> pending change if the VM is running.
> 
> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
> ---
> That case is already handled for containers but was missed for VMs.
> 
>  PVE/API2/Qemu.pm | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 4404da9..24b1d2f 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -3607,15 +3607,21 @@ __PACKAGE__->register_method({
>  		    PVE::QemuConfig->write_config($vmid, $source_conf);
>  
>  		    my $drive_string = PVE::QemuServer::print_drive($drive);
> -		    &$update_vm_api(
> -			{
> -			    node => $node,
> -			    vmid => $target_vmid,
> -			    digest => $target_digest,
> -			    $target_disk => $drive_string,
> -			},
> -			1,
> -		    );
> +
> +		    if ($target_disk =~ /^unused\d+$/) {
> +			$target_conf->{$target_disk} = $drive_string;
> +			PVE::QemuConfig->write_config($target_vmid, $target_conf);
> +		    } else {
> +			&$update_vm_api(
> +			    {
> +				node => $node,
> +				vmid => $target_vmid,
> +				digest => $target_digest,
> +				$target_disk => $drive_string,
> +			    },
> +			    1,
> +			);
> +		    }
>  
>  		    # remove possible replication snapshots
>  		    if (PVE::Storage::volume_has_feature(
> -- 
> 2.30.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




More information about the pve-devel mailing list