Signed-off-by: Wolfgang Bumiller <w.bumil...@proxmox.com>
---
No changes.

 src/PVE/LXC.pm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index c51e59e..c07a597 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1033,12 +1033,18 @@ sub update_ipconfig {
 
 }
 
+my $open_namespace = sub {
+    my ($vmid, $pid, $kind) = @_;
+    sysopen my $fd, "/proc/$pid/ns/$kind", O_RDONLY
+       or die "failed to open $kind namespace of container $vmid: $!\n";
+    return $fd;
+};
+
 my $enter_namespace = sub {
-    my ($vmid, $pid, $which, $type) = @_;
-    sysopen my $fd, "/proc/$pid/ns/$which", O_RDONLY
-       or die "failed to open $which namespace of container $vmid: $!\n";
+    my ($vmid, $pid, $kind, $type) = @_;
+    my $fd = $open_namespace->($vmid, $pid, $kind);
     PVE::Tools::setns(fileno($fd), $type)
-       or die "failed to enter $which namespace of container $vmid: $!\n";
+       or die "failed to enter $kind namespace of container $vmid: $!\n";
     close $fd;
 };
 
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to