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.bumil...@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


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to