From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C8627BBBB for ; Fri, 25 Nov 2022 15:09:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A89D91D078 for ; Fri, 25 Nov 2022 15:09:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 25 Nov 2022 15:09:27 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 12E7C448F1 for ; Fri, 25 Nov 2022 15:09:27 +0100 (CET) From: Markus Frank To: pve-devel@lists.proxmox.com Date: Fri, 25 Nov 2022 15:08:57 +0100 Message-Id: <20221125140857.121622-6-m.frank@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221125140857.121622-1-m.frank@proxmox.com> References: <20221125140857.121622-1-m.frank@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.042 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager v4 5/5] ui: MachineEdit with viommu checkbox X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2022 14:09:59 -0000 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 --- 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