From: Wolfgang Bumiller Date: Tue, 29 May 2018 07:00:32 +0000 (+0200) Subject: fix #1786: check for shared storage on clone X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=24f9d440a6391ec31ecfce869627a7910eb3f041;p=pve-container.git fix #1786: check for shared storage on clone Refuse to clone a container to a remote node when using local storage. Signed-off-by: Wolfgang Bumiller --- diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index c016b44..f555b84 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';