[pve-devel] [PATCH pve-container 3/9] add function umount_raw_file

Wolfgang Link w.link at proxmox.com
Wed Nov 18 09:30:00 CET 2015


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

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index d6cea24..383a6da 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -2022,6 +2022,28 @@ sub check_ct_modify_config_perm {
     return 1;
 }
 
+sub umount_raw_file {
+    my ($mountpoint, $dev, $mounted) = @_;
+
+    if ($mounted) {
+	umount_mp($mountpoint, 1);
+    }
+
+    if ($dev) {
+	if (($dev =~ m!^/dev/loop\d+!) && !$mounted) {
+
+	    PVE::Tools::run_command(['losetup', '-d',  $dev]);
+	    warn $@ if $@;
+
+	} elsif ($dev =~ m!^/dev/rbd\d+!) {
+
+	    PVE::Tools::run_command(['rbd', 'unmap',  $dev]);
+	    warn $@ if $@;
+
+	}
+    }
+}
+
 sub umount_mp {
     my($mount_path, $noerr) = @_;
 
-- 
2.1.4




More information about the pve-devel mailing list