all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH qemu-server v4 10/13] network: sdn: push the DHCP mappings of a guest when it resumes
Date: Tue,  3 Nov 2026 19:55:56 +0100	[thread overview]
Message-ID: <20261103185559.420277-11-h.laimer@proxmox.com> (raw)
In-Reply-To: <20261103185559.420277-1-h.laimer@proxmox.com>

A mapping edit and a migration of the guest exclude each other, but
an edit through a node not yet upgraded takes no lock and writes no
reservation, so it can land while the guest is migrated. Every resume
now pushes the mapping of each NIC of the guest on the local node
before the guest continues, and the last step of a live migration
resumes the target after the config moved, so the target serves what
the cache vouches for. The push reads the cache only and asks the
IPAM for nothing, so the paused guest waits on no request.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 src/PVE/QemuServer/Network.pm  | 17 +++++++++++++++++
 src/PVE/QemuServer/RunState.pm |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/src/PVE/QemuServer/Network.pm b/src/PVE/QemuServer/Network.pm
index b4893c015646..b063f5b75b36 100644
--- a/src/PVE/QemuServer/Network.pm
+++ b/src/PVE/QemuServer/Network.pm
@@ -272,6 +272,23 @@ sub add_random_macs {
     }
 }
 
+# every resume pushes the current mapping of each NIC, so the target of a
+# live migration, resumed after the config moved, holds what the cache
+# vouches for. The push takes it from the cache and asks the IPAM for
+# nothing, so the paused guest waits on no request
+sub add_nets_dhcp_mapping {
+    my ($conf) = @_;
+
+    for my $opt (keys %$conf) {
+        next if $opt !~ m/^net\d+$/;
+        my $net = parse_net($conf->{$opt}, 1) or next;
+        next if !$net->{bridge} || !$net->{macaddr};
+        # a resume does not fail on its DHCP backend
+        eval { PVE::Network::SDN::Dhcp::update_mapping($net->{bridge}, $net->{macaddr}, 1) };
+        warn $@ if $@;
+    }
+}
+
 sub add_nets_bridge_fdb {
     my ($conf, $vmid) = @_;
 
diff --git a/src/PVE/QemuServer/RunState.pm b/src/PVE/QemuServer/RunState.pm
index 889ddd28287b..828d79159e90 100644
--- a/src/PVE/QemuServer/RunState.pm
+++ b/src/PVE/QemuServer/RunState.pm
@@ -181,6 +181,8 @@ sub vm_resume($vmid, $skiplock = undef, $nocheck = undef) {
 
             PVE::QemuServer::Network::add_nets_bridge_fdb($conf, $vmid)
                 if $resume_cmd eq 'cont';
+            PVE::QemuServer::Network::add_nets_dhcp_mapping($conf)
+                if $resume_cmd eq 'cont';
 
             mon_cmd($vmid, $resume_cmd);
         },
-- 
2.47.3





  parent reply	other threads:[~2026-11-03 18:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 18:55 [PATCH docs/manager/network/qemu-server v4 00/13] sdn: improve MAC cache, DHCP reservations and scope both to the vnet Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 01/13] sdn: ipam: stop caching IPAM misses Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 02/13] sdn: ipam: cache a MAC lookup's answer under the cluster lock Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 03/13] sdn: ipam: read the MAC cache case-insensitively Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 04/13] sdn: dhcp: replace a stale dnsmasq reservation instead of dropping it Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 05/13] sdn: ipam: release an address the built-in IPAM no longer holds Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 06/13] sdn: dhcp: update reservations when IP mappings change Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 07/13] sdn: ipam: look a MAC up within the vnet's subnets Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 08/13] sdn: ipam: keep the MAC cache per vnet Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-network v4 09/13] sdn: ipam: give each zone a VRF in NetBox and a section in phpIPAM Hannes Laimer
2026-11-03 18:55 ` Hannes Laimer [this message]
2026-11-03 18:55 ` [PATCH pve-manager v4 11/13] ui: sdn: dhcp tree: do not merge the same subnet in different zones Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-manager v4 12/13] ui: sdn: ipam: add the zone namespace options Hannes Laimer
2026-11-03 18:55 ` [PATCH pve-docs v4 13/13] sdn: ipam: document zone namespaces in NetBox and phpIPAM Hannes Laimer
2026-11-04  9:56 ` superseded: [PATCH docs/manager/network/qemu-server v4 00/13] sdn: improve MAC cache, DHCP reservations and scope both to the vnet Hannes Laimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261103185559.420277-11-h.laimer@proxmox.com \
    --to=h.laimer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal