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 690331FF066 for ; Tue, 24 Nov 2026 17:33:02 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 621A721775; Tue, 24 Nov 2026 17:32:22 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v2 07/20] migrate: factor out whether the running virtual CPU is kept Date: Tue, 24 Nov 2026 17:30:31 +0100 Message-ID: <20261124163136.320992-8-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: 1795537921998 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.078 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: EUMDLSCZ2DFXX6LHJYFMGHX5EZTU7RBS X-Message-ID-Hash: EUMDLSCZ2DFXX6LHJYFMGHX5EZTU7RBS 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 c8af09fe..245b79d7 100644 --- a/src/PVE/QemuMigrate.pm +++ b/src/PVE/QemuMigrate.pm @@ -243,7 +243,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 18cba4af..844bc250 100644 --- a/src/PVE/QemuMigrate/Helpers.pm +++ b/src/PVE/QemuMigrate/Helpers.pm @@ -323,6 +323,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