mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-06-14 13:26:24 +00:00
move NUMA-related code into memory module
which is the only user of the parse_numa() helper. While at it, avoid the duplication of MAX_NUMA. In preparation to remove the cyclic include of PVE::QemuServer in the memory module. No functional change intended. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
261b67e4aa
commit
0e32bf5bc2
@ -49,7 +49,7 @@ use PVE::Tools qw(run_command file_read_firstline file_get_contents dir_glob_for
|
||||
|
||||
use PVE::QMPClient;
|
||||
use PVE::QemuConfig;
|
||||
use PVE::QemuServer::Helpers qw(config_aware_timeout min_version parse_number_sets windows_version);
|
||||
use PVE::QemuServer::Helpers qw(config_aware_timeout min_version windows_version);
|
||||
use PVE::QemuServer::Cloudinit;
|
||||
use PVE::QemuServer::CGroup;
|
||||
use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options);
|
||||
@ -842,44 +842,9 @@ while (my ($k, $v) = each %$confdesc) {
|
||||
my $MAX_NETS = 32;
|
||||
my $MAX_SERIAL_PORTS = 4;
|
||||
my $MAX_PARALLEL_PORTS = 3;
|
||||
my $MAX_NUMA = 8;
|
||||
|
||||
my $numa_fmt = {
|
||||
cpus => {
|
||||
type => "string",
|
||||
pattern => qr/\d+(?:-\d+)?(?:;\d+(?:-\d+)?)*/,
|
||||
description => "CPUs accessing this NUMA node.",
|
||||
format_description => "id[-id];...",
|
||||
},
|
||||
memory => {
|
||||
type => "number",
|
||||
description => "Amount of memory this NUMA node provides.",
|
||||
optional => 1,
|
||||
},
|
||||
hostnodes => {
|
||||
type => "string",
|
||||
pattern => qr/\d+(?:-\d+)?(?:;\d+(?:-\d+)?)*/,
|
||||
description => "Host NUMA nodes to use.",
|
||||
format_description => "id[-id];...",
|
||||
optional => 1,
|
||||
},
|
||||
policy => {
|
||||
type => 'string',
|
||||
enum => [qw(preferred bind interleave)],
|
||||
description => "NUMA allocation policy.",
|
||||
optional => 1,
|
||||
},
|
||||
};
|
||||
PVE::JSONSchema::register_format('pve-qm-numanode', $numa_fmt);
|
||||
my $numadesc = {
|
||||
optional => 1,
|
||||
type => 'string', format => $numa_fmt,
|
||||
description => "NUMA topology.",
|
||||
};
|
||||
PVE::JSONSchema::register_standard_option("pve-qm-numanode", $numadesc);
|
||||
|
||||
for (my $i = 0; $i < $MAX_NUMA; $i++) {
|
||||
$confdesc->{"numa$i"} = $numadesc;
|
||||
for (my $i = 0; $i < $PVE::QemuServer::Memory::MAX_NUMA; $i++) {
|
||||
$confdesc->{"numa$i"} = $PVE::QemuServer::Memory::numadesc;
|
||||
}
|
||||
|
||||
my $nic_model_list = [
|
||||
@ -1930,15 +1895,6 @@ sub print_vga_device {
|
||||
return "$type,id=${vgaid}${memory}${max_outputs}${pciaddr}${edidoff}";
|
||||
}
|
||||
|
||||
sub parse_numa {
|
||||
my ($data) = @_;
|
||||
|
||||
my $res = parse_property_string($numa_fmt, $data);
|
||||
$res->{cpus} = parse_number_sets($res->{cpus}) if defined($res->{cpus});
|
||||
$res->{hostnodes} = parse_number_sets($res->{hostnodes}) if defined($res->{hostnodes});
|
||||
return $res;
|
||||
}
|
||||
|
||||
# netX: e1000=XX:XX:XX:XX:XX:XX,bridge=vmbr0,rate=<mbps>
|
||||
sub parse_net {
|
||||
my ($data, $disable_mac_autogen) = @_;
|
||||
|
@ -3,13 +3,59 @@ package PVE::QemuServer::Memory;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use PVE::JSONSchema qw(parse_property_string);
|
||||
use PVE::Tools qw(run_command lock_file lock_file_full file_read_firstline dir_glob_foreach);
|
||||
use PVE::Exception qw(raise raise_param_exc);
|
||||
|
||||
use PVE::QemuServer;
|
||||
use PVE::QemuServer::Helpers qw(parse_number_sets);
|
||||
use PVE::QemuServer::Monitor qw(mon_cmd);
|
||||
|
||||
my $MAX_NUMA = 8;
|
||||
our $MAX_NUMA = 8;
|
||||
|
||||
my $numa_fmt = {
|
||||
cpus => {
|
||||
type => "string",
|
||||
pattern => qr/\d+(?:-\d+)?(?:;\d+(?:-\d+)?)*/,
|
||||
description => "CPUs accessing this NUMA node.",
|
||||
format_description => "id[-id];...",
|
||||
},
|
||||
memory => {
|
||||
type => "number",
|
||||
description => "Amount of memory this NUMA node provides.",
|
||||
optional => 1,
|
||||
},
|
||||
hostnodes => {
|
||||
type => "string",
|
||||
pattern => qr/\d+(?:-\d+)?(?:;\d+(?:-\d+)?)*/,
|
||||
description => "Host NUMA nodes to use.",
|
||||
format_description => "id[-id];...",
|
||||
optional => 1,
|
||||
},
|
||||
policy => {
|
||||
type => 'string',
|
||||
enum => [qw(preferred bind interleave)],
|
||||
description => "NUMA allocation policy.",
|
||||
optional => 1,
|
||||
},
|
||||
};
|
||||
PVE::JSONSchema::register_format('pve-qm-numanode', $numa_fmt);
|
||||
our $numadesc = {
|
||||
optional => 1,
|
||||
type => 'string', format => $numa_fmt,
|
||||
description => "NUMA topology.",
|
||||
};
|
||||
PVE::JSONSchema::register_standard_option("pve-qm-numanode", $numadesc);
|
||||
|
||||
sub parse_numa {
|
||||
my ($data) = @_;
|
||||
|
||||
my $res = parse_property_string($numa_fmt, $data);
|
||||
$res->{cpus} = parse_number_sets($res->{cpus}) if defined($res->{cpus});
|
||||
$res->{hostnodes} = parse_number_sets($res->{hostnodes}) if defined($res->{hostnodes});
|
||||
return $res;
|
||||
}
|
||||
|
||||
my $STATICMEM = 1024;
|
||||
|
||||
my $_host_bits;
|
||||
@ -68,7 +114,7 @@ sub get_numa_node_list {
|
||||
my @numa_map;
|
||||
for (my $i = 0; $i < $MAX_NUMA; $i++) {
|
||||
my $entry = $conf->{"numa$i"} or next;
|
||||
my $numa = PVE::QemuServer::parse_numa($entry) or next;
|
||||
my $numa = parse_numa($entry) or next;
|
||||
push @numa_map, $i;
|
||||
}
|
||||
return @numa_map if @numa_map;
|
||||
@ -88,7 +134,7 @@ sub get_numa_guest_to_host_map {
|
||||
my $map = {};
|
||||
for (my $i = 0; $i < $MAX_NUMA; $i++) {
|
||||
my $entry = $conf->{"numa$i"} or next;
|
||||
my $numa = PVE::QemuServer::parse_numa($entry) or next;
|
||||
my $numa = parse_numa($entry) or next;
|
||||
$map->{$i} = print_numa_hostnodes($numa->{hostnodes});
|
||||
}
|
||||
return $map if %$map;
|
||||
@ -281,7 +327,7 @@ sub config {
|
||||
my $numa_totalmemory = undef;
|
||||
for (my $i = 0; $i < $MAX_NUMA; $i++) {
|
||||
next if !$conf->{"numa$i"};
|
||||
my $numa = PVE::QemuServer::parse_numa($conf->{"numa$i"});
|
||||
my $numa = parse_numa($conf->{"numa$i"});
|
||||
next if !$numa;
|
||||
# memory
|
||||
die "missing NUMA node$i memory value\n" if !$numa->{memory};
|
||||
@ -484,7 +530,7 @@ sub hugepages_topology {
|
||||
#custom numa topology
|
||||
for (my $i = 0; $i < $MAX_NUMA; $i++) {
|
||||
next if !$conf->{"numa$i"};
|
||||
my $numa = PVE::QemuServer::parse_numa($conf->{"numa$i"});
|
||||
my $numa = parse_numa($conf->{"numa$i"});
|
||||
next if !$numa;
|
||||
|
||||
$numa_custom_topology = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user