Files
proxmox-git-qemu-server/src/test/run_memory_tests.pl
T
dualfroz c5a01a4a75 fix #6907: memory: allow multi-digit host nodes with hugepages
When hugepages are enabled, each custom NUMA node must be bound to a
single host node. This was checked with a regex that only accepts a
single digit, so any host node from 10 upwards was rejected with a
misleading "more than 1 hostnode value" error, making hugepages
unusable on hosts with more than ten NUMA nodes.

Accept any single node number instead. Ranges and lists are still
rejected as before.

Signed-off-by: Michal Fox <me@dualfroz.com>
Reviewed-by: Max R. Carrara <m.carrara@proxmox.com>
Tested-by: Max R. Carrara <m.carrara@proxmox.com>
Link: https://lore.proxmox.com/20260926084115.7-1-me@dualfroz.com
[TL: add a multi-digit host node case to the memory tests]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2026-10-14 14:06:30 +02:00

62 lines
1.7 KiB
Perl

#!/usr/bin/perl
use strict;
use warnings;
use lib qw(..);
use Test::MockModule;
use Test::More;
use PVE::QemuServer::Memory;
my $memory_module = Test::MockModule->new('PVE::QemuServer::Memory');
$memory_module->mock('host_numanode_exists', sub { return 1; });
$memory_module->mock('hugepages_chunk_size_supported', sub { return 1; });
my $tests = [
['0', '0', 1],
['9', '9', 1],
['10', '10', 1],
['0;1', '0,1', 0],
['0;10', '0,10', 0],
['0;1;10', '0,1,10', 0],
['1;2', '1,2', 0],
['0-1', '0-1', 0],
['0;1-2', '0,1-2', 0],
];
for my $test (@$tests) {
my ($hostnodes, $expected, $single_node) = @$test;
subtest "host nodes $hostnodes" => sub {
my $numa_config = "cpus=0,memory=1024,hostnodes=$hostnodes,policy=bind";
my $numa = PVE::QemuServer::Memory::parse_numa($numa_config);
is(
PVE::QemuServer::Memory::print_numa_hostnodes($numa->{hostnodes}),
$expected,
'preserve node and range separators',
);
my $conf = {
numa => 1,
memory => 1024,
hugepages => 2,
numa0 => $numa_config,
};
my $topology = eval { PVE::QemuServer::Memory::hugepages_topology($conf, 0); };
if ($single_node) {
is($@, '', 'accept a single host node for hugepages');
is_deeply($topology, { 2 => { $hostnodes => 512 } }, 'use the requested host node');
} else {
like(
$@,
qr/^more than 1 hostnode value in numa node is not supported when hugepages are enabled/,
'reject host node lists and ranges for hugepages',
);
}
};
}
done_testing();