[pve-devel] [PATCH container 4/8] add get_container_namespace helper

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Nov 8 11:06:05 CET 2019


Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 src/PVE/LXC.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index d40f490..1225c8b 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1047,6 +1047,19 @@ my $enter_namespace = sub {
     close $fd;
 };
 
+my $get_container_namespace = sub {
+    my ($vmid, $pid, $kind) = @_;
+
+    my $pidfd;
+    if (!defined($pid)) {
+	# Pin the pid while we're grabbing its stuff from /proc
+	($pid, $pidfd) = open_lxc_pid($vmid)
+	    or die "failed to open pidfd of container $vmid\'s init process\n";
+    }
+
+    return $open_namespace->($vmid, $pid, $kind);
+};
+
 my $do_syncfs = sub {
     my ($vmid, $pid, $socket) = @_;
 
-- 
2.20.1





More information about the pve-devel mailing list