From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id EE79F95D9 for ; Mon, 4 Sep 2023 13:40:26 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D761AE253 for ; Mon, 4 Sep 2023 13:39:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 4 Sep 2023 13:39:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id F0DAA4102C for ; Mon, 4 Sep 2023 13:39:54 +0200 (CEST) From: Fiona Ebner To: pve-devel@lists.proxmox.com Date: Mon, 4 Sep 2023 13:39:46 +0200 Message-Id: <20230904113949.940431-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230904113949.940431-1-f.ebner@proxmox.com> References: <20230904113949.940431-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.079 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 2/5] move NUMA-related code into memory module 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: , X-List-Received-Date: Mon, 04 Sep 2023 11:40:27 -0000 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 --- PVE/QemuServer.pm | 50 +++-------------------------------- PVE/QemuServer/Memory.pm | 56 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index ed604a80..61409a58 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -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= sub parse_net { my ($data, $disable_mac_autogen) = @_; diff --git a/PVE/QemuServer/Memory.pm b/PVE/QemuServer/Memory.pm index d459a08d..c5c3a0a6 100644 --- a/PVE/QemuServer/Memory.pm +++ b/PVE/QemuServer/Memory.pm @@ -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; -- 2.39.2