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 B87CF1FF0C0 for ; Wed, 18 Nov 2026 16:43:02 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 34D8121856; Wed, 18 Nov 2026 16:42:43 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server 07/15] migrate: factor out whether the running virtual CPU is kept Date: Wed, 18 Nov 2026 16:40:38 +0100 Message-ID: <20261118154207.424260-8-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118154207.424260-1-j.theisen@proxmox.com> References: <20261118154207.424260-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: 1795016553202 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.088 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: 7AJJ4XRBTXITFC4ZKC6RIW3BSSPHLDM4 X-Message-ID-Hash: 7AJJ4XRBTXITFC4ZKC6RIW3BSSPHLDM4 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 abstracted CPU configurations, a live migration starts the target instance with the QEMU CPU of the running instance. Factor out this condition, so that checks whether the target can run that CPU can use the same one as the migration itself. Signed-off-by: Jonas Theisen --- src/PVE/QemuMigrate.pm | 2 +- src/PVE/QemuMigrate/Helpers.pm | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm index bd157845..bd3f7257 100644 --- a/src/PVE/QemuMigrate.pm +++ b/src/PVE/QemuMigrate.pm @@ -235,7 +235,7 @@ sub prepare { $self->{forcemachine} = PVE::QemuServer::Machine::qemu_machine_pxe($vmid, $conf); # To support abstracted CPU configurations, keep QEMU's "-cpu" parameter intact. - if ($conf->{cpu} && PVE::QemuServer::CPUConfig::is_abstracted($conf->{cpu})) { + if (PVE::QemuMigrate::Helpers::is_running_cpu_kept($conf)) { $self->{forcecpu} = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid); } diff --git a/src/PVE/QemuMigrate/Helpers.pm b/src/PVE/QemuMigrate/Helpers.pm index 0a0f3787..67f3c0e3 100644 --- a/src/PVE/QemuMigrate/Helpers.pm +++ b/src/PVE/QemuMigrate/Helpers.pm @@ -310,6 +310,22 @@ my sub get_target_cpu_issues { return ($issues, $complete); } +=head3 is_running_cpu_kept + + my $kept = is_running_cpu_kept($conf); + +Returns whether a live migration of the VM with the configuration C<$conf> starts the target +instance with the QEMU CPU of the running instance, instead of generating it again from the +configuration. This is the case for abstracted CPU configurations, as their QEMU CPU depends on +more than the configuration. + +=cut + +sub is_running_cpu_kept { + my ($conf) = @_; + return $conf->{cpu} && PVE::QemuServer::CPUConfig::is_abstracted($conf->{cpu}) ? 1 : 0; +} + =head3 check_target_cpu_compatibility my ($issues_by_node, $unchecked_nodes) = check_target_cpu_compatibility($conf, $pid, $nodes); -- 2.47.3