[pve-devel] [PATCH container 3/3] fix #2512: post-stop: unmount stage mps before cleanup

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Dec 12 11:36:05 CET 2019


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 at proxmox.com>
---
 src/lxc-pve-poststop-hook | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/lxc-pve-poststop-hook b/src/lxc-pve-poststop-hook
index 2a83872..1dba48c 100755
--- a/src/lxc-pve-poststop-hook
+++ b/src/lxc-pve-poststop-hook
@@ -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);
 
-- 
2.20.1




More information about the pve-devel mailing list