[pve-devel] [PATCH v2 container 5/9] add get_container_namespace helper

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Nov 13 10:33:15 CET 2019


Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
No changes.

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

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index c07a597..6bea0b7 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1048,6 +1048,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