[pve-devel] [PATCH container 3/8] split open_namespace out of enter_namespace
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Nov 8 11:06:04 CET 2019
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
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 3bbaa36..d40f490 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -1032,12 +1032,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
More information about the pve-devel
mailing list