[pve-devel] [PATCH v2 container 2/3] Check lock for pct start, stop, suspend, shutdown

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Jan 15 11:40:10 CET 2016


Correctly error out upon encountering a locked container
when doing pct start, pct stop, pct suspend or pct shutdown

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/PVE/API2/LXC/Status.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm
index fb5480d..e119211 100644
--- a/src/PVE/API2/LXC/Status.pm
+++ b/src/PVE/API2/LXC/Status.pm
@@ -161,6 +161,8 @@ __PACKAGE__->register_method({
 		die "you can't start a CT if it's a template\n"
 		    if PVE::LXC::is_template($conf);
 
+		PVE::LXC::check_lock($conf);
+
 		my $storage_cfg = cfs_read_file("storage.cfg");
 
 		PVE::LXC::update_lxc_config($storage_cfg, $vmid, $conf);
@@ -234,6 +236,10 @@ __PACKAGE__->register_method({
 
 		syslog('info', "stopping CT $vmid: $upid\n");
 
+		my $conf = PVE::LXC::load_config($vmid);
+
+		PVE::LXC::check_lock($conf);
+
 		my $cmd = ['lxc-stop', '-n', $vmid, '--kill'];
 
 		run_command($cmd);
@@ -304,6 +310,8 @@ __PACKAGE__->register_method({
 
 	    my $conf = PVE::LXC::load_config($vmid);
 
+	    PVE::LXC::check_lock($conf);
+
 	    my $storage_cfg = PVE::Storage::config();
 
 	    push @$cmd, '--timeout', $timeout;
@@ -370,6 +378,10 @@ __PACKAGE__->register_method({
 
             syslog('info', "suspend CT $vmid: $upid\n");
 
+	    my $conf = PVE::LXC::load_config($vmid);
+
+	    PVE::LXC::check_lock($conf);
+
 	    my $cmd = ['lxc-checkpoint', '-n', $vmid, '-s', '-D', '/var/liv/vz/dump'];
 
 	    run_command($cmd);
-- 
2.1.4





More information about the pve-devel mailing list