[pve-devel] [PATCH manager 6/6 v2] gui: let users add PCI devices

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Nov 22 08:41:26 CET 2018


On 11/20/18 5:13 PM, Dominik Csapak wrote:
> this enables the gui part to enable the user to add a pci device
> via the gui
> 
> we disable the button after 4 devices, since that is the maximum
> in the backend
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  www/manager6/qemu/HardwareView.js | 25 ++++++++++++++++++++++---
>  1 file changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
> index 8313c2a4..a11f1c9e 100644
> --- a/www/manager6/qemu/HardwareView.js
> +++ b/www/manager6/qemu/HardwareView.js
> @@ -219,6 +219,7 @@ Ext.define('PVE.qemu.HardwareView', {
>  		order: i,
>  		tdCls: 'pve-itype-icon-pci',
>  		never_delete: caps.nodes['Sys.Console'] ? false : true,
> +		editor: caps.nodes['Sys.Console'] ? 'PVE.qemu.PCIEdit' : undefined,
>  		header: gettext('PCI Device') + ' (' + confid + ')'
>  	    };
>  	}
> @@ -501,17 +502,21 @@ Ext.define('PVE.qemu.HardwareView', {
>  	    // see that there is already one
>  	    efidisk_menuitem.setDisabled(me.rstore.getData().map.efidisk0 !== undefined);
>  	    // en/disable usb add button
> -	    var count = 0;
> +	    var usbcount = 0;
> +	    var pcicount = 0;
>  	    var hasCloudInit = false;
>  	    me.rstore.getData().items.forEach(function(item){
>  		if (/^usb\d+/.test(item.id)) {
> -		    count++;
> +		    usbcount++;
> +		} else if (/^hostpci\d+/.test(item.id)) {
> +		    pcicount++;
>  		}
>  		if (!hasCloudInit && /vm-.*-cloudinit/.test(item.data.value)) {
>  		    hasCloudInit = true;
>  		}
>  	    });
> -	    me.down('#addusb').setDisabled((count >= 5));
> +	    me.down('#addusb').setDisabled((usbcount >= 5));
> +	    me.down('#addpci').setDisabled((pcicount >= 4));
>  	    me.down('#addci').setDisabled(hasCloudInit);

this breaks (even before this patch) our caps Sys.Console heuristic disable check.
I pushed a trivial fix to master for the existing ones, please integrate that in
your series.

>  
>  	    if (!rec) {
> @@ -615,6 +620,20 @@ Ext.define('PVE.qemu.HardwareView', {
>  				}
>  			    },
>  			    {
> +				text: gettext('PCI Device'),
> +				itemId: 'addpci',
> +				iconCls: 'pve-itype-icon-pci',
> +				disabled: !caps.nodes['Sys.Console'],
> +				handler: function() {
> +				    var win = Ext.create('PVE.qemu.PCIEdit', {
> +					url: '/api2/extjs/' + baseurl,
> +					pveSelNode: me.pveSelNode
> +				    });
> +				    win.on('destroy', reload);
> +				    win.show();
> +				}
> +			    },
> +			    {
>  				text: gettext('Serial Port'),
>  				itemId: 'addserial',
>  				iconCls: 'pve-itype-icon-serial',
> 





More information about the pve-devel mailing list