From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 4D31D1FF0DE for ; Thu, 19 Nov 2026 11:40:37 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id AC2B521AAA; Thu, 19 Nov 2026 11:37:02 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH manager v4 34/41] api: bulk migrate: refuse targets that would drop the guest identity Date: Thu, 19 Nov 2026 11:34:20 +0100 Message-ID: <20261119103551.1666964-35-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261119103551.1666964-1-t.lamprecht@proxmox.com> References: <20261119103551.1666964-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795084557413 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.160 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: SFXJCE7XN4FT56YCNAHNJT3OZ24ICIHA X-Message-ID-Hash: SFXJCE7XN4FT56YCNAHNJT3OZ24ICIHA X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A node that keeps the guest identity refuses to migrate a guest to a node that does not. A bulk migration to such a node therefore logged one warning per guest and only failed after it had tried all of them. Check the target once, before the task starts. The migration of all guests of a node runs on that node. The check there gives the same result as the check of each single migration. The cluster-wide bulk migration is different. It runs on the node that handles the request, while each guest migrates from its own node, and a source node with an older version does not check the target at all. So refuse there only if at least one selected guest that is not on the target yet is on a node that keeps the identity. Guests can then still move between two older nodes, for example to empty a node before its upgrade. Check first that the target node exists, because the version check would report a mistyped node name as a node without version information. Signed-off-by: Thomas Lamprecht --- changes v3 -> v4: * cluster-wide bulk migration: refuse up front only if a selected guest that is not on the target yet sits on a node that keeps the identity, so that guests can still move between two older nodes, for example to empty one before its upgrade; v3 refused that * commit message: plainer wording, same content changes v2 -> v3: * also check the target of the cluster-wide bulk migration once before the task starts, after checking that the node exists; subject changed accordingly changes v1 -> v2: * new in v2 PVE/API2/Cluster/BulkAction/Guest.pm | 17 +++++++++++++++++ PVE/API2/Nodes.pm | 3 +++ 2 files changed, 20 insertions(+) diff --git a/PVE/API2/Cluster/BulkAction/Guest.pm b/PVE/API2/Cluster/BulkAction/Guest.pm index a55ea2ea..ee75b4a1 100644 --- a/PVE/API2/Cluster/BulkAction/Guest.pm +++ b/PVE/API2/Cluster/BulkAction/Guest.pm @@ -6,6 +6,7 @@ use warnings; use PVE::APIClient::LWP; use PVE::Cluster; use PVE::Exception qw(raise raise_perm_exc raise_param_exc); +use PVE::GuestIdentity; use PVE::INotify; use PVE::JSONSchema qw(get_standard_option); use PVE::RESTEnvironment qw(log_warn); @@ -760,6 +761,22 @@ __PACKAGE__->register_method({ check_guest_permissions($rpcenv, $authuser, $vmlist, ['VM.Migrate']); + my $target = $param->{target}; + PVE::Cluster::check_node_exists($target); + + # A source node that keeps the guest identity refuses an older target for each guest, so + # refuse once instead. Older source nodes do not check and are left to their own calls. + my $cluster_vmlist = PVE::Cluster::get_vmlist() // {}; + my $guests = $cluster_vmlist->{ids} // {}; + my $sources = {}; + for my $vmid (scalar($vmlist->@*) ? $vmlist->@* : keys $guests->%*) { + my $node = $guests->{$vmid} ? $guests->{$vmid}->{node} : undef; + $sources->{$node} = 1 if defined($node) && $node ne $target; + } + if (grep { !PVE::GuestIdentity::node_identity_unsupported($_) } keys $sources->%*) { + PVE::GuestIdentity::assert_node_supports_identity($target); + } + my $code = sub { my $list = PVE::API2::Nodes::Nodeinfo::get_filtered_vmlist(undef, $vmlist_string, 1, 1); diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index 07b3ce1f..8dc409bf 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -23,6 +23,7 @@ use PVE::Cluster qw(cfs_read_file); use PVE::DataCenterConfig; use PVE::Exception qw(raise raise_perm_exc raise_param_exc); use PVE::Firewall; +use PVE::GuestIdentity; use PVE::HA::Config; use PVE::HA::Env::PVE2; use PVE::INotify; @@ -2766,6 +2767,8 @@ __PACKAGE__->register_method({ PVE::Cluster::check_cfs_quorum(); PVE::Cluster::check_node_exists($target); + # refuse once instead of failing the migration of every guest + PVE::GuestIdentity::assert_node_supports_identity($target); my $datacenterconfig = cfs_read_file('datacenter.cfg'); # prefer parameter over datacenter cfg settings -- 2.47.3