From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 17FE61FF066 for ; Tue, 24 Nov 2026 17:34:24 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 4EEEF21887; Tue, 24 Nov 2026 17:32:47 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v2 15/20] api: migrate: check the CPU of the target before requesting HA migration Date: Tue, 24 Nov 2026 17:30:39 +0100 Message-ID: <20261124163136.320992-16-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261124163136.320992-1-j.theisen@proxmox.com> References: <20261124163136.320992-1-j.theisen@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795537938723 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.075 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: 74URZUDE4JWXDBNOZEODS2XPSPWPDUTY X-Message-ID-Hash: 74URZUDE4JWXDBNOZEODS2XPSPWPDUTY X-MailFrom: j.theisen@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: For HA-managed VMs, the migrate API only requests the migration from the HA stack, which then runs it in a separate task on the LRM. If the target node's CPU cannot run the VM, that task fails, but the API call and its task have already succeeded, so the caller only learns about it from the LRM's task log or the HA status. Run the CPU compatibility check before requesting the HA migration, as done for the storage checks already, so that the API call fails with the reason directly. Options that override an incompatibility, like 'allow-missing-cpu-flags', are honored as in the migration itself. The warnings are not reported here, as the migration task of the LRM logs them. Migrations that the HA stack starts on its own, for example for maintenance mode or automatic rebalancing, do not use this API path and still fail in the migration task, after which the HA stack currently retries them without backoff, see bug #8059. Link: https://bugzilla.proxmox.com/show_bug.cgi?id=8059 Signed-off-by: Jonas Theisen --- src/PVE/API2/Qemu.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index 14032b9d..55212792 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -5956,7 +5956,8 @@ __PACKAGE__->register_method({ PVE::QemuConfig->check_lock($conf); - if (PVE::QemuServer::check_running($vmid)) { + my $pid = PVE::QemuServer::check_running($vmid); + if ($pid) { die "can't migrate running VM without --online\n" if !$param->{online}; my $repl_conf = PVE::ReplicationConfig->new(); @@ -6002,6 +6003,11 @@ __PACKAGE__->register_method({ } if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') { + # The HA stack migrates the VM in a separate task later, so refuse an incompatible + # target here, where the caller sees why. The task logs the warnings. + PVE::QemuMigrate::Helpers::assert_target_cpu_compatibility( + $vmid, $conf, $pid, $target, $param, + ) if $param->{online}; my $hacmd = sub { my $upid = shift; -- 2.47.3