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 9A9771FF137 for ; Tue, 03 Feb 2026 15:21:45 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 20CE32049D; Tue, 3 Feb 2026 15:22:14 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Subject: [PATCH qemu-server 1/2] tests: improve multiarch build support Date: Tue, 3 Feb 2026 15:16:30 +0100 Message-ID: <20260203142209.3614946-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.032 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 Message-ID-Hash: PNTBO6PX3O7ZPYQ4SWVK3GLYSODVDGXM X-Message-ID-Hash: PNTBO6PX3O7ZPYQ4SWVK3GLYSODVDGXM X-MailFrom: d.csapak@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: The CPUConfig module sets the local 'host_arch' on loading, so instead to try to mock all subs that access this variable, provide a setter only intended for tests (and warn when using this). Also, we have to override the 'get_host_arch' in the Helpers module too. Without these changes, the config to command tests fail when building on non-x86 hosts. Signed-off-by: Dominik Csapak --- not sure about the 'setter hack', which can be partially deleted when we'll switch to using PVE::Tools::get_host_arch again, but we have to keep the code changing the cpu_models_by_arch hash. This patch requires these patches from fiona: https://lore.proxmox.com/pve-devel/20260129131021.118199-1-f.ebner@proxmox.com/ src/PVE/QemuServer/CPUConfig.pm | 12 ++++++++++++ src/test/run_config2command_tests.pl | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm index 32ec4954..686bbdc0 100644 --- a/src/PVE/QemuServer/CPUConfig.pm +++ b/src/PVE/QemuServer/CPUConfig.pm @@ -1230,6 +1230,18 @@ sub get_intel_tdx_object { return $tdx_object; } +# CAUTION: for tests only, DO NOT USE outside of tests! +# sets the package gloabl $host_arch value, and modifies the $cpu_models_by_arch +# so that the 'host' model is available only in the newly set $arch +sub set_host_arch($) { + my ($arch) = @_; + warn "CAUTION: use of 'set_host_arch' only intended in tests!\n"; + + delete $cpu_models_by_arch->{$host_arch}->{host}; + $host_arch = $arch; + $cpu_models_by_arch->{$host_arch}->{host} = 'default'; +} + __PACKAGE__->register(); __PACKAGE__->init(); diff --git a/src/test/run_config2command_tests.pl b/src/test/run_config2command_tests.pl index 4c872d1c..b8a2cf7e 100755 --- a/src/test/run_config2command_tests.pl +++ b/src/test/run_config2command_tests.pl @@ -235,6 +235,8 @@ sub parse_test($config_fn) { $testname = "'$testname' - $desc"; } $current_test->{testname} = $testname; + + PVE::QemuServer::CPUConfig::set_host_arch($current_test->{arch} // 'x86_64'); } sub get_test_qemu_version { @@ -264,6 +266,14 @@ $qemu_server_module->mock( }, ); +my $qemu_server_helpers_module; +$qemu_server_helpers_module = Test::MockModule->new('PVE::QemuServer::Helpers'); +$qemu_server_helpers_module->mock( + get_host_arch => sub() { + return $current_test->{host_arch} // 'x86_64'; + }, +); + my $storage_module = Test::MockModule->new("PVE::Storage"); $storage_module->mock( activate_volumes => sub { @@ -582,6 +592,9 @@ sub diff($a, $b) { $SIG{__WARN__} = sub { my $warning = shift; chomp $warning; + if ($warning =~ m/^CAUTION: use of 'set_host/) { + return; + } if (my $warn_expect = $current_test->{expect_warning}) { if ($warn_expect ne $warning) { fail($current_test->{testname}); -- 2.47.3