From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <m.heiserer@proxmox.com>
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 858EF71545
 for <pve-devel@lists.proxmox.com>; Wed,  8 Jun 2022 16:46:19 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 7729CA6DC
 for <pve-devel@lists.proxmox.com>; Wed,  8 Jun 2022 16:45:49 +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 id CB80AA6D1
 for <pve-devel@lists.proxmox.com>; Wed,  8 Jun 2022 16:45:48 +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 A021B43A6C
 for <pve-devel@lists.proxmox.com>; Wed,  8 Jun 2022 16:45:48 +0200 (CEST)
Message-ID: <038f219d-99d0-ed64-5122-7881ef3c17e6@proxmox.com>
Date: Wed, 8 Jun 2022 16:45:47 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.9.0
Content-Language: en-US
To: pve-devel@lists.proxmox.com
References: <20220608115428.250668-1-daniel@bowdernet.com>
 <20220608115428.250668-4-daniel@bowdernet.com>
From: Matthias Heiserer <m.heiserer@proxmox.com>
In-Reply-To: <20220608115428.250668-4-daniel@bowdernet.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.686 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -1.732 Looks like a legit reply (A)
 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 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [qemuserver.pm]
Subject: Re: [pve-devel] [PATCH 3/5] fix #3593: Added vm core pinning
 qemu-server
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 08 Jun 2022 14:46:19 -0000

I'm not sure where it comes from, but when starting a VM, the task log 
receives a bunch of messages on changed affinity:

pid 95121's current affinity list: 0-7
pid 95121's new affinity list: 2,3
pid 95122's current affinity list: 0-7
pid 95122's new affinity list: 2,3
pid 95123's current affinity list: 0-7
pid 95123's new affinity list: 2,3
pid 95184's current affinity list: 0-7
pid 95184's new affinity list: 2,3
pid 95185's current affinity list: 0-7
pid 95185's new affinity list: 2,3
pid 95187's current affinity list: 0-7
pid 95187's new affinity list: 2,3

Can we avoid showing them? I don't think they offer any insight, because 
as I understand it, when starting, the current affinity list is always 
all available cores.

On 08.06.2022 13:54, Daniel Bowder wrote:
> Signed-off-by: Daniel Bowder <daniel@bowdernet.com>
> ---
>   The third patch adds cpuset as a valid object in the qm conf file. A new type is created called 'pve-cpuset' so that the cpuset can go through some validation before passing it to the taskset command. The exec_taskset command is executed just after the 'post-start' hookscript, which ensures that there is a valid PID to pin.
The commit message should be above the lines :)
Otherwise, it won't be part of the commit, but only a comment visible on 
the mailing list.
>   PVE/QemuServer.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 49 insertions(+)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index e9aa248..6b9abc0 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -713,6 +713,11 @@ EODESCR
>   	description => "Some (read-only) meta-information about this guest.",
>   	optional => 1,
>       },
> +	cpuset => {
> +	type => 'string', format => 'pve-cpuset',
> +	description => "Specifies the cpu core numbers to pin the vm qemu processes to with 'taskset'.",
> +	optional => 1,
> +	},
>   };
>   
>   my $cicustom_fmt = {
> @@ -5802,6 +5807,8 @@ sub vm_start_nolock {
>   
>       PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'post-start');
>   
> +    PVE::GuestHelpers::exec_taskset($conf, $vmid);
> +
>       return $res;
>   }
>   
> @@ -8214,4 +8221,46 @@ sub check_volume_storage_type {
>       return 1;
>   }
>   
> +sub parse_cpuset {
> +    my ($data) = @_;
> +
> +    my $res = "";
> +
> +	# Parse cpuset value
> +	foreach my $value (PVE::Tools::split_list($data)) {
> +		if ($value =~ m/^([0-9]+)-([0-9]+)$/) {
> +			if (int($1) > int($2)) {
> +				die "invalid cpuset value '$value', left value must be <= right\n";
> +			}
> +			my @range = (int($1) .. int($2));
> +			for my $cpu (@range) {
> +				$res .= "," . $cpu;
> +			}
> +		} elsif ($value =~ m/^([0-9]+)$/) {
> +			$res .= "," . $1;
> +		} else {
> +			die "invalid cpuset value '$value'\n";
> +		}
> +	}
> +
> +	if (!$res) {
> +		die "invalid cpuset '$data'\n";
> +	}
> +
> +	# Trim leading ","
> +    $res = substr($res, 1);
> +    return $res;
> +}
> +
> +PVE::JSONSchema::register_format('pve-cpuset', \&pve_verify_cpuset);
> +sub pve_verify_cpuset {
> +    my ($value, $noerr) = @_;
> +
> +    return $value if parse_cpuset($value);
> +
> +    return if $noerr;
> +
> +    die "unable to parse cpuset option\n";
> +}
> +
>   1;

BTW, my colleagues will also review your code at some point, so be 
prepared that there might be some more required changes