From 24f9d440a6391ec31ecfce869627a7910eb3f041 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 29 May 2018 09:00:32 +0200 Subject: [PATCH] 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 --- 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 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'; -- 2.39.2