1 // The view model of the parent shoul contain a 'cgroupMode' variable (or params for v2 are used).
2 Ext
.define('PVE.qemu.ProcessorInputPanel', {
3 extend
: 'Proxmox.panel.InputPanel',
4 alias
: 'widget.pveQemuProcessorPanel',
13 showCustomModelPermWarning
: false,
17 totalCoreCount
: get => get('socketCount') * get('coreCount'),
18 cpuunitsDefault
: (get) => get('cgroupMode') === 1 ? 1024 : 100,
19 cpuunitsMin
: (get) => get('cgroupMode') === 1 ? 2 : 1,
20 cpuunitsMax
: (get) => get('cgroupMode') === 1 ? 262144 : 10000,
25 xclass
: 'Ext.app.ViewController',
28 let viewModel
= me
.getViewModel();
30 viewModel
.set('userIsRoot', Proxmox
.UserName
=== 'root@pam');
34 onGetValues: function(values
) {
36 let cpuunitsDefault
= me
.getViewModel().get('cpuunitsDefault');
38 if (Array
.isArray(values
.delete)) {
39 values
.delete = values
.delete.join(',');
42 PVE
.Utils
.delete_if_default(values
, 'cpulimit', '0', me
.insideWizard
);
43 PVE
.Utils
.delete_if_default(values
, 'cpuunits', `${cpuunitsDefault}`, me
.insideWizard
);
45 // build the cpu options:
46 me
.cpu
.cputype
= values
.cputype
;
49 me
.cpu
.flags
= values
.flags
;
54 delete values
.cputype
;
56 var cpustring
= PVE
.Parser
.printQemuCpu(me
.cpu
);
58 // remove cputype delete request:
59 var del
= values
.delete;
63 Ext
.Array
.remove(del
, 'cputype');
69 values
.cpu
= cpustring
;
74 var delarr
= del
.join(',');
76 values
.delete = delarr
;
82 setValues: function(values
) {
85 let type
= values
.cputype
;
86 let typeSelector
= me
.lookupReference('cputype');
87 let typeStore
= typeSelector
.getStore();
88 typeStore
.on('load', (store
, records
, success
) => {
89 if (!success
|| !type
|| records
.some(x
=> x
.data
.name
=== type
)) {
93 // if we get here, a custom CPU model is selected for the VM but we
94 // don't have permission to configure it - it will not be in the
95 // list retrieved from the API, so add it manually to allow changing
96 // other processor options
99 displayname
: type
.replace(/^custom-/, ''),
101 vendor
: gettext("Unknown"),
103 typeSelector
.select(type
);
106 me
.callParent([values
]);
113 xtype
: 'proxmoxintegerfield',
118 fieldLabel
: gettext('Sockets'),
121 value
: '{socketCount}',
125 xtype
: 'proxmoxintegerfield',
130 fieldLabel
: gettext('Cores'),
133 value
: '{coreCount}',
140 xtype
: 'CPUModelSelector',
142 reference
: 'cputype',
143 fieldLabel
: gettext('Type'),
146 xtype
: 'displayfield',
147 fieldLabel
: gettext('Total cores'),
151 value
: '{totalCoreCount}',
158 xtype
: 'displayfield',
160 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!'),
163 hidden
: '{!showCustomModelPermWarning}',
170 xtype
: 'proxmoxintegerfield',
175 fieldLabel
: gettext('VCPUs'),
180 emptyText
: '{totalCoreCount}',
181 maxValue
: '{totalCoreCount}',
185 xtype
: 'numberfield',
188 maxValue
: 128, // api maximum
191 fieldLabel
: gettext('CPU limit'),
193 emptyText
: gettext('unlimited'),
196 xtype
: 'proxmoxtextfield',
200 fieldLabel
: gettext('CPU Affinity'),
202 emptyText
: gettext("All Cores"),
205 disabled
: '{!userIsRoot}',
212 xtype
: 'proxmoxintegerfield',
214 fieldLabel
: gettext('CPU units'),
220 minValue
: '{cpuunitsMin}',
221 maxValue
: '{cpuunitsMax}',
222 emptyText
: '{cpuunitsDefault}',
228 xtype
: 'proxmoxcheckbox',
229 fieldLabel
: gettext('Enable NUMA'),
237 text
: 'Extra CPU Flags:',
240 xtype
: 'vmcpuflagselector',
246 Ext
.define('PVE.qemu.ProcessorEdit', {
247 extend
: 'Proxmox.window.Edit',
248 alias
: 'widget.pveQemuProcessorEdit',
258 initComponent: function() {
260 me
.getViewModel().set('cgroupMode', me
.cgroupMode
);
262 var ipanel
= Ext
.create('PVE.qemu.ProcessorInputPanel');
265 subject
: gettext('Processors'),
272 success: function(response
, options
) {
273 var data
= response
.result
.data
;
274 var value
= data
.cpu
;
276 var cpu
= PVE
.Parser
.parseQemuCpu(value
);
278 data
.cputype
= cpu
.cputype
;
280 data
.flags
= cpu
.flags
;
283 let caps
= Ext
.state
.Manager
.get('GuiCap');
284 if (data
.cputype
.indexOf('custom-') === 0 &&
285 !caps
.nodes
['Sys.Audit']) {
286 let vm
= ipanel
.getViewModel();
287 vm
.set("showCustomModelPermWarning", true);