From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <t.lamprecht@proxmox.com>
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 7DAA894FE5
 for <pve-devel@lists.proxmox.com>; Thu, 11 Apr 2024 17:13:54 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 52E9B34547
 for <pve-devel@lists.proxmox.com>; Thu, 11 Apr 2024 17:13:54 +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 <pve-devel@lists.proxmox.com>; Thu, 11 Apr 2024 17:13:53 +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 107D344323
 for <pve-devel@lists.proxmox.com>; Thu, 11 Apr 2024 17:13:53 +0200 (CEST)
Message-ID: <ca746021-8520-4360-9de8-48e40797f660@proxmox.com>
Date: Thu, 11 Apr 2024 17:13:50 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird Beta
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Markus Frank <m.frank@proxmox.com>
References: <20240411104822.832432-1-m.frank@proxmox.com>
 <20240411104822.832432-4-m.frank@proxmox.com>
Content-Language: en-GB
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
In-Reply-To: <20240411104822.832432-4-m.frank@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.057 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
Subject: Re: [pve-devel] [PATCH manager v9 3/3] ui: machine: add viommu
 ComboBox
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 11 Apr 2024 15:13:54 -0000

On 11/04/2024 12:48, Markus Frank wrote:
> Added a proxmoxKVComboBox for selecting a vIOMMU implementation for a
> VM. If i440fx is selected, a hint tells that q35 is required for Intel vIOMMU.
> 
> The UI also needs to parse the new machine parameter as PropertyString.
> 
> Signed-off-by: Markus Frank <m.frank@proxmox.com>
> ---
>  www/manager6/qemu/MachineEdit.js | 45 ++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> diff --git a/www/manager6/qemu/MachineEdit.js b/www/manager6/qemu/MachineEdit.js
> index f928c80c..45f3d34d 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',
nit: this could be done in a separate patch.

>  
>      controller: {
>  	xclass: 'Ext.app.ViewController',

> @@ -40,12 +44,30 @@ Ext.define('PVE.qemu.MachineInputPanel', {
>  	    delete values.delete;
>  	}
>  	delete values.version;
> +	if (values.machine === undefined) {
> +	    if (values.viommu) {
> +		delete values.delete;
> +		values.machine = "pc";
> +	    } else {
> +		values.delete = "machine";
> +	    }
> +	}
> +	if (values.viommu) {
> +	    values.machine += ",viommu=" + values.viommu;
> +	}
> +	if (values.delete === "viommu") {
> +	    delete values.delete;
> +	}
> +	delete values.viommu;

can't we use printPropertyString here (with a bit less code preparing the object
passed to it), or at least try making it a bit less convoluted..

>  	    fieldLabel: gettext('Note'),
>  	    value: gettext('Machine version change may affect hardware layout and settings in the guest OS.'),
>  	},
> +	{
> +	    xtype: 'proxmoxKVComboBox',
> +	    fieldLabel: gettext('vIOMMU'),
> +	    name: 'viommu',
> +	    reference: 'viommu',
> +	    value: '__default__',
> +	    comboItems: [
> +		['__default__', Proxmox.Utils.defaultText + ' (None)'],
> +		['intel', 'Intel'],
> +		['virtio', 'VirtIO'],
> +	    ],
> +	},
> +	{
> +	    xtype: 'displayfield',
> +	    name: 'q35Hint',
> +	    reference: 'q35Hint',
> +	    userCls: 'pmx-hint',
> +	    value: gettext('Intel vIOMMU needs the q35 machine type'),

maybe we could mark the field invalid (if that text is returned in the
validity check it will be shown as tooltip) instead of using the hint?

> +	    hidden: true,
> +	},
>      ],
>  });
>