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 54DC18A4F for ; Tue, 22 Aug 2023 14:41:34 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2DF18CD34 for ; Tue, 22 Aug 2023 14:41:04 +0200 (CEST) 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 ; Tue, 22 Aug 2023 14:41:02 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9FE1B43327 for ; Tue, 22 Aug 2023 14:41:02 +0200 (CEST) From: Markus Frank To: pve-devel@lists.proxmox.com Date: Tue, 22 Aug 2023 14:40:41 +0200 Message-Id: <20230822124041.119554-5-m.frank@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230822124041.119554-1-m.frank@proxmox.com> References: <20230822124041.119554-1-m.frank@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.051 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [data.id] Subject: [pve-devel] [PATCH manager v6 4/4] 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: Tue, 22 Aug 2023 12:41:34 -0000 Add 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 | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js index f928c80c..25e8dc83 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_system_settings', 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.getView().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) || 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) { + // show hint when vIOMMU cannot be used + kvmHint.setVisible(true); + } if (!me.getView().isWindows) { version.setValue('latest'); } else { @@ -38,14 +54,26 @@ Ext.define('PVE.qemu.MachineInputPanel', { if (values.version && values.version !== 'latest') { values.machine = values.version; delete values.delete; + } else if (values.machine === undefined && values.viommu) { + // set machine to pc to raise the viommu + i440fx error + // from qemu-server instead of a regex error + values.machine = "pc"; + 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 machineConf = PVE.Parser.parsePropertyString(values.machine, "type"); + values.machine = machineConf.type; + me.isWindows = values.isWindows; if (values.machine === 'pc') { values.machine = '__default__'; @@ -58,6 +86,11 @@ Ext.define('PVE.qemu.MachineInputPanel', { values.version = 'pc-q35-5.1'; } } + + me.kvm = values.kvm; + values.viommu = PVE.Parser.parseBoolean(machineConf.viommu); + 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 +146,20 @@ 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: 'displayfield', + name: 'kvmQ35Hint', + reference: 'kvmQ35Hint', + userCls: 'pmx-hint', + value: gettext('vIOMMU needs kvm enabled and q35 machine type'), + hidden: true, + }, ], }); @@ -135,8 +182,10 @@ Ext.define('PVE.qemu.MachineEdit', { me.load({ success: function(response) { let conf = response.result.data; + conf.kvm ??= 1; let values = { machine: conf.machine || '__default__', + kvm: conf.kvm, }; values.isWindows = PVE.Utils.is_windows(conf.ostype); me.setValues(values); -- 2.39.2