[pve-devel] [PATCH container 3/4] fix #5900: do not create container if dhcp range is exhausted
Daniel Herzig
d.herzig at proxmox.com
Thu Dec 5 17:33:31 CET 2024
This patch prevents containers to be created if their bridge is
associated with a SDN zone with dnsmasq automatic dhcp enabled, and if
the dhcp-range is exhausted or unset.
Signed-off-by: Daniel Herzig <d.herzig at proxmox.com>
---
src/PVE/API2/LXC.pm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 213e518..35fb0a6 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -244,6 +244,18 @@ __PACKAGE__->register_method({
PVE::LXC::Config->check_protection($conf, "unable to restore CT $vmid");
}
+ for my $opt (keys %$param) {
+ if ($opt =~ /net/) {
+ my $bridge_err;
+ my $bridge = PVE::GuestHelpers::get_bridge(${param}->{$opt});
+ if (defined($bridge)) {
+ eval { PVE::Network::SDN::Dhcp::test_bridge_for_sdn_dnsmasq($bridge) };
+ ${bridge_err}->{$opt} = $@ if $@;
+ raise_param_exc($bridge_err) if $bridge_err;
+ }
+ }
+ }
+
my $password = extract_param($param, 'password');
my $ssh_keys = extract_param($param, 'ssh-public-keys');
PVE::Tools::validate_ssh_public_keys($ssh_keys) if defined($ssh_keys);
--
2.39.5
More information about the pve-devel
mailing list