From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 425731FF16B for ; Fri, 7 Nov 2025 15:44:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 93ACB15692; Fri, 7 Nov 2025 15:45:09 +0100 (CET) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Fri, 7 Nov 2025 15:43:41 +0100 Message-ID: <20251107144429.126790-4-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251107144429.126790-1-f.ebner@proxmox.com> References: <20251107144429.126790-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1762526652833 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.018 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH qemu-server v2 3/8] cpu config: introduce is_abstracted() helper X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" The helper reports whether the CPU configuration cannot be determined from the configuration alone. Currently, this means using a custom model, because that depends on the contents of the custom model configuration. The next commit will add an abstract flag that depends on the host. Note that parse_property_string() returns a hash reference or fails, so there is no need to check its return value for evaluating to true in boolean context. Even if the check were necessary, having no result should be treated as a failure, not quietly ignored. Signed-off-by: Fiona Ebner --- New in v2. src/PVE/QemuMigrate.pm | 11 +++-------- src/PVE/QemuServer/CPUConfig.pm | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/PVE/QemuMigrate.pm b/src/PVE/QemuMigrate.pm index 78954c20..063fd6f2 100644 --- a/src/PVE/QemuMigrate.pm +++ b/src/PVE/QemuMigrate.pm @@ -226,14 +226,9 @@ sub prepare { $self->{forcemachine} = PVE::QemuServer::Machine::qemu_machine_pxe($vmid, $conf); - # To support custom CPU types, we keep QEMU's "-cpu" parameter intact. - # Since the parameter itself contains no reference to a custom model, - # this makes migration independent of changes to "cpu-models.conf". - if ($conf->{cpu}) { - my $cpuconf = PVE::JSONSchema::parse_property_string('pve-cpu-conf', $conf->{cpu}); - if ($cpuconf && PVE::QemuServer::CPUConfig::is_custom_model($cpuconf->{cputype})) { - $self->{forcecpu} = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid); - } + # To support abstracted CPU configurations, keep QEMU's "-cpu" parameter intact. + if ($conf->{cpu} && PVE::QemuServer::CPUConfig::is_abstracted($conf->{cpu})) { + $self->{forcecpu} = PVE::QemuServer::CPUConfig::get_cpu_from_running_vm($pid); } # Do not treat a suspended VM as paused, as it might wake up diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm index ebec42d5..4cbd7b48 100644 --- a/src/PVE/QemuServer/CPUConfig.pm +++ b/src/PVE/QemuServer/CPUConfig.pm @@ -567,6 +567,31 @@ sub print_cpu_device { return "$cpu-x86_64-cpu,id=cpu$id,socket-id=$current_socket,core-id=$current_core,thread-id=0"; } +=head3 is_abstracted + + if (is_abstracted($conf->{cpu})) { + # better check running CPU of QEMU instance + } + +Check if the configured CPU is abstracted in any way, meaning that the actual CPU model cannot be +determined from the configuration alone. Possible abstractions: + +=over + +=item custom model: can change with updates to the custom model configuration + +=back + +=cut + +sub is_abstracted { + my ($cpu_property_string) = @_; + + my $cpu_conf = PVE::JSONSchema::parse_property_string('pve-cpu-conf', $cpu_property_string); + + return is_custom_model($cpu_conf->{cputype}); +} + # Resolves multiple arrays of hashes representing CPU flags with metadata to a # single string in QEMU "-cpu" compatible format. Later arrays have higher # priority. -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel