]> git.proxmox.com Git - pve-container.git/commitdiff
fix #1786: check for shared storage on clone
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 29 May 2018 07:00:32 +0000 (09:00 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 1 Jun 2018 12:56:52 +0000 (14:56 +0200)
Refuse to clone a container to a remote node when using
local storage.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/API2/LXC.pm

index c016b44effbc979058d138e3f42a6306b4256ada..f555b847b2cbcbd22b64513a6435d4beff3ef128 100644 (file)
@@ -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';