From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server 3/6] cpuconfig: add get_cpu_topology helper
Date: Thu, 9 Mar 2023 09:52:14 +0100 [thread overview]
Message-ID: <20230309085217.3649203-4-aderumier@odiso.com> (raw)
In-Reply-To: <20230309085217.3649203-1-aderumier@odiso.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
PVE/QemuServer.pm | 16 +++-------------
PVE/QemuServer/CPUConfig.pm | 11 +++++++++++
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index deb7faf..b49b59b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -50,7 +50,7 @@ use PVE::QemuConfig;
use PVE::QemuServer::Helpers qw(min_version config_aware_timeout windows_version);
use PVE::QemuServer::Cloudinit;
use PVE::QemuServer::CGroup;
-use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options);
+use PVE::QemuServer::CPUConfig qw(print_cpu_device get_cpu_options get_cpu_topology);
use PVE::QemuServer::Drive qw(is_valid_drivename drive_is_cloudinit drive_is_cdrom drive_is_read_only parse_drive print_drive);
use PVE::QemuServer::Machine;
use PVE::QemuServer::Memory;
@@ -3818,13 +3818,7 @@ sub config_to_command {
add_tpm_device($vmid, $devices, $conf);
- my $sockets = 1;
- $sockets = $conf->{smp} if $conf->{smp}; # old style - no longer iused
- $sockets = $conf->{sockets} if $conf->{sockets};
-
- my $cores = $conf->{cores} || 1;
-
- my $maxcpus = $sockets * $cores;
+ my ($sockets, $cores, $maxcpus) = get_cpu_topology($conf);
my $vcpus = $conf->{vcpus} ? $conf->{vcpus} : $maxcpus;
@@ -4660,11 +4654,7 @@ sub qemu_cpu_hotplug {
my $machine_type = PVE::QemuServer::Machine::get_current_qemu_machine($vmid);
- my $sockets = 1;
- $sockets = $conf->{smp} if $conf->{smp}; # old style - no longer iused
- $sockets = $conf->{sockets} if $conf->{sockets};
- my $cores = $conf->{cores} || 1;
- my $maxcpus = $sockets * $cores;
+ my ($sockets, $cores, $maxcpus) = get_cpu_topology($conf);
$vcpus = $maxcpus if !$vcpus;
diff --git a/PVE/QemuServer/CPUConfig.pm b/PVE/QemuServer/CPUConfig.pm
index fb0861b..826e472 100644
--- a/PVE/QemuServer/CPUConfig.pm
+++ b/PVE/QemuServer/CPUConfig.pm
@@ -12,6 +12,7 @@ use base qw(PVE::SectionConfig Exporter);
our @EXPORT_OK = qw(
print_cpu_device
get_cpu_options
+get_cpu_topology
);
# under certain race-conditions, this module might be loaded before pve-cluster
@@ -659,6 +660,16 @@ sub get_cpu_from_running_vm {
return $1;
}
+sub get_cpu_topology {
+ my ($conf) = @_;
+
+ my $sockets = $conf->{sockets} || 1;
+ my $cores = $conf->{cores} || 1;
+ my $maxcpus = $sockets * $cores;
+
+ return ($sockets, $cores, $maxcpus);
+}
+
__PACKAGE__->register();
__PACKAGE__->init();
--
2.30.2
next prev parent reply other threads:[~2023-03-09 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 8:52 [pve-devel] [PATCH qemu-server 0/6] improve virtio drive multiqueues Alexandre Derumier
2023-03-09 8:52 ` [pve-devel] [PATCH qemu-server 1/6] add virtio-scsi && virtio-scsi-single tests Alexandre Derumier
2023-03-09 8:52 ` [pve-devel] [PATCH qemu-server 2/6] virtio-blk: add queues option Alexandre Derumier
2023-03-09 8:52 ` Alexandre Derumier [this message]
2023-03-09 8:52 ` [pve-devel] [PATCH qemu-server 4/6] fix #4295 : virtio-(blk|scsi): enable multiqueue by default Alexandre Derumier
2023-03-09 8:52 ` [pve-devel] [PATCH qemu-server 5/6] drive: allow minimum queues = 1 Alexandre Derumier
2023-03-09 8:52 ` [pve-devel] [PATCH qemu-server 6/6] add virtio-blk|scsi default multiqueue tests Alexandre Derumier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230309085217.3649203-4-aderumier@odiso.com \
--to=aderumier@odiso.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox