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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4976391908 for ; Fri, 7 Oct 2022 16:30:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2E15A2704B for ; Fri, 7 Oct 2022 16:29:49 +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 ; Fri, 7 Oct 2022 16:29:46 +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 B8E294482D for ; Fri, 7 Oct 2022 16:29:46 +0200 (CEST) From: Markus Frank To: pve-devel@lists.proxmox.com Date: Fri, 7 Oct 2022 16:29:21 +0200 Message-Id: <20221007142922.165009-2-m.frank@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221007142922.165009-1-m.frank@proxmox.com> References: <20221007142922.165009-1-m.frank@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.055 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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: [pve-devel] [PATCH pve-manager] added options to add virtio-9p & virtio-fs fileshare to the config 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: Fri, 07 Oct 2022 14:30:19 -0000 Signed-off-by: Markus Frank --- www/manager6/Makefile | 1 + www/manager6/Utils.js | 12 ++- www/manager6/qemu/HardwareView.js | 18 +++++ www/manager6/qemu/SharedfilesEdit.js | 106 +++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 www/manager6/qemu/SharedfilesEdit.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index d16770b1..dd907d36 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -209,6 +209,7 @@ JSSRC= \ qemu/Config.js \ qemu/CreateWizard.js \ qemu/DisplayEdit.js \ + qemu/SharedfilesEdit.js \ qemu/HDEdit.js \ qemu/HDEfi.js \ qemu/HDTPM.js \ diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index 7ca6a271..e3fb40e5 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -1569,7 +1569,17 @@ Ext.define('PVE.Utils', { } }, - hardware_counts: { net: 32, usb: 5, hostpci: 16, audio: 1, efidisk: 1, serial: 4, rng: 1, tpmstate: 1 }, + hardware_counts: { + net: 32, + usb: 5, + hostpci: 16, + audio: 1, + efidisk: 1, + serial: 4, + rng: 1, + tpmstate: 1, + sharedfiles: 10, + }, cleanEmptyObjectKeys: function(obj) { for (const propName of Object.keys(obj)) { diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js index 6e9d03b4..530934ce 100644 --- a/www/manager6/qemu/HardwareView.js +++ b/www/manager6/qemu/HardwareView.js @@ -233,6 +233,16 @@ Ext.define('PVE.qemu.HardwareView', { header: gettext('Network Device') + ' (' + confid +')', }; } + for (let i = 0; i < PVE.Utils.hardware_counts.sharedfiles; i++) { + let confid = "sharedfiles" + i.toString(); + rows[confid] = { + group: 18, + order: i, + iconCls: 'hdd-o', + editor: 'PVE.qemu.SharedfilesEdit', + header: gettext('Shared FS') + ' (' + confid +')', + }; + } rows.efidisk0 = { group: 20, iconCls: 'hdd-o', @@ -578,6 +588,7 @@ Ext.define('PVE.qemu.HardwareView', { me.down('#addRng').setDisabled(noSysConsolePerm || isAtLimit('rng')); efidisk_menuitem.setDisabled(noVMConfigDiskPerm || isAtLimit('efidisk')); me.down('#addTpmState').setDisabled(noSysConsolePerm || isAtLimit('tpmstate')); + me.down('#addFileshare').setDisabled(noSysConsolePerm || isAtLimit('sharedfiles')); me.down('#addCloudinitDrive').setDisabled(noSysConsolePerm || hasCloudInit); if (!rec) { @@ -718,6 +729,13 @@ Ext.define('PVE.qemu.HardwareView', { disabled: !caps.nodes['Sys.Console'], handler: editorFactory('RNGEdit'), }, + { + text: gettext("Shared Filesystem"), + itemId: 'addFileshare', + iconCls: 'fa fa-fw fa-hdd-o black', + disabled: !caps.nodes['Sys.Console'], + handler: editorFactory('SharedfilesEdit'), + }, ], }), }, diff --git a/www/manager6/qemu/SharedfilesEdit.js b/www/manager6/qemu/SharedfilesEdit.js new file mode 100644 index 00000000..7baf90d3 --- /dev/null +++ b/www/manager6/qemu/SharedfilesEdit.js @@ -0,0 +1,106 @@ +Ext.define('PVE.qemu.SharedfilesInputPanel', { + extend: 'Proxmox.panel.InputPanel', + xtype: 'pveSharedfilesInputPanel', + onlineHelp: 'qm_sharedfiles', + + insideWizard: false, + + onGetValues: function(values) { + var me = this; + var confid = me.confid; + var params = {}; + params[confid] = PVE.Parser.printPropertyString(values, 'type'); + console.log(params); + return params; + }, + + setSharedfiles: function(confid, data) { + var me = this; + me.confid = confid; + me.sharedfiles = data; + me.setValues(me.sharedfiles); + }, + items: [ + { + name: 'type', + xtype: 'proxmoxKVComboBox', + fieldLabel: gettext('Shared FS Type'), + comboItems: [['virtio-9p', 'virtio-9p'], ['virtio-fs', 'virtio-fs']], + allowBlank: false, + }, + { + xtype: 'proxmoxtextfield', + emptyText: '/path/to/shared/dir', + fieldLabel: gettext('shared path'), + name: 'path', + allowBlank: false, + }, + { + xtype: 'proxmoxtextfield', + emptyText: 'tag name', + fieldLabel: gettext('tag'), + name: 'tag', + allowBlank: false, + }, + ], + + initComponent: function() { + var me = this; + + me.sharedfiles = {}; + me.confid = 'sharedfiles0'; + me.callParent(); + }, +}); + +Ext.define('PVE.qemu.SharedfilesEdit', { + extend: 'Proxmox.window.Edit', + + subject: gettext('Filesystem Passthrough'), + + initComponent: function() { + var me = this; + + me.isCreate = !me.confid; + + var ipanel = Ext.create('PVE.qemu.SharedfilesInputPanel', { + confid: me.confid, + isCreate: me.isCreate, + }); + + Ext.applyIf(me, { + subject: gettext('Sharedfiles 1'), + items: ipanel, + }); + + me.callParent(); + + me.load({ + success: function(response) { + me.conf = response.result.data; + var i, confid; + if (!me.isCreate) { + var value = me.conf[me.confid]; + console.log(value); + var sharedfiles = PVE.Parser.parsePropertyString(value, "type"); + console.log(sharedfiles); + if (!sharedfiles) { + Ext.Msg.alert(gettext('Error'), 'Unable to parse network options'); + me.close(); + return; + } + ipanel.setSharedfiles(me.confid, sharedfiles); + } else { + for (i = 0; i < PVE.Utils.hardware_counts.sharedfiles; i++) { + confid = 'sharedfiles' + i.toString(); + if (!Ext.isDefined(me.conf[confid])) { + me.confid = confid; + break; + } + } + ipanel.setSharedfiles(me.confid, {}); + } + }, + }); + }, +}); -- 2.30.2