[pve-devel] [PATCH qemu-server v2 03/15] fix #5284: api: clone_vm: assert content type support for target storage

Fiona Ebner f.ebner at proxmox.com
Thu Feb 20 15:04:10 CET 2025


Am 11.02.25 um 17:08 schrieb Daniel Kral:
> Asserts whether the target storage supports storing VM images before
> cloning a VM and its volumes to the target storage.
> 
> Without the check in place, a VMs volumes can be cloned to a storage,
> which does not support VM images, but won't be able to start since any
> attached volume must be stored on a supported storage.
> 
> Signed-off-by: Daniel Kral <d.kral at proxmox.com>

Reviewed-by: Fiona Ebner <f.ebner at proxmox.com>

> ---
> changes since v1:
> - new! (was fixed without special notice in rfc)
> 
>  PVE/API2/Qemu.pm | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 52234afd..370036b8 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -3851,13 +3851,15 @@ __PACKAGE__->register_method({
>  	    my $storecfg = PVE::Storage::config();
>  
>  	    if ($storage) {
> -		# check if storage is enabled on local node
> -		PVE::Storage::storage_check_enabled($storecfg, $storage);
> +		# check if storage is enabled on local node and supports vm images
> +		my $scfg = PVE::Storage::storage_check_enabled($storecfg, $storage);
> +		raise_param_exc({ storage => "storage '$storage' does not support vm images" })
> +		    if !$scfg->{content}->{images};
> +
>  		if ($target) {
>  		    # check if storage is available on target node
>  		    PVE::Storage::storage_check_enabled($storecfg, $storage, $target);
>  		    # clone only works if target storage is shared
> -		    my $scfg = PVE::Storage::storage_config($storecfg, $storage);
>  		    die "can't clone to non-shared storage '$storage'\n"
>  			if !$scfg->{shared};
>  		}





More information about the pve-devel mailing list