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 E0FA578E6E for ; Fri, 1 Jul 2022 02:10:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DD9E73A50 for ; Fri, 1 Jul 2022 02:10:07 +0200 (CEST) Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 1 Jul 2022 02:10:03 +0200 (CEST) Received: by mail-pg1-x52f.google.com with SMTP id e132so872669pgc.5 for ; Thu, 30 Jun 2022 17:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowdernet.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rQ9YC5odSObVpQtwEREFjNVXBJCRuZf6oa5e+KGSnWw=; b=JnzFdPMuj9uioMVVErutAxLuj+8M+g1y6oWXsFgc/kh/AoTV3OWHLsAGzMNkshBXrD EHQ7gJh+FfIrtX5BKRelRwggG7/Lx3yQr/L9OgWoB+TPe89WQRh0WtjrRGtGaBz5e6zR FqOqSv4CiWLY4Sp3qqANho5kOS8yPCdmQ/SUw+YZ3SlZJGiyjH8W3nLO8VWshJXBbXTU BXHYXJJBmG+mUh8ib19exNcSerHQSdUcsDR2DAW+aBnWDvOtPydY4yd8bDYruOt5FkXC m0SvyK9atVDHwbnnt0oFcSj2TzMuTBIPWdikD5xlvDp8TjeaA1ImrbNP1CJIkFBu/AoE D0DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rQ9YC5odSObVpQtwEREFjNVXBJCRuZf6oa5e+KGSnWw=; b=08ERI8MJ7NkB/DoU06nhUb/nXjKw6Y3u3zZM+PryqycHDDU1szWxLRvfWrcQftHTdb PpQM01Jzg4epqNfdItodDDSAA+F6AyQAZkFEeIuULGonEgUIkR618dfJdE6fK6zlWISI l3ZrVY+noG111oKNE39FbYthSdtP7Mig3bp6vu5xsopwPgTuKpcKbKfytYNdqu/ZtndS DdLNB6qeAQRey59z/8clJzf6skDPhyxATpf7A5g6aLwn9x2eQfXWP0BfecFEYkN0duJm XXF5VT4zKZYqLAXBzMokL9/iQkL9BYP4Ma1+DGH5wSH8O7k4utmwOSX+t3oM5hHlPqh2 6WcA== X-Gm-Message-State: AJIora+UsrQz+YQkfz3BxJKdJQa4O7v2ivL/DhG8G7QHepP6Il4hZAPH ZGui8xXAhM+bmOF5V6AhNVwR2qCAZpAtDQ60 X-Google-Smtp-Source: AGRyM1vo5AWvAGvcruQBtsgiWb5vOP/ewOTVjAB8DssXlVBlaNQ2AGEJgIR4KpcUi4P4NxB33Tl+2g== X-Received: by 2002:a63:7e1a:0:b0:40c:c3b9:f97c with SMTP id z26-20020a637e1a000000b0040cc3b9f97cmr10020981pgc.498.1656634195292; Thu, 30 Jun 2022 17:09:55 -0700 (PDT) Received: from localhost.localdomain (c-24-19-168-226.hsd1.wa.comcast.net. [24.19.168.226]) by smtp.gmail.com with ESMTPSA id g6-20020a631106000000b004114aad90ebsm7296066pgl.49.2022.06.30.17.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 17:09:54 -0700 (PDT) From: Daniel Bowder To: pve-devel@lists.proxmox.com Cc: Daniel Bowder Date: Thu, 30 Jun 2022 17:09:45 -0700 Message-Id: <20220701000948.148496-2-daniel@bowdernet.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220701000948.148496-1-daniel@bowdernet.com> References: <20220701000948.148496-1-daniel@bowdernet.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v2 qemu-server 1/4] fix #3593: add affinity to qemu 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: Fri, 01 Jul 2022 00:10:37 -0000 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 --- 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