[pve-devel] [PATCH 1/2] add is mounted check befor try to unmount disk.

Wolfgang Link w.link at proxmox.com
Wed Sep 2 14:22:34 CEST 2015


---
 src/PVE/LXC.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index eb69fac..357fc81 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1912,6 +1912,12 @@ sub dettach_loops {
     }
 }
 
+sub is_mounted {
+    my ($mountpoint) = @_;
+
+    return !system("mount | grep -e \"$mountpoint \" > /dev/null");
+}
+
 sub umount_all {
     my ($vmid, $storage_cfg, $conf, $noerr) = @_;
 
@@ -1931,7 +1937,8 @@ sub umount_all {
 	my $mount_path = "$rootdir/$mount";
 	$mount_path =~ s!/+!/!g;
 
-	# fixme: test if mounted?
+	return if !is_mounted($mount_path);
+
 	eval {
 	    PVE::Tools::run_command(['umount', '-d', $mount_path]);
 	};
-- 
2.1.4





More information about the pve-devel mailing list