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 E6F041FF0BC for ; Wed, 02 Dec 2026 16:19:35 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1C4C92182E; Wed, 02 Dec 2026 16:19:16 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v4 06/21] migrate: factor out whether the running virtual CPU is kept Date: Wed, 2 Dec 2026 16:18:02 +0100 Message-ID: <20261202151831.414110-7-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261202151831.414110-1-j.theisen@proxmox.com> References: <20261202151831.414110-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: 1796224730681 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.057 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: VYYKGEY5LEQNBA3KJ5MFZLR777QQFV2N X-Message-ID-Hash: VYYKGEY5LEQNBA3KJ5MFZLR777QQFV2N 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 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 67b72598..d3f6f155 100644 --- a/src/PVE/QemuMigrate.pm +++ b/src/PVE/QemuMigrate.pm @@ -242,7 +242,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 466517da..e0eec8b1 100644 --- a/src/PVE/QemuMigrate/Helpers.pm +++ b/src/PVE/QemuMigrate/Helpers.pm @@ -113,6 +113,22 @@ sub check_local_resources { return wantarray ? (\@loc_res, $mapped_res, $missing_mappings_by_node) : \@loc_res; } +=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; +} + sub set_migration_caps { my ($vmid, $savevm) = @_; -- 2.47.3