public inbox for pve-devel@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 v6 10/13] network: sdn: push the DHCP mappings of a guest when it resumes
Date: Thu,  5 Nov 2026 10:35:26 +0100	[thread overview]
Message-ID: <20261105093529.209052-11-h.laimer@proxmox.com> (raw)
In-Reply-To: <20261105093529.209052-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 asks the IPAM only when the cache
cannot vouch for the address. The push does not wait long for a push
holding the reservation file. A failed request fails the task after
the guest continued, naming the IPAM's error. An IPAM that does not
answer holds the resume up to the request's timeout first, and a slow
one for every request the lookup makes. That beats serving the guest a
stale address.

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

diff --git a/src/PVE/QemuServer/Network.pm b/src/PVE/QemuServer/Network.pm
index b4893c015646..7ae448ea1369 100644
--- a/src/PVE/QemuServer/Network.pm
+++ b/src/PVE/QemuServer/Network.pm
@@ -272,6 +272,24 @@ sub add_random_macs {
     }
 }
 
+# a resume pushes the current mapping of each NIC. The target of a live
+# migration resumes after the config moved and serves the current addresses
+# from then on. The push does not wait long for a push holding the
+# reservation file
+sub add_nets_dhcp_mapping {
+    my ($conf) = @_;
+
+    my @errors;
+    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};
+        eval { PVE::Network::SDN::Dhcp::update_mapping($net->{bridge}, $net->{macaddr}, 1) };
+        push @errors, $@ if $@;
+    }
+    die join('', @errors) if @errors;
+}
+
 sub add_nets_bridge_fdb {
     my ($conf, $vmid) = @_;
 
diff --git a/src/PVE/QemuServer/RunState.pm b/src/PVE/QemuServer/RunState.pm
index 889ddd28287b..cf1e1873c39d 100644
--- a/src/PVE/QemuServer/RunState.pm
+++ b/src/PVE/QemuServer/RunState.pm
@@ -181,8 +181,16 @@ sub vm_resume($vmid, $skiplock = undef, $nocheck = undef) {
 
             PVE::QemuServer::Network::add_nets_bridge_fdb($conf, $vmid)
                 if $resume_cmd eq 'cont';
+            # a failed push is raised after the guest continued, so the task
+            # says what went wrong and the guest does not stay paused for it
+            my $dhcp_err;
+            if ($resume_cmd eq 'cont') {
+                eval { PVE::QemuServer::Network::add_nets_dhcp_mapping($conf) };
+                $dhcp_err = $@;
+            }
 
             mon_cmd($vmid, $resume_cmd);
+            die $dhcp_err if $dhcp_err;
         },
     );
 }
-- 
2.47.3





  parent reply	other threads:[~2026-11-05  9:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  9:35 [PATCH docs/manager/network/qemu-server v6 00/13] sdn: improve MAC cache, DHCP reservations and scope both to the vnet Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 01/13] sdn: ipam: stop caching IPAM misses Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 02/13] sdn: ipam: cache a MAC lookup's answer under the cluster lock Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 03/13] sdn: ipam: read the MAC cache case-insensitively Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 04/13] sdn: dhcp: replace a stale dnsmasq reservation instead of dropping it Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 05/13] sdn: ipam: release an address the built-in IPAM no longer holds Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 06/13] sdn: dhcp: update reservations when IP mappings change Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 07/13] sdn: ipam: look a MAC up within the vnet's subnets Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 08/13] sdn: ipam: keep the MAC cache per vnet Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-network v6 09/13] sdn: ipam: give each zone a VRF in NetBox and a section in phpIPAM Hannes Laimer
2026-11-05  9:35 ` Hannes Laimer [this message]
2026-11-05  9:35 ` [PATCH pve-manager v6 11/13] ui: sdn: dhcp tree: do not merge the same subnet in different zones Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-manager v6 12/13] ui: sdn: ipam: add the zone namespace options Hannes Laimer
2026-11-05  9:35 ` [PATCH pve-docs v6 13/13] sdn: ipam: document zone namespaces and the mapping edit 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=20261105093529.209052-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal