[pve-devel] [PATCH manager] add spec-ctrl cpu flag checkbox
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue Jan 16 15:16:43 CET 2018
On 1/16/18 2:51 PM, Dominik Csapak wrote:
> also make the mechanism for the flag checkboxes generic
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> www/manager6/qemu/ProcessorEdit.js | 47 ++++++++++++++++++++++++++------------
> 1 file changed, 32 insertions(+), 15 deletions(-)
>
> diff --git a/www/manager6/qemu/ProcessorEdit.js b/www/manager6/qemu/ProcessorEdit.js
> index a14e5c87..e8afc7bb 100644
> --- a/www/manager6/qemu/ProcessorEdit.js
> +++ b/www/manager6/qemu/ProcessorEdit.js
> @@ -5,15 +5,27 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
>
> insideWizard: false,
>
> + // defines the possible cpu flags and their labels
> + flagsAvail: ['pcid', 'spec-ctrl'],
> + flagLabels: ['PCID', 'SPEC-CTRL'],
> +
a "synced" map would be nicer, for now we could keep it simple
and have just the lower case version tracked, imo:
cpuflags: [
'pcid',
'spec-ctrl'
],
should make the code below slightly shorter.
Once we've "full blown" CPU Flag support we need to rethink this
component anyways, so that the user experience stays somewhat sane :)
But, as this is only a temporary solution the patch as is is also OK:
Reviewed-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Tested-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> onGetValues: function(values) {
> var me = this;
>
> // build the cpu options:
> me.cpu.cputype = values.cputype;
>
> - // as long as flags is not a textfield, we
> - // have to manuall set the value
> - me.cpu.flags = (values.flags) ? '+pcid' : undefined;
> + var flags = [];
> +
> + me.flagsAvail.forEach(function(flag) {
> + if (values[flag]) {
> + flags.push('+' + flag.toString());
> + }
> + delete values[flag];
> + });
> +
> + me.cpu.flags = flags.length ? flags.join(';') : undefined;
> +
> delete values.cputype;
> delete values.flags;
> var cpustring = PVE.Parser.printQemuCpu(me.cpu);
> @@ -102,19 +114,19 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
> fieldLabel: gettext('Total cores'),
> name: 'totalcores',
> value: '1'
> - },
> - {
> - // will be a textfield probably someday,
> - // so we name it flags
> + }
> + ];
> +
> + me.flagsAvail.forEach(function(flag, i) {
> + me.column2.push({
> hidden: me.insideWizard,
> disabled: me.insideWizard,
> xtype: 'pvecheckbox',
> - fieldLabel: 'PCID',
> - name: 'flags',
> + fieldLabel: me.flagLabels[i] || flag,
> + name: flag,
> uncheckedValue: 0
> - }
> -
> - ];
> + });
> + });
>
> me.callParent();
> }
> @@ -143,9 +155,14 @@ Ext.define('PVE.qemu.ProcessorEdit', {
> var cpu = PVE.Parser.parseQemuCpu(value);
> ipanel.cpu = cpu;
> data.cputype = cpu.cputype;
> - /*jslint confusion: true*/
> - // .flags is boolean and string
> - data.flags = (cpu.flags === '+pcid');
> + if (cpu.flags) {
> + var flags = cpu.flags.split(';');
> + flags.forEach(function(flag) {
> + var sign = flag.substr(0,1);
> + flag = flag.substr(1);
> + data[flag] = (sign === '+');
> + });
> + }
> }
> me.setValues(data);
> }
>
More information about the pve-devel
mailing list