From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 49DF31FF137 for ; Tue, 17 Feb 2026 15:09:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 241FD6B6; Tue, 17 Feb 2026 15:10:40 +0100 (CET) From: Arthur Bied-Charreton To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server v3 2/2] cpu config: Add tests for arch/reported-model misconfigurations Date: Tue, 17 Feb 2026 15:06:52 +0100 Message-ID: <20260217141036.338747-2-a.bied-charreton@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260217141036.338747-1-a.bied-charreton@proxmox.com> References: <20260217141036.338747-1-a.bied-charreton@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.092 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 KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: KRUSHCSBWXA5CN2BOGD6D7QCITGVIWUG X-Message-ID-Hash: KRUSHCSBWXA5CN2BOGD6D7QCITGVIWUG X-MailFrom: abied-charreton@jett.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: Test that validate_cpu_conf denies custom CPU models with a 'reported-model' that does not exist on the specified (or default) 'arch'. Test that get_cpu_options denies configurations with custom CPU model arch not matching the VM arch. Signed-off-by: Arthur Bied-Charreton --- Changes since v2: * fix expected error message in custom-cpu-model-wrong-arch.conf, got out of sync with actual error message before submitting v2 src/test/Makefile | 5 +- .../cfg2cmd/custom-cpu-model-wrong-arch.conf | 9 +++ src/test/run_config2command_tests.pl | 4 ++ src/test/run_cpu_config_tests.pl | 57 +++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/test/cfg2cmd/custom-cpu-model-wrong-arch.conf create mode 100755 src/test/run_cpu_config_tests.pl diff --git a/src/test/Makefile b/src/test/Makefile index 2ef9073a..dcfab6d6 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -1,6 +1,6 @@ all: test -test: test_snapshot test_cfg_to_cmd test_pci_addr_conflicts test_pci_reservation test_qemu_img_convert test_migration test_restore_config test_parse_config +test: test_snapshot test_cfg_to_cmd test_pci_addr_conflicts test_pci_reservation test_qemu_img_convert test_migration test_restore_config test_parse_config test_cpu_config test_snapshot: run_snapshot_tests.pl ./run_snapshot_tests.pl @@ -31,6 +31,9 @@ test_restore_config: run_qemu_restore_config_tests.pl test_parse_config: run_parse_config_tests.pl ./run_parse_config_tests.pl +test_cpu_config: run_cpu_config_tests.pl + perl -I../ ./run_cpu_config_tests.pl + .PHONY: clean clean: rm -rf MigrationTest/run parse-config-output diff --git a/src/test/cfg2cmd/custom-cpu-model-wrong-arch.conf b/src/test/cfg2cmd/custom-cpu-model-wrong-arch.conf new file mode 100644 index 00000000..d1b9b08a --- /dev/null +++ b/src/test/cfg2cmd/custom-cpu-model-wrong-arch.conf @@ -0,0 +1,9 @@ +# TEST: custom CPU model with wrong arch for VM is rejected +# EXPECT_ERROR: custom CPU model has architecture 'aarch64', but VM has 'x86_64' +cores: 2 +cpu: custom-aarch64cpu +name: wrong-arch-cpu +numa: 0 +ostype: l26 +smbios1: uuid=2ea3f676-dfa5-11e9-ae82-c721e12f3fcd +sockets: 1 diff --git a/src/test/run_config2command_tests.pl b/src/test/run_config2command_tests.pl index 4c872d1c..dec07bda 100755 --- a/src/test/run_config2command_tests.pl +++ b/src/test/run_config2command_tests.pl @@ -408,6 +408,10 @@ cpu-model: qemu64 cpu-model: alldefault +cpu-model: aarch64cpu + reported-model cortex-a76 + arch aarch64 + EOF ); }, diff --git a/src/test/run_cpu_config_tests.pl b/src/test/run_cpu_config_tests.pl new file mode 100755 index 00000000..d3e587cc --- /dev/null +++ b/src/test/run_cpu_config_tests.pl @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use lib qw(..); + +use Test::More; + +use PVE::JSONSchema; +use PVE::QemuServer::CPUConfig; + +# Test that validate_cpu_conf rejects a custom CPU model whose reported-model +# doesn't match the specified arch. + +my @tests = ( + { + name => 'x86_64 reported-model with aarch64 arch is rejected', + input => 'custom-mycpu,reported-model=qemu64,arch=aarch64', + expected_error => qr/reported model 'qemu64' is not valid for architecture 'aarch64'/, + }, + { + name => 'aarch64 reported-model with x86_64 arch is rejected', + input => 'custom-mycpu,reported-model=cortex-a76,arch=x86_64', + expected_error => + qr/reported model 'cortex-a76' is not valid for architecture 'x86_64'/, + }, + { + name => 'aarch64 reported-model with default (x86_64) arch is rejected', + input => 'custom-mycpu,reported-model=cortex-a76', + expected_error => + qr/reported model 'cortex-a76' is not valid for architecture 'x86_64'/, + }, + { + name => 'x86_64 reported-model with matching arch is accepted', + input => 'custom-mycpu,reported-model=qemu64,arch=x86_64', + expected_error => undef, + }, + { + name => 'aarch64 reported-model with matching arch is accepted', + input => 'custom-mycpu,reported-model=cortex-a76,arch=aarch64', + expected_error => undef, + }, +); + +for my $test (@tests) { + eval { PVE::JSONSchema::parse_property_string('pve-cpu-conf', $test->{input}); }; + my $err = $@; + + if ($test->{expected_error}) { + like($err, $test->{expected_error}, $test->{name}); + } else { + is($err, '', $test->{name}); + } +} + +done_testing(); -- 2.47.3