]> git.proxmox.com Git - pve-container.git/commitdiff
fix #2512: post-stop: unmount stage mps before cleanup
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 12 Dec 2019 10:36:05 +0000 (11:36 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Dec 2019 11:30:42 +0000 (12:30 +0100)
With staged mount points we now have mount points also
mounted in our staging temp directory, and we keep them
there in order to prevent hotplugged mounts (which can be
unmounted by the container) to disconnect from their loop
devices, so we need to clean those up as well before we can
run any cleanups.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/lxc-pve-poststop-hook

index 2a83872246c3edc668f7a12fd6391437d2d47716..1dba48c02f83ad48bb86c0e9b4deff47a1905ce3 100755 (executable)
@@ -3,8 +3,9 @@
 use strict;
 use warnings;
 
-use POSIX;
 use File::Path;
+use IO::Dir;
+use POSIX;
 
 use PVE::GuestHelpers;
 use PVE::LXC::Config;
@@ -23,7 +24,17 @@ PVE::LXC::Tools::lxc_hook('post-stop', 'lxc', sub {
 
     my $storage_cfg = PVE::Storage::config();
 
-    PVE::Tools::run_command(['umount', '--recursive', $vars->{ROOTFS_PATH}]);
+    PVE::Tools::run_command(['umount', '--recursive', '--', $vars->{ROOTFS_PATH}]);
+    my $staging_dir = PVE::LXC::get_staging_tempfs();
+    if (my $dh = IO::Dir->new($staging_dir)) {
+       while (defined(my $dir = $dh->read)) {
+           next if $dir eq '.' || $dir eq '..';
+           eval {
+               PVE::Tools::run_command(['umount', '--', "$staging_dir/$dir"]);
+           };
+           warn $@ if $@;
+       }
+    }
 
     PVE::LXC::vm_stop_cleanup($storage_cfg, $vmid, $conf);