[pve-devel] applied: [PATCH container] fix #1786: check for shared storage on clone

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Jun 1 15:13:39 CEST 2018


Am 05/29/2018 um 09:00 AM schrieb Wolfgang Bumiller:
> Refuse to clone a container to a remote node when using
> local storage.
> 
> Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> ---
>   src/PVE/API2/LXC.pm | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
> index bce5fa3..f1bcdc4 100644
> --- a/src/PVE/API2/LXC.pm
> +++ b/src/PVE/API2/LXC.pm
> @@ -1326,6 +1326,7 @@ __PACKAGE__->register_method({
>   		die "unable to create CT $newid: config file already exists\n"
>   		    if -f $conffile;
>   
> +		my $sharedvm = 1;
>   		foreach my $opt (keys %$src_conf) {
>   		    next if $opt =~ m/^unused\d+$/;
>   
> @@ -1342,6 +1343,10 @@ __PACKAGE__->register_method({
>   			    my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
>   			    $sid = $storage if defined($storage);
>   			    my $scfg = PVE::Storage::storage_config($storecfg, $sid);
> +			    if (!$scfg->{shared}) {
> +				$sharedvm = 0;
> +				warn "found non-shared volume: $volid\n" if $target;
> +			    }
>   
>   			    $rpcenv->check($authuser, "/storage/$sid", ['Datastore.AllocateSpace']);
>   
> @@ -1373,6 +1378,8 @@ __PACKAGE__->register_method({
>   			$newconf->{$opt} = $value;
>   		    }
>   		}
> +		die "can't clone CT to node '$target' (CT uses local storage)\n"
> +		    if $target && !$sharedvm;
>   
>   		# Replace the 'disk' lock with a 'create' lock.
>   		$newconf->{lock} = 'create';
> 

applied




More information about the pve-devel mailing list