[pve-devel] [PATCH manager v4 5/5] ui: MachineEdit with viommu checkbox
Markus Frank
m.frank at proxmox.com
Fri Nov 25 15:08:57 CET 2022
Added a Checkbox to enable viommu, if q35 is selected.
Otherwise (i440fx & !kvm) the checkbox is disabled, if not ticked on
before. If ticked on before, the user is able to uncheck the checkbox.
If kvm is deactivated or i440fx is selected, a Hint tells that q35 and
kvm are required for vIOMMU.
The UI also needs to parse the new machine parameter as PropertyString.
Signed-off-by: Markus Frank <m.frank at proxmox.com>
---
www/manager6/qemu/MachineEdit.js | 56 ++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js
index f928c80c..03fcf36d 100644
--- a/www/manager6/qemu/MachineEdit.js
+++ b/www/manager6/qemu/MachineEdit.js
@@ -1,6 +1,7 @@
Ext.define('PVE.qemu.MachineInputPanel', {
extend: 'Proxmox.panel.InputPanel',
xtype: 'pveMachineInputPanel',
+ onlineHelp: 'qm_pci_viommu',
controller: {
xclass: 'Ext.app.ViewController',
@@ -12,11 +13,26 @@ Ext.define('PVE.qemu.MachineInputPanel', {
onMachineChange: function(field, value) {
let me = this;
let version = me.lookup('version');
+ let kvm = me.lookup('kvm');
+ let viommu = me.lookup('viommu');
+ let kvmHint = me.lookup('kvmQ35Hint');
let store = version.getStore();
let oldRec = store.findRecord('id', version.getValue(), 0, false, false, true);
let type = value === 'q35' ? 'q35' : 'i440fx';
store.clearFilter();
store.addFilter(val => val.data.id === 'latest' || val.data.type === type);
+ if ((type === 'q35' && kvm.getValue()) || viommu.getValue()) {
+ viommu.setDisabled(false);
+ kvmHint.setVisible(false);
+ } else {
+ // disable checkbox if vIOMMU is not possible and checkbox was not
+ // ticked on before
+ viommu.setDisabled(true);
+ }
+ if (type === 'i440fx' || !kvm.getValue()) {
+ // show hint when vIOMMU cannot be used
+ kvmHint.setVisible(true);
+ }
if (!me.getView().isWindows) {
version.setValue('latest');
} else {
@@ -35,17 +51,31 @@ Ext.define('PVE.qemu.MachineInputPanel', {
},
onGetValues: function(values) {
+ console.log(values);
if (values.version && values.version !== 'latest') {
values.machine = values.version;
delete values.delete;
+ } else if ((typeof values.machine === 'undefined') && values.viommu) {
+ // set machine to pc to raise the viommu + i440fx error from backend
+ // instead of regex error
+ values.machine = "pc";
+ delete values.delete;
}
delete values.version;
+ if (values.viommu) {
+ values.machine += ",viommu=1";
+ }
+ delete values.viommu;
+ delete values.kvm;
return values;
},
setValues: function(values) {
let me = this;
+ let machineConf = PVE.Parser.parsePropertyString(values.machine, "type");
+ values.machine = machineConf.type;
+
me.isWindows = values.isWindows;
if (values.machine === 'pc') {
values.machine = '__default__';
@@ -58,6 +88,11 @@ Ext.define('PVE.qemu.MachineInputPanel', {
values.version = 'pc-q35-5.1';
}
}
+
+ me.lookup('kvm').setValue(values.kvm);
+ values.viommu = machineConf.viommu === "1";
+ me.lookup('viommu').setValue(values.viommu);
+
if (values.machine !== '__default__' && values.machine !== 'q35') {
values.version = values.machine;
values.machine = values.version.match(/q35/) ? 'q35' : '__default__';
@@ -113,6 +148,26 @@ Ext.define('PVE.qemu.MachineInputPanel', {
fieldLabel: gettext('Note'),
value: gettext('Machine version change may affect hardware layout and settings in the guest OS.'),
},
+ {
+ xtype: 'proxmoxcheckbox',
+ fieldLabel: gettext('vIOMMU'),
+ name: 'viommu',
+ reference: 'viommu',
+ },
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'kvm',
+ reference: 'kvm',
+ hidden: true,
+ },
+ {
+ xtype: 'displayfield',
+ name: 'kvmQ35Hint',
+ reference: 'kvmQ35Hint',
+ userCls: 'pmx-hint',
+ value: gettext('vIOMMU needs kvm enabled and q35 firmware'),
+ hidden: true,
+ },
],
});
@@ -137,6 +192,7 @@ Ext.define('PVE.qemu.MachineEdit', {
let conf = response.result.data;
let values = {
machine: conf.machine || '__default__',
+ kvm: conf.kvm,
};
values.isWindows = PVE.Utils.is_windows(conf.ostype);
me.setValues(values);
--
2.30.2
More information about the pve-devel
mailing list