From: Wolfgang Bumiller Date: Fri, 26 Feb 2016 10:42:12 +0000 (+0100) Subject: allow starting and stopping a mounted container X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=6da1f91b592bb0aceacf492761527e13ef7e3005;p=pve-container.git allow starting and stopping a mounted container --- diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm index e91ac7c..a4498d1 100644 --- a/src/PVE/API2/LXC/Status.pm +++ b/src/PVE/API2/LXC/Status.pm @@ -168,7 +168,9 @@ __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) if !$skiplock; + if (!$skiplock && !PVE::LXC::has_lock($conf, 'mounted')) { + PVE::LXC::check_lock($conf); + } my $storage_cfg = cfs_read_file("storage.cfg"); @@ -256,7 +258,9 @@ __PACKAGE__->register_method({ my $conf = PVE::LXC::load_config($vmid); - PVE::LXC::check_lock($conf) if !$skiplock; + if (!$skiplock && !PVE::LXC::has_lock($conf, 'mounted')) { + PVE::LXC::check_lock($conf); + } my $cmd = ['lxc-stop', '-n', $vmid, '--kill']; diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 8ebf3db..0f8cff3 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -1054,6 +1054,11 @@ sub check_lock { die "VM is locked ($conf->{'lock'})\n" if $conf->{'lock'}; } +sub has_lock { + my ($conf, $lock) = @_; + return $conf->{lock} && (!defined($lock) || $lock eq $conf->{lock}); +} + sub check_protection { my ($vm_conf, $err_msg) = @_; diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook index 29e7808..28e1a36 100755 --- a/src/lxc-pve-prestart-hook +++ b/src/lxc-pve-prestart-hook @@ -63,7 +63,9 @@ __PACKAGE__->register_method ({ return undef if ! -f PVE::LXC::config_file($vmid); my $conf = PVE::LXC::load_config($vmid); - PVE::LXC::check_lock($conf) if !$ENV{PVE_SKIPLOCK}; + if (!$ENV{PVE_SKIPLOCK} && !PVE::LXC::has_lock($conf, 'mounted')) { + PVE::LXC::check_lock($conf); + } my $storage_cfg = PVE::Storage::config();