[pve-devel] [PATCH container v3 09/13] manage DHCP for containers with custom entrypoint
Filip Schauer
f.schauer at proxmox.com
Wed Jul 9 15:41:10 CEST 2025
On 09/07/2025 14:34, Filip Schauer wrote:
> @@ -2827,6 +2882,30 @@ sub vm_start { }
> PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-start'); + if
> ($conf->{ipmanagehost}) { + my @dhcpv4_interfaces = (); + my
> @dhcpv6_interfaces = (); + foreach my $k (sort keys %$conf) { + next
> if $k !~ m/^net(\d+)$/; + my $d =
> PVE::LXC::Config->parse_lxc_network($conf->{$k}); + push
> @dhcpv4_interfaces, $d->{name} if $d->{ip} && $d->{ip} eq 'dhcp'; +
> push @dhcpv6_interfaces, $d->{name} if $d->{ip6} && $d->{ip6} eq
> 'dhcp'; + } + + my $pid = PVE::LXC::find_lxc_pid($vmid);
Replace this line with:
+ my ($pid, $pidfd) = PVE::LXC::open_lxc_pid($vmid);
to keep the $pidfd around for as long as $rootdir is in use.
> + my $rootdir = "/proc/$pid/root"; + + foreach my $eth
> (@dhcpv4_interfaces) { + eval { manage_dhclient('start', $vmid, 4,
> $eth, $rootdir) }; + PVE::RESTEnvironment::log_warn("DHCP failed -
> $@") if $@; + } + + foreach my $eth (@dhcpv6_interfaces) { + eval {
> manage_dhclient('start', $vmid, 6, $eth, $rootdir) }; +
> PVE::RESTEnvironment::log_warn("DHCP failed - $@") if $@; + } + } +
> return; }
More information about the pve-devel
mailing list