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 331D11FF0B7 for ; Mon, 30 Nov 2026 19:11:21 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 6BBC02177D; Mon, 30 Nov 2026 19:10:52 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3 06/18] migrate: factor out whether the running virtual CPU is kept Date: Mon, 30 Nov 2026 19:09:38 +0100 Message-ID: <20261130181007.596064-7-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261130181007.596064-1-j.theisen@proxmox.com> References: <20261130181007.596064-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: 1796062228715 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 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: 54NC4ZYPI2YGZYJ77KNGQTUM5BTUY7U6 X-Message-ID-Hash: 54NC4ZYPI2YGZYJ77KNGQTUM5BTUY7U6 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 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