[pve-devel] [PATCH pve-container 4/4] vzdump:lxc: unshare mount namespace

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Sep 17 13:07:00 CEST 2015


Enter a new mount namespace for stop and snapshot backups
where we need to mount the container to a temporary
location.
---
 src/PVE/VZDump/LXC.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index c9a75dd..2d4b85a 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -152,6 +152,13 @@ sub prepare {
     } else {
 	die "unknown mode '$mode'\n"; # should not happen
     }
+
+    if ($mode ne 'suspend') {
+	# If we preform mount operations, let's unshare the mount namespace
+	# to not influence the running host.
+	PVE::Tools::unshare(PVE::Tools::CLONE_NEWNS);
+	PVE::Tools::run_command(['mount', '--make-rprivate', '/']);
+    }
 }
 
 sub lock_vm {
-- 
2.1.4





More information about the pve-devel mailing list