[pve-devel] [PATCH qemu-server v2 5/6] added options to add virtio-9p & virtio-fs Shared Filesystems to qemu config
Markus Frank
m.frank at proxmox.com
Fri Dec 23 14:10:06 CET 2022
Signed-off-by: Markus Frank <m.frank at proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/Utils.js | 1 +
www/manager6/qemu/HardwareView.js | 19 +++++
www/manager6/qemu/SharedfilesEdit.js | 101 +++++++++++++++++++++++++++
4 files changed, 122 insertions(+)
create mode 100644 www/manager6/qemu/SharedfilesEdit.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 7146fab1..cb035734 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -237,6 +237,7 @@ JSSRC= \
qemu/QemuBiosEdit.js \
qemu/RNGEdit.js \
qemu/SSHKey.js \
+ qemu/SharedfilesEdit.js \
qemu/ScsiHwEdit.js \
qemu/SerialEdit.js \
qemu/Smbios1Edit.js \
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 8c118fa2..5ac830a3 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1579,6 +1579,7 @@ Ext.define('PVE.Utils', {
serial: 4,
rng: 1,
tpmstate: 1,
+ sharedfiles: 10,
},
// we can have usb6 and up only for specific machine/ostypes
diff --git a/www/manager6/qemu/HardwareView.js b/www/manager6/qemu/HardwareView.js
index af35a980..10091aee 100644
--- a/www/manager6/qemu/HardwareView.js
+++ b/www/manager6/qemu/HardwareView.js
@@ -309,6 +309,16 @@ Ext.define('PVE.qemu.HardwareView', {
never_delete: !caps.nodes['Sys.Console'],
header: gettext("VirtIO RNG"),
};
+ for (let i = 0; i < PVE.Utils.hardware_counts.sharedfiles; i++) {
+ let confid = "sharedfiles" + i.toString();
+ rows[confid] = {
+ group: 50,
+ order: i,
+ iconCls: 'folder',
+ editor: 'PVE.qemu.SharedfilesEdit',
+ header: gettext('Shared FS') + ' (' + confid +')',
+ };
+ }
var sorterFn = function(rec1, rec2) {
var v1 = rec1.data.key;
@@ -582,6 +592,7 @@ Ext.define('PVE.qemu.HardwareView', {
const noVMConfigDiskPerm = !caps.vms['VM.Config.Disk'];
const noVMConfigCDROMPerm = !caps.vms['VM.Config.CDROM'];
const noVMConfigCloudinitPerm = !caps.vms['VM.Config.Cloudinit'];
+ const noVMConfigOptionsPerm = !caps.vms['VM.Config.Options'];
me.down('#addUsb').setDisabled(noSysConsolePerm || isAtUsbLimit());
me.down('#addPci').setDisabled(noSysConsolePerm || isAtLimit('hostpci'));
@@ -591,6 +602,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(noVMConfigOptionsPerm || isAtLimit('sharedfiles'));
me.down('#addCloudinitDrive').setDisabled(noVMConfigCDROMPerm || noVMConfigCloudinitPerm || hasCloudInit);
if (!rec) {
@@ -735,6 +747,13 @@ Ext.define('PVE.qemu.HardwareView', {
disabled: !caps.nodes['Sys.Console'],
handler: editorFactory('RNGEdit'),
},
+ {
+ text: gettext("Shared Filesystem"),
+ itemId: 'addFileshare',
+ iconCls: 'fa fa-folder',
+ 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..8ebcef6c
--- /dev/null
+++ b/www/manager6/qemu/SharedfilesEdit.js
@@ -0,0 +1,101 @@
+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');
+ 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: 'dirid',
+ fieldLabel: gettext('Directory ID'),
+ name: 'dirid',
+ 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, {
+ 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];
+ var sharedfiles = PVE.Parser.parsePropertyString(value, "type");
+ if (!sharedfiles) {
+ Ext.Msg.alert(gettext('Error'), 'Unable to parse sharedfiles 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