This patch prevents VMs 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.her...@proxmox.com>
---
 PVE/API2/Qemu.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index ec45d5ff..73580c64 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1065,6 +1065,18 @@ __PACKAGE__->register_method({
            raise_perm_exc();
        }
 
+       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;
+               }
+           }
+       }
+
        if ($archive) {
            for my $opt (sort keys $param->%*) {
                if (PVE::QemuServer::Drive::is_valid_drivename($opt)) {
-- 
2.39.5



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

Reply via email to