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 v5 10/13] network: sdn: push the DHCP mappings of a guest when it resumes
Date: Wed,  4 Nov 2026 10:55:17 +0100	[thread overview]
Message-ID: <20261104095520.398544-11-h.laimer@proxmox.com> (raw)
In-Reply-To: <20261104095520.398544-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. A busy reservation lock is not waited
for, since the push holding it writes the line as well. An IPAM that
does not answer then holds the resume up to the request's timeout,
and the migration task fails naming the resume. That beats serving
the guest a stale address.

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..59b21fcfb055 100644
--- a/src/PVE/QemuServer/Network.pm
+++ b/src/PVE/QemuServer/Network.pm
@@ -272,6 +272,23 @@ 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 for a busy reservation lock, the push
+# holding it writes the line as well
+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-04  9:56 UTC|newest]

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