From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <daniel@bowdernet.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 0E97371269
 for <pve-devel@lists.proxmox.com>; Wed,  8 Jun 2022 13:54:56 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 0B73C7753
 for <pve-devel@lists.proxmox.com>; Wed,  8 Jun 2022 13:54:56 +0200 (CEST)
Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com
 [IPv6:2607:f8b0:4864:20::62d])
 (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 id 7F1CF7744
 for <pve-devel@lists.proxmox.com>; Wed,  8 Jun 2022 13:54:55 +0200 (CEST)
Received: by mail-pl1-x62d.google.com with SMTP id i15so666609plr.1
 for <pve-devel@lists.proxmox.com>; Wed, 08 Jun 2022 04:54:55 -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=9vXWanN0/3SA+tjghBw62+Xv4ptfI/j2BujY24iVZpI=;
 b=S52pt4lapS0I07YuCA2zVdFlXG8Y4h0UdRBzkYdMEEBepTj8MD3gbE3dBoZfMimxr0
 xxmWNTlbUTF37a0ZKEBDPFeZ1AVQSzsFqsgVfRCtcgqNmgNmVV92WD7IcG1DXPbQPjPQ
 c1p+Q1Zsv9V0JE8MTORVUNqnRjXYTnQkpeFCLVeafMjtn6EVpWNoxlBrCfUspU6DNihY
 eOx84Qvi949RGOZ6GsTvR0KoOYyoIV+iLjLkDvmNiIgIwKMNF2nUeOHxZOE7lxBD1aXs
 OYGJf9yT0S1cyegYXyGJZ81qB5G328Yww+BeNJXTguOsInJIyjDc3oAaLAjRyodiMA0N
 UQjw==
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=9vXWanN0/3SA+tjghBw62+Xv4ptfI/j2BujY24iVZpI=;
 b=Je3dHs5K7kcPiW7m8VAhSi4c/sEaVJV5WnsipLEzA1z6XrGKXpoO+13s26+hiNhvFw
 F2WwcjP3pYPAEKmKQ67gu9iJux+Mysbjsx0v/GwlB/qTethTEfBDg9vXbU3dxKBUvuHI
 3IDh4UDM0u7MWrxzQbiojIS0SIZ563Qe7Y6nwJV1s91Lhqv7VkAwGIB2Qd5ODvnnaW7W
 FHbta5yoUVioEVG1R9pS6GXTMXplIqNPpyEMr9vzGCjwbLsccQdBdmWaVMZK3auC7vBM
 H9nzFEWZ29O0JY+Qd0h+XQxcFYzDU3tkWQB+beXOksPv6PTqvYDOlvMeHM6vgyNDT11h
 mklA==
X-Gm-Message-State: AOAM531lM2XQjdGyBqe0u7Xo8hEQUYZOFXMzezRHm17n+wYAex51GS+k
 SH6mF5PPsjoX4v3dyk282P+7tplbbqS13aC+
X-Google-Smtp-Source: ABdhPJwOQUYWyHzSHgrZ+s0C1mEIpsH0z9eSgmD7uvA2YRaMyN4sHTo7Fs15dD/YvDpSUvBp0BZhLw==
X-Received: by 2002:a17:90a:c4f:b0:1df:a178:897f with SMTP id
 u15-20020a17090a0c4f00b001dfa178897fmr37465034pje.19.1654689287907; 
 Wed, 08 Jun 2022 04:54:47 -0700 (PDT)
Received: from pve-dev.dbnet.in (c-24-19-168-226.hsd1.wa.comcast.net.
 [24.19.168.226]) by smtp.gmail.com with ESMTPSA id
 t6-20020a654b86000000b003fba6db1b50sm14902820pgq.85.2022.06.08.04.54.47
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 08 Jun 2022 04:54:47 -0700 (PDT)
From: Daniel Bowder <daniel@bowdernet.com>
To: pve-devel@lists.proxmox.com
Cc: Daniel Bowder <daniel@bowdernet.com>
Date: Wed,  8 Jun 2022 04:54:27 -0700
Message-Id: <20220608115428.250668-5-daniel@bowdernet.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20220608115428.250668-1-daniel@bowdernet.com>
References: <20220608115428.250668-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 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [bowdernet.com]
X-Mailman-Approved-At: Wed, 08 Jun 2022 14:30:46 +0200
Subject: [pve-devel] [PATCH 4/5] fix #3593: Added vm core pinning
 proxmox-widget-toolkit
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 11:54:56 -0000

Signed-off-by: Daniel Bowder <daniel@bowdernet.com>
---
 The fourth patch adds a javascript type for CPUSet. This type can use a regex match to (mostly) ensure the user types a correct cpuset. There are some fringe cases where the CPUSet can pass the CPUSet_match, but then fail the checks in patch three. (e.g. 0,5-4 will pass, but is invalid). This is not a problem, because the user cannot save this invalid CPUSet per the checks in patch three.
 src/Toolkit.js | 5 +++++
 src/Utils.js   | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/src/Toolkit.js b/src/Toolkit.js
index a1d291e..41673a6 100644
--- a/src/Toolkit.js
+++ b/src/Toolkit.js
@@ -121,6 +121,11 @@ Ext.apply(Ext.form.field.VTypes, {
     },
     HttpProxyText: gettext('Example') + ": http://username:password&#64;host:port/",
 
+    CPUSet: function(v) {
+        return Proxmox.Utils.CPUSet_match.test(v);
+    },
+    CPUSetText: gettext('This is not a valid CPU Set. (e.g. 0,2-6,8)'),
+
     DnsName: function(v) {
 	return Proxmox.Utils.DnsName_match.test(v);
     },
diff --git a/src/Utils.js b/src/Utils.js
index 6a03057..8f1c839 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1315,6 +1315,8 @@ utilities: {
 	me.DnsName_match = new RegExp("^" + DnsName_REGEXP + "$");
 	me.DnsName_or_Wildcard_match = new RegExp("^(?:\\*\\.)?" + DnsName_REGEXP + "$");
 
+	me.CPUSet_match = /^(?:(?:[0-9]+,)|(?:[0-9]+-[0-9]+,))*(?:(?:[0-9]+)$|(?:[0-9]+-[0-9]+)$)/;
+
 	me.HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(?::(\\d+))?$");
 	me.HostPortBrackets_match = new RegExp("^\\[(" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](?::(\\d+))?$");
 	me.IP6_dotnotation_match = new RegExp("^(" + IPV6_REGEXP + ")(?:\\.(\\d+))?$");
-- 
2.30.2