public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "DERUMIER, Alexandre" <Alexandre.DERUMIER@groupe-cyllene.com>
To: "pve-devel@lists.proxmox.com" <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH manager v2 11/13] ui: add dc/HardwareView: a CRUD interface for hardware mapping
Date: Thu, 25 Aug 2022 15:37:59 +0000	[thread overview]
Message-ID: <38ddcb04-c9e8-4804-7ea2-c330e3357258@groupe-cyllene.com> (raw)
In-Reply-To: <20220825092440.1810328-30-d.csapak@proxmox.com>

I don't known if it's a bug in the gui, or the api.

But, if you update an existing mapping,with currently,a simple function 
pci with mdev=1, and you change it to a pci multifunction with mdev=0,

the mdev value is not updated.

(This occur in the other direction too)


original singly function with mdev=1
--------
{
   "pci": {
     "sharednvidia": {
       "pve2": {
         "path": "0000:02:00.0",
         "subsystem-vendor": "0x10de",
         "subsystem-device": "0x131b",
         "device": "0x1c31",
         "mdev": "1",
         "iommugroup": "47",
         "vendor": "0x10de"
       },
     }
   },
   "digest": "7e544172eb5487e753672f6511bae9602338de6f"
}


after update to multiple function, mdev should be 0 instead 1.

--------
{
   "pci": {
     "sharednvidia": {
       "pve2": {
         "path": "0000:02:00",
         "subsystem-vendor": "0x10de",
         "subsystem-device": "0x131b",
         "device": "0x1c31",
         "mdev": "1",
         "iommugroup": "47",
         "vendor": "0x10de"
       },
     }
   },
   "digest": "7e544172eb5487e753672f6511bae9602338de6f"
}

Le 25/08/22 à 11:24, Dominik Csapak a écrit :
> it's possible to add/edit/remove mappings here, with a cluster
> wide view on the mappings and validity.
> 
> to do that, we have to to an api call for each node, since
> we don't have the pci status synced across them.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>   www/manager6/Makefile           |   1 +
>   www/manager6/dc/Config.js       |  18 +-
>   www/manager6/dc/HardwareView.js | 324 ++++++++++++++++++++++++++++++++
>   3 files changed, 341 insertions(+), 2 deletions(-)
>   create mode 100644 www/manager6/dc/HardwareView.js
> 
> diff --git a/www/manager6/Makefile b/www/manager6/Makefile
> index 5507276e..869395e1 100644
> --- a/www/manager6/Makefile
> +++ b/www/manager6/Makefile
> @@ -163,6 +163,7 @@ JSSRC= 							\
>   	dc/UserEdit.js					\
>   	dc/UserView.js					\
>   	dc/MetricServerView.js				\
> +	dc/HardwareView.js				\
>   	lxc/CmdMenu.js					\
>   	lxc/Config.js					\
>   	lxc/CreateWizard.js				\
> diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
> index 13ded12e..37148588 100644
> --- a/www/manager6/dc/Config.js
> +++ b/www/manager6/dc/Config.js
> @@ -255,8 +255,22 @@ Ext.define('PVE.dc.Config', {
>   		iconCls: 'fa fa-bar-chart',
>   		itemId: 'metricservers',
>   		onlineHelp: 'external_metric_server',
> -	    },
> -	    {
> +	    });
> +	}
> +
> +	if (caps.hardware['Hardware.Use'] ||
> +	    caps.hardware['Hardware.Audit'] ||
> +	    caps.hardware['Hardware.Configure']) {
> +	    me.items.push({
> +		xtype: 'pveDcHardwareView',
> +		title: gettext('Hardware'),
> +		iconCls: 'fa fa-desktop',
> +		itemId: 'hardware',
> +	    });
> +	}
> +
> +	if (caps.dc['Sys.Audit']) {
> +	    me.items.push({
>   		xtype: 'pveDcSupport',
>   		title: gettext('Support'),
>   		itemId: 'support',
> diff --git a/www/manager6/dc/HardwareView.js b/www/manager6/dc/HardwareView.js
> new file mode 100644
> index 00000000..7201d70f
> --- /dev/null
> +++ b/www/manager6/dc/HardwareView.js
> @@ -0,0 +1,324 @@
> +Ext.define('pve-hardware-tree', {
> +    extend: 'Ext.data.Model',
> +    fields: ['type', 'text', 'path', 'ntype',
> +	{
> +	    name: 'vendor',
> +	    type: 'string',
> +	},
> +	{
> +	    name: 'device',
> +	    type: 'string',
> +	},
> +	{
> +	    name: 'iconCls',
> +	    calculate: function(data) {
> +		if (data.ntype === 'entry') {
> +		    if (data.type === 'usb') {
> +			return 'fa fa-fw fa-usb';
> +		    }
> +		    if (data.type === 'pci') {
> +			return 'pve-itype-icon-pci';
> +		    }
> +		    return 'fa fa-fw fa-folder-o';
> +		}
> +
> +		return 'fa fa-fw fa-building';
> +	    },
> +	},
> +	{
> +	    name: 'leaf',
> +	    calculate: function(data) {
> +		return data.ntype && data.ntype !== 'entry';
> +	    },
> +	},
> +    ],
> +
> +});
> +
> +Ext.define('PVE.dc.HardwareView', {
> +    extend: 'Ext.tree.Panel',
> +    alias: 'widget.pveDcHardwareView',
> +    mixins: ['Proxmox.Mixin.CBind'],
> +
> +    rootVisible: false,
> +
> +    cbindData: function(initialConfig) {
> +	let me = this;
> +	const caps = Ext.state.Manager.get('GuiCap');
> +	me.canConfigure = !!caps.nodes['Sys.Modify'] && !!caps.hardware['Hardware.Configure'];
> +
> +	return {};
> +    },
> +
> +    controller: {
> +	xclass: 'Ext.app.ViewController',
> +
> +	addPCI: function() {
> +	    let me = this;
> +	    let nodename = Proxmox.NodeName;
> +	    Ext.create('PVE.node.PCIEditWindow', {
> +		url: `/nodes/${nodename}/hardware/mapping/pci`,
> +		autoShow: true,
> +		listeners: {
> +		    destroy: () => me.load(),
> +		},
> +	    });
> +	},
> +
> +	addUSB: function() {
> +	    let me = this;
> +	    let nodename = Proxmox.NodeName;
> +	    Ext.create('PVE.node.USBEditWindow', {
> +		url: `/nodes/${nodename}/hardware/mapping/usb`,
> +		autoShow: true,
> +		listeners: {
> +		    destroy: () => me.load(),
> +		},
> +	    });
> +	},
> +
> +	addHost: function() {
> +	    let me = this;
> +	    me.edit(false);
> +	},
> +
> +	edit: function(includeNodename = true) {
> +	    let me = this;
> +	    let view = me.getView();
> +	    let selection = view.getSelection();
> +	    if (!selection || !selection.length) {
> +		return;
> +	    }
> +	    let rec = selection[0];
> +	    if (!view.canConfigure) {
> +		return;
> +	    }
> +
> +	    let type = 'PVE.node.' + (rec.data.type === 'pci' ? 'PCIEditWindow' : 'USBEditWindow');
> +
> +	    Ext.create(type, {
> +		url: `/nodes/${rec.data.node}/hardware/mapping/${rec.data.type}/${rec.data.entry}`,
> +		autoShow: true,
> +		autoLoad: rec.data.ntype !== 'entry',
> +		nodename: rec.data.ntype !== 'entry' && includeNodename ? rec.data.node : undefined,
> +		name: rec.data.entry ?? rec.data.text,
> +		listeners: {
> +		    destroy: () => me.load(),
> +		},
> +	    });
> +	},
> +
> +	load: function() {
> +	    let me = this;
> +	    let view = me.getView();
> +	    Proxmox.Utils.API2Request({
> +		url: '/cluster/hardware/mapping',
> +		method: 'GET',
> +		failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
> +		success: function({ result: { data } }) {
> +		    view.setRootNode({
> +			children: data,
> +		    });
> +		    let root = view.getRootNode();
> +		    root.expand();
> +		    root.childNodes.forEach(node => node.expand());
> +		    me.loadRemainigNodes();
> +		},
> +	    });
> +	},
> +
> +	loadRemainigNodes: function() {
> +	    let me = this;
> +	    let view = me.getView();
> +	    PVE.data.ResourceStore.getNodes().forEach(({ node }) => {
> +		if (node === Proxmox.NodeName) {
> +		    return;
> +		}
> +		Proxmox.Utils.API2Request({
> +		    url: `/nodes/${node}/hardware/mapping/all`,
> +		    method: 'GET',
> +		    failure: function(response) {
> +			view.getRootNode()?.cascade(function(rec) {
> +			    if (rec.data.node !== node) {
> +				return;
> +			    }
> +
> +			    rec.set('valid', 0);
> +			    rec.set('errmsg', response.htmlStatus);
> +			    rec.commit();
> +			});
> +		    },
> +		    success: function({ result: { data } }) {
> +			let entries = {};
> +			data.forEach((entry) => {
> +			    entries[entry.name] = entry;
> +			});
> +			view.getRootNode()?.cascade(function(rec) {
> +			    if (rec.data.node !== node) {
> +				return;
> +			    }
> +
> +			    let entry = entries[rec.data.entry];
> +
> +			    rec.set('valid', entry.valid);
> +			    rec.set('errmsg', entry.errmsg);
> +			    rec.commit();
> +			});
> +		    },
> +		});
> +	    });
> +	},
> +    },
> +
> +    store: {
> +	sorters: 'text',
> +	model: 'pve-hardware-tree',
> +	data: {},
> +    },
> +
> +
> +    tbar: [
> +	{
> +	    text: gettext('Add'),
> +	    cbind: {
> +		disabled: '{!canConfigure}',
> +	    },
> +	    menu: [
> +		{
> +		    text: gettext('PCI'),
> +		    iconCls: 'pve-itype-icon-pci',
> +		    handler: 'addPCI',
> +		},
> +		{
> +		    text: gettext('USB'),
> +		    iconCls: 'fa fa-fw fa-usb black',
> +		    handler: 'addUSB',
> +		},
> +	    ],
> +	},
> +	{
> +	    xtype: 'proxmoxButton',
> +	    text: gettext('New Host mapping'),
> +	    disabled: true,
> +	    parentXType: 'treepanel',
> +	    enableFn: function(_rec) {
> +		return this.up('treepanel').canConfigure;
> +	    },
> +	    handler: 'addHost',
> +	},
> +	{
> +	    xtype: 'proxmoxButton',
> +	    text: gettext('Edit'),
> +	    disabled: true,
> +	    parentXType: 'treepanel',
> +	    enableFn: function(rec) {
> +		return rec.data.ntype !== 'entry' && this.up('treepanel').canConfigure;
> +	    },
> +	    cbind: {
> +		disabled: '{!canConfigure}',
> +	    },
> +	    handler: 'edit',
> +	},
> +	{
> +	    xtype: 'proxmoxStdRemoveButton',
> +	    parentXType: 'treepanel',
> +	    getUrl: function(rec) {
> +		let data = rec.data;
> +		return `/api2/extjs/nodes/${data.node}/hardware/mapping/${data.type}/${data.entry}`;
> +	    },
> +	    confirmMsg: function(rec) {
> +		let msg = gettext('Are you sure you want to remove entry {0} for {1}');
> +		return Ext.String.format(msg, `'${rec.data.entry}'`, `'${rec.data.node}'`);
> +	    },
> +	    enableFn: function(rec) {
> +		return rec.data.ntype !== 'entry' && this.up('treepanel').canConfigure;
> +	    },
> +	    callback: 'load',
> +	    disabled: true,
> +	    text: gettext('Remove'),
> +	},
> +    ],
> +
> +    columns: [
> +	{
> +	    xtype: 'treecolumn',
> +	    text: gettext('Type/ID/Node'),
> +	    dataIndex: 'text',
> +	    renderer: function(value, _meta, record) {
> +		if (record.data.ntype === 'entry') {
> +		    let typeMap = {
> +			usb: gettext('USB'),
> +			pci: gettext('PCI'),
> +		    };
> +		    let type = typeMap[record.data.type] || Proxmox.Utils.unknownText;
> +		    return `${value} (${type})`;
> +		}
> +		return value;
> +	    },
> +	    width: 200,
> +	},
> +	{
> +	    text: gettext('Vendor'),
> +	    dataIndex: 'vendor',
> +	},
> +	{
> +	    text: gettext('Device'),
> +	    dataIndex: 'device',
> +	},
> +	{
> +	    text: gettext('Subsystem Vendor'),
> +	    dataIndex: 'subsystem-vendor',
> +	},
> +	{
> +	    text: gettext('Subsystem Device'),
> +	    dataIndex: 'subsystem-device',
> +	},
> +	{
> +	    text: gettext('IOMMU group'),
> +	    dataIndex: 'iommugroup',
> +	},
> +	{
> +	    text: gettext('Path'),
> +	    flex: 1,
> +	    dataIndex: 'path',
> +	    renderer: function(value) {
> +		value = value ?? '';
> +		if (value.indexOf(';') !== -1) {
> +		    return value.split(';').join(', ');
> +		}
> +		return value;
> +	    },
> +	},
> +	{
> +	    header: gettext('Status'),
> +	    dataIndex: 'valid',
> +	    flex: 1,
> +	    renderer: function(value, _metadata, record) {
> +		if (record.data.ntype !== 'mapping') {
> +		    return '';
> +		}
> +		let iconCls;
> +		let status;
> +		if (value === undefined) {
> +		    iconCls = 'fa-spinner fa-spin';
> +		    status = gettext('Loading...');
> +		} else {
> +		    let state = value ? 'good' : 'critical';
> +		    iconCls = PVE.Utils.get_health_icon(state, true);
> +		    status = value ? gettext("OK") : record.data.errmsg || Proxmox.Utils.unknownText;
> +		}
> +		return `<i class="fa ${iconCls}"></i> ${status}`;
> +	    },
> +	},
> +	{
> +	    header: gettext('Comment'),
> +	    dataIndex: 'comment',
> +	    flex: 1,
> +	},
> +    ],
> +
> +    listeners: {
> +	activate: 'load',
> +	itemdblclick: 'edit',
> +    },
> +});


  reply	other threads:[~2022-08-25 15:38 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25  9:24 [pve-devel] [PATCH many v2] add cluster-wide hardware device mapping Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH cluster v2 1/1] add nodes/hardware-map.conf Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH access-control v2 1/1] PVE/AccessControl: add Hardware.* privileges and /hardware/ paths Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH common v2 1/3] SysFSTools: make mdev cleanup independent of pciid Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH common v2 2/3] add PVE/HardwareMap Dominik Csapak
2022-08-25 13:37   ` DERUMIER, Alexandre
2022-08-25  9:24 ` [pve-devel] [PATCH common v2 3/3] HardwareMap: add support for multiple pci device paths per mapping Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 01/13] cleanup pci devices in more situations Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 02/13] PCI: make mediated device path independent of pci id Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 03/13] PCI: refactor print_pci_device Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 04/13] PCI: reuse parsed info from print_hostpci_devices Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 05/13] PVE/QemuServer: allow mapped usb devices in config Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 06/13] PVE/QemuServer: allow mapped pci deviced " Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 07/13] PVE/API2/Qemu: add permission checks for mapped usb devices Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 08/13] PVE/API2/Qemu: add permission checks for mapped pci devices Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 09/13] PVE/QemuServer: extend 'check_local_resources' for mapped resources Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 10/13] PVE/API2/Qemu: migrate preconditions: use new check_local_resources info Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 11/13] PVE/QemuMigrate: check for mapped resources on migration Dominik Csapak
2022-08-25 18:00   ` DERUMIER, Alexandre
2022-08-26  6:33     ` Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 12/13] fix #3574: enable multi pci device mapping from config Dominik Csapak
2022-08-25 14:21   ` DERUMIER, Alexandre
2022-08-25 14:53     ` DERUMIER, Alexandre
2022-08-26  6:39       ` Dominik Csapak
2022-08-27 16:09         ` DERUMIER, Alexandre
2022-09-02  9:02           ` Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH qemu-server v2 13/13] add tests for mapped pci devices Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 01/13] PVE/API2/Hardware: add Mapping.pm Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 02/13] PVE/API2/Cluster: add Hardware mapping list api call Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 03/13] ui: form/USBSelector: make it more flexible with nodename Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 04/13] ui: form: add PCIMapSelector Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 05/13] ui: form: add USBMapSelector Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 06/13] ui: qemu/PCIEdit: rework panel to add a mapped configuration Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 07/13] ui: qemu/USBEdit: add 'mapped' device case Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 08/13] ui: form: add MultiPCISelector Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 09/13] ui: add window/PCIEdit: edit window for pci mappings Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 10/13] ui: add window/USBEdit: edit window for usb mappings Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 11/13] ui: add dc/HardwareView: a CRUD interface for hardware mapping Dominik Csapak
2022-08-25 15:37   ` DERUMIER, Alexandre [this message]
2022-08-26  6:48     ` Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 12/13] ui: window/Migrate: allow mapped devices Dominik Csapak
2022-08-25  9:24 ` [pve-devel] [PATCH manager v2 13/13] ui: improve permission handling for hardware Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=38ddcb04-c9e8-4804-7ea2-c330e3357258@groupe-cyllene.com \
    --to=alexandre.derumier@groupe-cyllene.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal