pve-manager/www/manager6/qemu/ProcessorEdit.js

295 lines
6.2 KiB
JavaScript
Raw Normal View History

// The view model of the parent shoul contain a 'cgroupMode' variable (or params for v2 are used).
Ext.define('PVE.qemu.ProcessorInputPanel', {
extend: 'Proxmox.panel.InputPanel',
alias: 'widget.pveQemuProcessorPanel',
onlineHelp: 'qm_cpu',
insideWizard: false,
viewModel: {
data: {
socketCount: 1,
coreCount: 1,
showCustomModelPermWarning: false,
userIsRoot: false,
},
formulas: {
totalCoreCount: get => get('socketCount') * get('coreCount'),
cpuunitsDefault: (get) => get('cgroupMode') === 1 ? 1024 : 100,
cpuunitsMin: (get) => get('cgroupMode') === 1 ? 2 : 1,
cpuunitsMax: (get) => get('cgroupMode') === 1 ? 262144 : 10000,
},
},
controller: {
xclass: 'Ext.app.ViewController',
init: function() {
let me = this;
let viewModel = me.getViewModel();
viewModel.set('userIsRoot', Proxmox.UserName === 'root@pam');
},
},
onGetValues: function(values) {
let me = this;
let cpuunitsDefault = me.getViewModel().get('cpuunitsDefault');
if (Array.isArray(values.delete)) {
values.delete = values.delete.join(',');
}
PVE.Utils.delete_if_default(values, 'cpulimit', '0', me.insideWizard);
PVE.Utils.delete_if_default(values, 'cpuunits', `${cpuunitsDefault}`, me.insideWizard);
// build the cpu options:
me.cpu.cputype = values.cputype;
gui: vm: add CPU flag selector with tri-state awareness This allows to select the tri-state (enforce on, enforce off, default from QEMU+CPU Model) for each CPU flag independently. For this a grid with a widgetcolumn is used hosting tree radio buttons for each state. They're marked '+' for enforce on, '-' for enforce off and the default has no label, as it isn't easy to add in such a way that it does not confuses people and does not looks completely ugly.. But, to help people which have a hard time figuring out what the states mean, a fake column was added showing the current selected state's outcome in words. For show casing the new nice interface add all currently supported flags from out API- It could be worth to add some selected CPU model awareness, so that flags are only enabled if they can make sense with the selected model. But one should be able to add this relative easily with this as base. The hardcoded flag lists is not ideal, we should try to generate this in the future, but here already qemu-server is lacking and this is rather independent of the fact and can be done later one just fine too. Note that this /is/ an *advanced* feature so not visible for all directly, while I try to document in short what a flag does it surely isn't perfect and to short to explain all nuances, they should give enough pointers to know if it's relevant at all (amd / intel cpu) and for what one should research Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> (cherry picked from commit 92572ead6dc4e2a4475111a4c4d52be8f849d9a2) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 23:22:19 +03:00
if (values.flags) {
me.cpu.flags = values.flags;
} else {
delete me.cpu.flags;
}
delete values.cputype;
delete values.flags;
var cpustring = PVE.Parser.printQemuCpu(me.cpu);
// remove cputype delete request:
var del = values.delete;
delete values.delete;
if (del) {
del = del.split(',');
Ext.Array.remove(del, 'cputype');
} else {
del = [];
}
if (cpustring) {
values.cpu = cpustring;
} else {
del.push('cpu');
}
var delarr = del.join(',');
if (delarr) {
values.delete = delarr;
}
return values;
},
setValues: function(values) {
let me = this;
let type = values.cputype;
let typeSelector = me.lookupReference('cputype');
let typeStore = typeSelector.getStore();
typeStore.on('load', (store, records, success) => {
if (!success || !type || records.some(x => x.data.name === type)) {
return;
}
// if we get here, a custom CPU model is selected for the VM but we
// don't have permission to configure it - it will not be in the
// list retrieved from the API, so add it manually to allow changing
// other processor options
typeStore.add({
name: type,
displayname: type.replace(/^custom-/, ''),
custom: 1,
vendor: gettext("Unknown"),
});
typeSelector.select(type);
});
me.callParent([values]);
},
cpu: {},
column1: [
{
xtype: 'proxmoxintegerfield',
name: 'sockets',
minValue: 1,
maxValue: 4,
value: '1',
fieldLabel: gettext('Sockets'),
allowBlank: false,
bind: {
value: '{socketCount}',
},
},
{
xtype: 'proxmoxintegerfield',
name: 'cores',
minValue: 1,
maxValue: 128,
value: '1',
fieldLabel: gettext('Cores'),
allowBlank: false,
bind: {
value: '{coreCount}',
},
},
],
column2: [
{
xtype: 'CPUModelSelector',
name: 'cputype',
reference: 'cputype',
fieldLabel: gettext('Type'),
},
{
xtype: 'displayfield',
fieldLabel: gettext('Total cores'),
name: 'totalcores',
isFormField: false,
bind: {
value: '{totalCoreCount}',
},
},
],
columnB: [
{
xtype: 'displayfield',
userCls: 'pmx-hint',
value: gettext('WARNING: You do not have permission to configure custom CPU types, if you change the type you will not be able to go back!'),
hidden: true,
bind: {
hidden: '{!showCustomModelPermWarning}',
},
},
],
advancedColumn1: [
{
xtype: 'proxmoxintegerfield',
name: 'vcpus',
minValue: 1,
maxValue: 1,
value: '',
fieldLabel: gettext('VCPUs'),
deleteEmpty: true,
allowBlank: true,
emptyText: '1',
bind: {
emptyText: '{totalCoreCount}',
maxValue: '{totalCoreCount}',
},
},
{
xtype: 'numberfield',
name: 'cpulimit',
minValue: 0,
maxValue: 128, // api maximum
value: '',
step: 1,
fieldLabel: gettext('CPU limit'),
allowBlank: true,
emptyText: gettext('unlimited'),
},
{
xtype: 'proxmoxtextfield',
name: 'affinity',
vtype: 'CpuSet',
value: '',
fieldLabel: gettext('CPU Affinity'),
allowBlank: true,
emptyText: gettext("All Cores"),
deleteEmpty: true,
bind: {
disabled: '{!userIsRoot}',
},
},
gui: vm: add CPU flag selector with tri-state awareness This allows to select the tri-state (enforce on, enforce off, default from QEMU+CPU Model) for each CPU flag independently. For this a grid with a widgetcolumn is used hosting tree radio buttons for each state. They're marked '+' for enforce on, '-' for enforce off and the default has no label, as it isn't easy to add in such a way that it does not confuses people and does not looks completely ugly.. But, to help people which have a hard time figuring out what the states mean, a fake column was added showing the current selected state's outcome in words. For show casing the new nice interface add all currently supported flags from out API- It could be worth to add some selected CPU model awareness, so that flags are only enabled if they can make sense with the selected model. But one should be able to add this relative easily with this as base. The hardcoded flag lists is not ideal, we should try to generate this in the future, but here already qemu-server is lacking and this is rather independent of the fact and can be done later one just fine too. Note that this /is/ an *advanced* feature so not visible for all directly, while I try to document in short what a flag does it surely isn't perfect and to short to explain all nuances, they should give enough pointers to know if it's relevant at all (amd / intel cpu) and for what one should research Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> (cherry picked from commit 92572ead6dc4e2a4475111a4c4d52be8f849d9a2) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 23:22:19 +03:00
],
advancedColumn2: [
{
xtype: 'proxmoxintegerfield',
name: 'cpuunits',
fieldLabel: gettext('CPU units'),
minValue: '1',
maxValue: '10000',
value: '',
emptyText: '100',
bind: {
minValue: '{cpuunitsMin}',
maxValue: '{cpuunitsMax}',
emptyText: '{cpuunitsDefault}',
},
deleteEmpty: true,
allowBlank: true,
gui: vm: add CPU flag selector with tri-state awareness This allows to select the tri-state (enforce on, enforce off, default from QEMU+CPU Model) for each CPU flag independently. For this a grid with a widgetcolumn is used hosting tree radio buttons for each state. They're marked '+' for enforce on, '-' for enforce off and the default has no label, as it isn't easy to add in such a way that it does not confuses people and does not looks completely ugly.. But, to help people which have a hard time figuring out what the states mean, a fake column was added showing the current selected state's outcome in words. For show casing the new nice interface add all currently supported flags from out API- It could be worth to add some selected CPU model awareness, so that flags are only enabled if they can make sense with the selected model. But one should be able to add this relative easily with this as base. The hardcoded flag lists is not ideal, we should try to generate this in the future, but here already qemu-server is lacking and this is rather independent of the fact and can be done later one just fine too. Note that this /is/ an *advanced* feature so not visible for all directly, while I try to document in short what a flag does it surely isn't perfect and to short to explain all nuances, they should give enough pointers to know if it's relevant at all (amd / intel cpu) and for what one should research Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> (cherry picked from commit 92572ead6dc4e2a4475111a4c4d52be8f849d9a2) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 23:22:19 +03:00
},
{
xtype: 'proxmoxcheckbox',
fieldLabel: gettext('Enable NUMA'),
name: 'numa',
uncheckedValue: 0,
},
gui: vm: add CPU flag selector with tri-state awareness This allows to select the tri-state (enforce on, enforce off, default from QEMU+CPU Model) for each CPU flag independently. For this a grid with a widgetcolumn is used hosting tree radio buttons for each state. They're marked '+' for enforce on, '-' for enforce off and the default has no label, as it isn't easy to add in such a way that it does not confuses people and does not looks completely ugly.. But, to help people which have a hard time figuring out what the states mean, a fake column was added showing the current selected state's outcome in words. For show casing the new nice interface add all currently supported flags from out API- It could be worth to add some selected CPU model awareness, so that flags are only enabled if they can make sense with the selected model. But one should be able to add this relative easily with this as base. The hardcoded flag lists is not ideal, we should try to generate this in the future, but here already qemu-server is lacking and this is rather independent of the fact and can be done later one just fine too. Note that this /is/ an *advanced* feature so not visible for all directly, while I try to document in short what a flag does it surely isn't perfect and to short to explain all nuances, they should give enough pointers to know if it's relevant at all (amd / intel cpu) and for what one should research Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> (cherry picked from commit 92572ead6dc4e2a4475111a4c4d52be8f849d9a2) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 23:22:19 +03:00
],
advancedColumnB: [
{
gui: vm: add CPU flag selector with tri-state awareness This allows to select the tri-state (enforce on, enforce off, default from QEMU+CPU Model) for each CPU flag independently. For this a grid with a widgetcolumn is used hosting tree radio buttons for each state. They're marked '+' for enforce on, '-' for enforce off and the default has no label, as it isn't easy to add in such a way that it does not confuses people and does not looks completely ugly.. But, to help people which have a hard time figuring out what the states mean, a fake column was added showing the current selected state's outcome in words. For show casing the new nice interface add all currently supported flags from out API- It could be worth to add some selected CPU model awareness, so that flags are only enabled if they can make sense with the selected model. But one should be able to add this relative easily with this as base. The hardcoded flag lists is not ideal, we should try to generate this in the future, but here already qemu-server is lacking and this is rather independent of the fact and can be done later one just fine too. Note that this /is/ an *advanced* feature so not visible for all directly, while I try to document in short what a flag does it surely isn't perfect and to short to explain all nuances, they should give enough pointers to know if it's relevant at all (amd / intel cpu) and for what one should research Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> (cherry picked from commit 92572ead6dc4e2a4475111a4c4d52be8f849d9a2) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 23:22:19 +03:00
xtype: 'label',
text: 'Extra CPU Flags:',
},
{
gui: vm: add CPU flag selector with tri-state awareness This allows to select the tri-state (enforce on, enforce off, default from QEMU+CPU Model) for each CPU flag independently. For this a grid with a widgetcolumn is used hosting tree radio buttons for each state. They're marked '+' for enforce on, '-' for enforce off and the default has no label, as it isn't easy to add in such a way that it does not confuses people and does not looks completely ugly.. But, to help people which have a hard time figuring out what the states mean, a fake column was added showing the current selected state's outcome in words. For show casing the new nice interface add all currently supported flags from out API- It could be worth to add some selected CPU model awareness, so that flags are only enabled if they can make sense with the selected model. But one should be able to add this relative easily with this as base. The hardcoded flag lists is not ideal, we should try to generate this in the future, but here already qemu-server is lacking and this is rather independent of the fact and can be done later one just fine too. Note that this /is/ an *advanced* feature so not visible for all directly, while I try to document in short what a flag does it surely isn't perfect and to short to explain all nuances, they should give enough pointers to know if it's relevant at all (amd / intel cpu) and for what one should research Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> (cherry picked from commit 92572ead6dc4e2a4475111a4c4d52be8f849d9a2) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 23:22:19 +03:00
xtype: 'vmcpuflagselector',
name: 'flags',
},
],
});
Ext.define('PVE.qemu.ProcessorEdit', {
extend: 'Proxmox.window.Edit',
alias: 'widget.pveQemuProcessorEdit',
gui: vm: add CPU flag selector with tri-state awareness This allows to select the tri-state (enforce on, enforce off, default from QEMU+CPU Model) for each CPU flag independently. For this a grid with a widgetcolumn is used hosting tree radio buttons for each state. They're marked '+' for enforce on, '-' for enforce off and the default has no label, as it isn't easy to add in such a way that it does not confuses people and does not looks completely ugly.. But, to help people which have a hard time figuring out what the states mean, a fake column was added showing the current selected state's outcome in words. For show casing the new nice interface add all currently supported flags from out API- It could be worth to add some selected CPU model awareness, so that flags are only enabled if they can make sense with the selected model. But one should be able to add this relative easily with this as base. The hardcoded flag lists is not ideal, we should try to generate this in the future, but here already qemu-server is lacking and this is rather independent of the fact and can be done later one just fine too. Note that this /is/ an *advanced* feature so not visible for all directly, while I try to document in short what a flag does it surely isn't perfect and to short to explain all nuances, they should give enough pointers to know if it's relevant at all (amd / intel cpu) and for what one should research Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> (cherry picked from commit 92572ead6dc4e2a4475111a4c4d52be8f849d9a2) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 23:22:19 +03:00
width: 700,
viewModel: {
data: {
cgroupMode: 2,
},
},
initComponent: function() {
let me = this;
me.getViewModel().set('cgroupMode', me.cgroupMode);
var ipanel = Ext.create('PVE.qemu.ProcessorInputPanel');
Ext.apply(me, {
subject: gettext('Processors'),
items: ipanel,
});
me.callParent();
me.load({
success: function(response, options) {
var data = response.result.data;
var value = data.cpu;
if (value) {
var cpu = PVE.Parser.parseQemuCpu(value);
ipanel.cpu = cpu;
data.cputype = cpu.cputype;
if (cpu.flags) {
gui: vm: add CPU flag selector with tri-state awareness This allows to select the tri-state (enforce on, enforce off, default from QEMU+CPU Model) for each CPU flag independently. For this a grid with a widgetcolumn is used hosting tree radio buttons for each state. They're marked '+' for enforce on, '-' for enforce off and the default has no label, as it isn't easy to add in such a way that it does not confuses people and does not looks completely ugly.. But, to help people which have a hard time figuring out what the states mean, a fake column was added showing the current selected state's outcome in words. For show casing the new nice interface add all currently supported flags from out API- It could be worth to add some selected CPU model awareness, so that flags are only enabled if they can make sense with the selected model. But one should be able to add this relative easily with this as base. The hardcoded flag lists is not ideal, we should try to generate this in the future, but here already qemu-server is lacking and this is rather independent of the fact and can be done later one just fine too. Note that this /is/ an *advanced* feature so not visible for all directly, while I try to document in short what a flag does it surely isn't perfect and to short to explain all nuances, they should give enough pointers to know if it's relevant at all (amd / intel cpu) and for what one should research Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> (cherry picked from commit 92572ead6dc4e2a4475111a4c4d52be8f849d9a2) Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-06 23:22:19 +03:00
data.flags = cpu.flags;
}
let caps = Ext.state.Manager.get('GuiCap');
if (data.cputype.indexOf('custom-') === 0 &&
!caps.nodes['Sys.Audit']) {
let vm = ipanel.getViewModel();
vm.set("showCustomModelPermWarning", true);
}
}
me.setValues(data);
},
});
},
});