[pve-devel] [PATCH qemu-server 5/6] vm_destroy: delete ip from ipam
Alexandre Derumier
aderumier at odiso.com
Wed Nov 15 15:22:06 CET 2023
Co-Authored-By: Stefan Hanreich <s.hanreich at proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer.pm | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7248346..4c52026 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2341,6 +2341,9 @@ sub destroy_vm {
});
}
+ eval { delete_ifaces_ipams_ips($conf, $vmid)};
+ warn $@ if $@;
+
if (defined $replacement_conf) {
PVE::QemuConfig->write_config($vmid, $replacement_conf);
} else {
@@ -8644,4 +8647,18 @@ sub create_ifaces_ipams_ips {
}
}
+sub delete_ifaces_ipams_ips {
+ my ($conf, $vmid) = @_;
+
+ return if !$have_sdn;
+
+ foreach my $opt (keys %$conf) {
+ if ($opt =~ m/^net(\d+)$/) {
+ my $net = PVE::QemuServer::parse_net($conf->{$opt});
+ eval { PVE::Network::SDN::Vnets::del_ips_from_mac($net->{bridge}, $net->{macaddr}, $conf->{name}) };
+ warn $@ if $@;
+ }
+ }
+}
+
1;
--
2.39.2
More information about the pve-devel
mailing list