[pve-devel] [PATCHV3 pve-container 4/4] Prevent that a CT run at cloning.

Wolfgang Link w.link at proxmox.com
Tue May 10 11:13:34 CEST 2016


If we make a linked clone the CT must be a template so it is not allowed to run.
If we make a full clone, it is safer to have the CT offline.
---
 src/PVE/API2/LXC.pm | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 6fb0a62..aef20f0 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1085,20 +1085,15 @@ __PACKAGE__->register_method({
 
 	PVE::Cluster::check_cfs_quorum();
 
-	my $running = PVE::LXC::check_running($vmid) || 0;
-
 	my $clonefn = sub {
 
+	    die "Clone can't be done online\n." if  PVE::LXC::check_running($vmid);
 	    # do all tests after lock
 	    # we also try to do all tests before we fork the worker
 	    my $conf = PVE::LXC::Config->load_config($vmid);
 
 	    PVE::LXC::Config->check_lock($conf);
 
-	    my $verify_running = PVE::LXC::check_running($vmid) || 0;
-
-	    die "unexpected state change\n" if $verify_running != $running;
-
 	    die "snapshot '$snapname' does not exist\n"
 		if $snapname && !defined( $conf->{snapshots}->{$snapname});
 
@@ -1131,7 +1126,7 @@ __PACKAGE__->register_method({
 			} else {
 			    # not full means clone instead of copy
 			    die "Linked clone feature for '$volid' is not available\n"
-				if !PVE::Storage::volume_has_feature($storecfg, 'clone', $volid, $snapname, $running);
+				if !PVE::Storage::volume_has_feature($storecfg, 'clone', $volid, $snapname, 0);
 			}
 
 			$mountpoints->{$opt} = $mp;
-- 
2.1.4





More information about the pve-devel mailing list