]> git.proxmox.com Git - pve-container.git/commitdiff
allow starting and stopping a mounted container
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 26 Feb 2016 10:42:12 +0000 (11:42 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 27 Feb 2016 13:27:41 +0000 (14:27 +0100)
src/PVE/API2/LXC/Status.pm
src/PVE/LXC.pm
src/lxc-pve-prestart-hook

index e91ac7c9eefacebe1e78fa6d51ed0851b2b5da4b..a4498d1f77cd42747337222ebe740af921b2b023 100644 (file)
@@ -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'];
 
index 8ebf3dbc49c6da52fba68560f23e557f19fc0279..0f8cff35b5646599c1a7f16333cbbcbecbd9eb53 100644 (file)
@@ -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) = @_;
 
index 29e780893285387e7b63d1a24106b408b291b63d..28e1a363bd5de86f7acc79c6be8775b20a6391a5 100755 (executable)
@@ -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();