From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id F25D81FF0B3 for ; Fri, 25 Sep 2026 11:43:33 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 24729217B1; Fri, 25 Sep 2026 11:42:38 +0200 (CEST) From: Arthur Bied-Charreton To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3 09/16] api: destroy_vm: add option to handle dangling IPSet references Date: Fri, 25 Sep 2026 11:42:23 +0200 Message-ID: <20260925094230.844917-10-a.bied-charreton@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260925094230.844917-1-a.bied-charreton@proxmox.com> References: <20260925094230.844917-1-a.bied-charreton@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.985 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: UEON3R6IH4A4N7JDIVHUDUTMEF4X6RFM X-Message-ID-Hash: UEON3R6IH4A4N7JDIVHUDUTMEF4X6RFM X-MailFrom: abied-charreton@jett.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: For each guest with IPAM entries, a 'guest-ipam-' IPSet is auto-generated [0]. Therefore, deleting a guest can lead to firewall rules referencing non-existing IPSets, which the firewall fails to parse and ignores. Add a 'dangling-ipset-references' option for DELETE /nodes/{node}/qemu/{vmid} allowing to 'drop' rules referencing now-deleted IPSets, to 'disable' them, or to 'keep' them as they are. [0] https://pve.proxmox.com/wiki/Software-Defined_Network#pvesdn_firewall_integration Signed-off-by: Arthur Bied-Charreton --- src/PVE/API2/Qemu.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index 922c6599..75219ad0 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -2818,6 +2818,16 @@ __PACKAGE__->register_method({ optional => 1, default => 0, }, + 'dangling-ipset-references' => { + type => 'string', + enum => ['keep', 'disable', 'drop'], + optional => 1, + default => 'keep', + description => 'Handle firewall rules referencing the IPSet auto-generated for ' + . 'this guest (\'guest-ipam-\'). Use \'disable\' to disable them, or ' + . '\'drop\' to remove them entirely. Kept as they are, they reference an IPSet ' + . 'that no longer exists and are dropped from the generated ruleset.', + }, }, }, returns => { @@ -2895,6 +2905,16 @@ __PACKAGE__->register_method({ } } + my $action = $param->{'dangling-ipset-references'} // 'keep'; + if ($action ne 'keep') { + eval { + PVE::Firewall::Helpers::update_guest_ipam_ipset_refs( + $vmid, $action, + ); + }; + warn "could not $action dangling IPSet references: $@" if $@; + } + # only now remove the zombie config, else we can have reuse race PVE::QemuConfig->destroy_config($vmid); }, -- 2.47.3