[pve-devel] [PATCH v4 pve-container 32/33] lxc-pve-prestart-hook : add_dhcp_mapping
Stefan Hanreich
s.hanreich at proxmox.com
Fri Nov 17 12:40:10 CET 2023
From: Alexandre Derumier <aderumier at odiso.com>
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
src/lxc-pve-prestart-hook | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook
index 936d0bf..fc577e4 100755
--- a/src/lxc-pve-prestart-hook
+++ b/src/lxc-pve-prestart-hook
@@ -21,6 +21,12 @@ use PVE::Storage;
use PVE::Syscall qw(:fsmount);
use PVE::Tools qw(AT_FDCWD O_PATH);
+my $have_sdn;
+eval {
+ require PVE::Network::SDN::Vnets;
+ $have_sdn = 1;
+};
+
my $WARNFD;
sub log_warn {
my ($vmid, $message) = @_;
@@ -140,6 +146,15 @@ PVE::LXC::Tools::lxc_hook('pre-start', 'lxc', sub {
}
PVE::Tools::file_set_contents($devlist_file, $devlist);
}
+
+ if ($have_sdn) {
+ for my $k (keys %$conf) {
+ next if $k !~ /^net(\d+)/;
+ my $net = PVE::LXC::Config->parse_lxc_network($conf->{$k});
+ next if $net->{type} ne 'veth';
+ PVE::Network::SDN::Vnets::add_dhcp_mapping($net->{bridge}, $net->{hwaddr});
+ }
+ }
});
# Leftover cgroups prevent lxc from starting without any useful information
--
2.39.2
More information about the pve-devel
mailing list