[pve-devel] applied: [Patch V2 container] fix #1778: check if storage support templates

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jun 6 15:35:07 CEST 2018


On 6/6/18 3:21 PM, Wolfgang Link wrote:
> LXC can only create templates on storages which support linked clones.
> To prevent this, we will check before we convert to a template if the
> storage support this.
> ---
>  src/PVE/API2/LXC.pm | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> [Patch V2]
> change formatting
> rename var
> fix grammar
> 
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index f555b84..651138f 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -1166,6 +1166,15 @@ __PACKAGE__->register_method({
>  	    die "you can't convert a CT to template if the CT is running\n"
>  		if PVE::LXC::check_running($vmid);
>  
> +	    my $scfg = PVE::Storage::config();
> +	    PVE::LXC::Config->foreach_mountpoint($conf, sub {
> +		my ($ms, $mp) = @_;
> +
> +		my ($sid) =PVE::Storage::parse_volume_id($mp->{volume}, 0);
> +		die "Storage '$sid' does not support templates!\n"
> +		    if $scfg->{ids}->{$sid}->{path};
> +	    });
> +
>  	    my $realcmd = sub {
>  		PVE::LXC::template_create($vmid, $conf);
>  
>




More information about the pve-devel mailing list