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

Fiona Ebner f.ebner at proxmox.com
Thu Aug 17 15:59:40 CEST 2023


Am 18.01.23 um 14:58 schrieb Markus Frank:
> @@ -38,14 +54,27 @@ 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";
> +	}

Nit: could use PVE.Parser.printPropertyString but no big deal

> +	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 +87,11 @@ Ext.define('PVE.qemu.MachineInputPanel', {
>  		values.version = 'pc-q35-5.1';
>  	    }
>  	}
> +
> +	me.lookup('kvm').setValue(values.kvm);
> +	values.viommu = machineConf.viommu === '1';

Should be PVE.Parser.parseBoolean to cover all cases (i.e. also 'on',
'yes' and 'true' can be in the config)

> +	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 +147,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,
> +	},

Why handle 'kvm' as an UI element? I guess a view model property would
be the natural place for this.

> +	{
> +	    xtype: 'displayfield',
> +	    name: 'kvmQ35Hint',
> +	    reference: 'kvmQ35Hint',
> +	    userCls: 'pmx-hint',
> +	    value: gettext('vIOMMU needs kvm enabled and q35 firmware'),

s/firmware/machine type/

> +	    hidden: true,
> +	},
>      ],
>  });
>  
> @@ -135,8 +189,12 @@ Ext.define('PVE.qemu.MachineEdit', {
>  	me.load({
>  	    success: function(response) {
>  		let conf = response.result.data;
> +		if (conf.kvm === undefined || conf.kvm === null) {
> +		    conf.kvm = 1;
> +		}

Style nit: could be one line with conf.kvm ??= 1;

>  		let values = {
>  		    machine: conf.machine || '__default__',
> +		    kvm: conf.kvm,
>  		};
>  		values.isWindows = PVE.Utils.is_windows(conf.ostype);
>  		me.setValues(values);





More information about the pve-devel mailing list