From: Daniel Bowder <daniel@bowdernet.com>
To: pve-devel@lists.proxmox.com
Cc: Daniel Bowder <daniel@bowdernet.com>
Subject: [pve-devel] [PATCH v2 qemu-server 1/4] fix #3593: add affinity to qemu
Date: Thu, 30 Jun 2022 17:09:45 -0700 [thread overview]
Message-ID: <20220701000948.148496-2-daniel@bowdernet.com> (raw)
In-Reply-To: <20220701000948.148496-1-daniel@bowdernet.com>
Reuse the PVE::CpuSet to validate cpuset formatting.
Add new qemu property called 'affinity' to store the cpuset.
Push taskset command in front of kvm if 'affinity' is set.
Signed-off-by: Daniel Bowder <daniel@bowdernet.com>
---
PVE/QemuServer.pm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7d9cf22..94b44ae 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -28,6 +28,7 @@ use UUID;
use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file);
use PVE::CGroup;
+use PVE::CpuSet;
use PVE::DataCenterConfig;
use PVE::Exception qw(raise raise_param_exc);
use PVE::Format qw(render_duration render_bytes);
@@ -713,6 +714,11 @@ EODESCR
description => "Some (read-only) meta-information about this guest.",
optional => 1,
},
+ affinity => {
+ type => 'string', format => 'pve-cpuset',
+ description => "List of host cores used to execute guest processes.",
+ optional => 1,
+ },
};
my $cicustom_fmt = {
@@ -1032,6 +1038,20 @@ foreach my $key (keys %$confdesc_cloudinit) {
$confdesc->{$key} = $confdesc_cloudinit->{$key};
}
+PVE::JSONSchema::register_format('pve-cpuset', \&pve_verify_cpuset);
+sub pve_verify_cpuset {
+ my ($set_text, $noerr) = @_;
+
+ my ($count, $members) = eval { PVE::CpuSet::parse_cpuset($set_text) };
+
+ if ($@) {
+ return if $noerr;
+ die "unable to parse cpuset option\n";
+ }
+
+ return PVE::CpuSet->new($members)->short_string();
+}
+
PVE::JSONSchema::register_format('pve-volume-id-or-qm-path', \&verify_volume_id_or_qm_path);
sub verify_volume_id_or_qm_path {
my ($volid, $noerr) = @_;
@@ -3535,6 +3555,13 @@ sub config_to_command {
my $use_old_bios_files = undef;
($use_old_bios_files, $machine_type) = qemu_use_old_bios_files($machine_type);
+ if ($conf->{affinity}) {
+ push @$cmd, "taskset";
+ push @$cmd, "--cpu-list";
+ push @$cmd, "--all-tasks";
+ push @$cmd, $conf->{affinity};
+ }
+
push @$cmd, $kvm_binary;
push @$cmd, '-id', $vmid;
--
2.36.1
next prev parent reply other threads:[~2022-07-01 0:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 0:09 [pve-devel] [PATCH SERIES v2 manager/docs/widget-toolkit/qemu-server 0/4] fix #3593 Daniel Bowder
2022-07-01 0:09 ` Daniel Bowder [this message]
2022-07-01 0:09 ` [pve-devel] [PATCH v2 pve-docs 2/4] fix #3593: add affinity to docs Daniel Bowder
2022-07-01 0:09 ` [pve-devel] [PATCH v2 proxmox-widget-toolkit 3/4] fix #3593: add CpuSet type to js Daniel Bowder
2022-07-01 0:09 ` [pve-devel] [PATCH v2 pve-manager 4/4] fix #3593: add js input for affinity Daniel Bowder
2022-11-10 9:57 ` [pve-devel] applied-series: [PATCH SERIES v2 manager/docs/widget-toolkit/qemu-server 0/4] fix #3593 Wolfgang Bumiller
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=20220701000948.148496-2-daniel@bowdernet.com \
--to=daniel@bowdernet.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