Signed-off-by: Alexandre Derumier <aderum...@odiso.com> --- PVE/QemuServer.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index d1507d6..e646503 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4620,6 +4620,7 @@ sub vmconfig_hotplug_pending { } elsif ($opt =~ m/^net(\d+)$/) { die "skip\n" if !$hotplug_features->{network}; vm_deviceunplug($vmid, $conf, $opt); + vmconfig_delete_net_ip($conf, $vmid, $1); } elsif (is_valid_drivename($opt)) { die "skip\n" if !$hotplug_features->{disk} || $opt =~ m/(ide|sata)(\d+)/; vm_deviceunplug($vmid, $conf, $opt); @@ -4805,6 +4806,9 @@ sub vmconfig_apply_pending { } elsif (defined($conf->{$opt}) && is_valid_drivename($opt)) { vmconfig_delete_or_detach_drive($vmid, $storecfg, $conf, $opt, $force); } + if($opt =~ m/net(\d+)$/) { + vmconfig_delete_net_ip($conf, $vmid, $1); + } }; if (my $err = $@) { $add_apply_error->($opt, $err); @@ -4864,6 +4868,25 @@ sub vmconfig_update_net_ip { } +sub vmconfig_delete_net_ip { + my ($conf, $vmid, $id) = @_; + + my $netid = "net$id"; + my $ipconfigid = "ipconfig$id"; + my $net = PVE::QemuServer::parse_net($conf->{pending}->{$netid}) if $conf->{pending}->{$netid}; + my $oldnet = PVE::QemuServer::parse_net($conf->{$netid}) if $conf->{$netid}; + my $hostname = $conf->{name}; + my $pending_hostname = "pending.".$hostname; + + eval { + PVE::QemuServer::Ipam::delete_net_ip($hostname, $oldnet, undef, "vm:$vmid net:$netid") if $oldnet; + }; + + eval { + PVE::QemuServer::Ipam::delete_net_ip($pending_hostname, $net, undef, "vm:$vmid net:$netid pending:1") if $net; + }; +} + sub vmconfig_update_net { my ($storecfg, $conf, $hotplug, $vmid, $opt, $value, $arch, $machine_type) = @_; -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel