From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v2 8/8] ui: cpu flag selector: query CPU flag list via API
Date: Fri, 7 Nov 2025 15:43:46 +0100 [thread overview]
Message-ID: <20251107144429.126790-9-f.ebner@proxmox.com> (raw)
In-Reply-To: <20251107144429.126790-1-f.ebner@proxmox.com>
There is coupling between the store and value for the top-level grid,
which has a field mixin. Because of this, the setValue() method needs
to update the 'state' value for the records in the store accordingly.
This can however only be done if the store is already loaded, so the
store gets a refresh() callback. It also remembers which value it was
already adjusted for for potential subsequent setValue() calls.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
Changes in v2:
* ui: fix function name adjustStoreForValue() for caller in setValue()
* Fix typo in commit message 'Becuase' -> 'Because'.
www/manager6/form/VMCPUFlagSelector.js | 96 +++++++++++---------------
1 file changed, 42 insertions(+), 54 deletions(-)
diff --git a/www/manager6/form/VMCPUFlagSelector.js b/www/manager6/form/VMCPUFlagSelector.js
index 630f79f5..922fcfa6 100644
--- a/www/manager6/form/VMCPUFlagSelector.js
+++ b/www/manager6/form/VMCPUFlagSelector.js
@@ -18,62 +18,42 @@ Ext.define('PVE.form.VMCPUFlagSelector', {
store: {
type: 'store',
- fields: ['flag', { name: 'state', defaultValue: '=' }, 'desc'],
- data: [
- // FIXME: let qemu-server host this and autogenerate or get from API call??
- {
- flag: 'md-clear',
- desc: 'Required to let the guest OS know if MDS is mitigated correctly',
- },
- {
- flag: 'pcid',
- desc: 'Meltdown fix cost reduction on Westmere, Sandy-, and IvyBridge Intel CPUs',
- },
- { flag: 'spec-ctrl', desc: 'Allows improved Spectre mitigation with Intel CPUs' },
- { flag: 'ssbd', desc: 'Protection for "Speculative Store Bypass" for Intel models' },
- { flag: 'ibpb', desc: 'Allows improved Spectre mitigation with AMD CPUs' },
- {
- flag: 'virt-ssbd',
- desc: 'Basis for "Speculative Store Bypass" protection for AMD models',
- },
- {
- flag: 'amd-ssbd',
- desc: 'Improves Spectre mitigation performance with AMD CPUs, best used with "virt-ssbd"',
- },
- {
- flag: 'amd-no-ssb',
- desc: 'Notifies guest OS that host is not vulnerable for Spectre on AMD CPUs',
- },
- {
- flag: 'pdpe1gb',
- desc: 'Allow guest OS to use 1GB size pages, if host HW supports it',
- },
- {
- flag: 'hv-tlbflush',
- desc: 'Improve performance in overcommitted Windows guests. May lead to guest bluescreens on old CPUs.',
- },
- {
- flag: 'hv-evmcs',
- desc: 'Improve performance for nested virtualization. Only supported on Intel CPUs.',
- },
- { flag: 'aes', desc: 'Activate AES instruction set for HW acceleration.' },
- ],
+ fields: ['name', { name: 'state', defaultValue: '=' }, 'description'],
+ autoLoad: true,
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json/nodes/localhost/capabilities/qemu/cpu-flags',
+ },
listeners: {
update: function () {
this.commitChanges();
},
+ refresh: function (store, eOpts) {
+ let me = this;
+ let view = me.view;
+
+ if (store.adjustedForValue !== view.value) {
+ view.adjustStoreForValue();
+ }
+ },
},
+ adjustedForValue: undefined,
},
getValue: function () {
let me = this;
let store = me.getStore();
+
+ if (!store.isLoaded()) {
+ return me.value;
+ }
+
let flags = '';
store.getData().each(function (rec) {
let s = rec.get('state');
if (s && s !== '=') {
- let f = rec.get('flag');
+ let f = rec.get('name');
if (flags === '') {
flags = s + f;
} else {
@@ -87,29 +67,41 @@ Ext.define('PVE.form.VMCPUFlagSelector', {
return flags;
},
- setValue: function (value) {
+ // Adjusts the store for the current value and determines the unkown flags based on what the
+ // store does not know.
+ adjustStoreForValue: function () {
let me = this;
let store = me.getStore();
-
- me.value = value || '';
+ let value = me.value;
me.unkownFlags = [];
- me.getStore().getData().each((rec) => rec.set('state', '='));
+ store.getData().each((rec) => rec.set('state', '='));
let flags = value ? value.split(';') : [];
flags.forEach(function (flag) {
let sign = flag.substr(0, 1);
flag = flag.substr(1);
- let rec = store.findRecord('flag', flag, 0, false, true, true);
+ let rec = store.findRecord('name', flag, 0, false, true, true);
if (rec !== null) {
rec.set('state', sign);
} else {
me.unkownFlags.push(flag);
}
});
- store.reload();
+
+ store.adjustedForValue = value;
+ },
+
+ setValue: function (value) {
+ let me = this;
+
+ me.value = value || '';
+
+ if (me.getStore().isLoaded()) {
+ me.adjustStoreForValue();
+ } // if not yet loaded, the store will trigger the function
let res = me.mixins.field.setValue.call(me, value);
@@ -179,11 +171,11 @@ Ext.define('PVE.form.VMCPUFlagSelector', {
},
},
{
- dataIndex: 'flag',
+ dataIndex: 'name',
width: 100,
},
{
- dataIndex: 'desc',
+ dataIndex: 'description',
cellWrap: true,
flex: 1,
},
@@ -192,12 +184,8 @@ Ext.define('PVE.form.VMCPUFlagSelector', {
initComponent: function () {
let me = this;
- // static class store, thus gets not recreated, so ensure defaults are set!
- me.getStore().data.forEach(function (v) {
- v.state = '=';
- });
-
me.value = me.originalValue = '';
+ me.store.view = me;
me.callParent(arguments);
},
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
prev parent reply other threads:[~2025-11-07 14:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 14:43 [pve-devel] [PATCH-SERIES qemu-server/manager v2 0/8] VM CPU flags: introduce vendor-agnostic 'nested-virt' CPU flag Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH qemu-server v2 1/8] critic: code style: cpu config: unpack @_ first in resolve_cpu_flags() Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH qemu-server v2 2/8] api: add endpoint for querying available cpu flags Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH qemu-server v2 3/8] cpu config: introduce is_abstracted() helper Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH qemu-server v2 4/8] cpu config: introduce vendor-agnostic 'nested-virt' CPU flag Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH manager v2 5/8] api: capabilities: register module for VM CPU flags Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH manager v2 6/8] ui: cpu flag selector: code style: use 'let' for declarations Fiona Ebner
2025-11-07 14:43 ` [pve-devel] [PATCH manager v2 7/8] ui: cpu flag selector: use simpler method to get all records of the store Fiona Ebner
2025-11-07 14:43 ` Fiona Ebner [this message]
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=20251107144429.126790-9-f.ebner@proxmox.com \
--to=f.ebner@proxmox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.