[pve-devel] [PATCH manager] ui: MachineEdit with viommu checkbox

Markus Frank m.frank at proxmox.com
Tue May 3 13:19:01 CEST 2022


Added a Checkbox to enable viommu, if q35 is selected.
Otherwise (i440fx) the checkbox is disabled.

The GUI 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 | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js
index f928c80c..41c4dd93 100644
--- a/www/manager6/qemu/MachineEdit.js
+++ b/www/manager6/qemu/MachineEdit.js
@@ -17,6 +17,13 @@ Ext.define('PVE.qemu.MachineInputPanel', {
 	    let type = value === 'q35' ? 'q35' : 'i440fx';
 	    store.clearFilter();
 	    store.addFilter(val => val.data.id === 'latest' || val.data.type === type);
+	    let viommuButton = me.lookup('viommu');
+	    if (type === 'i440fx') {
+		viommuButton.setValue(false);
+		viommuButton.setDisabled(true);
+	    } else {
+		viommuButton.setDisabled(false);
+	    }
 	    if (!me.getView().isWindows) {
 		version.setValue('latest');
 	    } else {
@@ -40,12 +47,17 @@ Ext.define('PVE.qemu.MachineInputPanel', {
 	    delete values.delete;
 	}
 	delete values.version;
+	if (values.viommu) values.machine += ",viommu=1";
+	delete values.viommu;
 	return values;
     },
 
     setValues: function(values) {
 	let me = this;
 
+	let machine_conf = PVE.Parser.parsePropertyString(values.machine, "type");
+	values.machine = machine_conf.type;
+
 	me.isWindows = values.isWindows;
 	if (values.machine === 'pc') {
 	    values.machine = '__default__';
@@ -54,10 +66,14 @@ Ext.define('PVE.qemu.MachineInputPanel', {
 	if (me.isWindows) {
 	    if (values.machine === '__default__') {
 		values.version = 'pc-i440fx-5.1';
+		values.viommu = false;
 	    } else if (values.machine === 'q35') {
 		values.version = 'pc-q35-5.1';
 	    }
 	}
+
+	values.viommu = machine_conf.viommu === "1";
+
 	if (values.machine !== '__default__' && values.machine !== 'q35') {
 	    values.version = values.machine;
 	    values.machine = values.version.match(/q35/) ? 'q35' : '__default__';
@@ -108,6 +124,12 @@ Ext.define('PVE.qemu.MachineInputPanel', {
 		},
 	    },
 	},
+	{
+	    xtype: 'proxmoxcheckbox',
+	    fieldLabel: gettext('vIOMMU'),
+	    name: 'viommu',
+	    reference: 'viommu',
+	},
 	{
 	    xtype: 'displayfield',
 	    fieldLabel: gettext('Note'),
-- 
2.30.2






More information about the pve-devel mailing list