[pve-devel] [PATCH pve-manager] added options to add virtio-9p & virtio-fs fileshare to the config
Markus Frank
m.frank at proxmox.com
Fri Oct 7 16:29:21 CEST 2022
Signed-off-by: Markus Frank <m.frank at proxmox.com>
---
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
More information about the pve-devel
mailing list