[pve-devel] [PATCH v4 container 07/12] add get_container_namespace helper

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Nov 20 08:31:02 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 2a79327..3ad807d 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1044,6 +1044,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