[pve-devel] [PATCH pve-manager 1/1] Close #2443: gui: qemu/NetworkEdit: add network mtu advanced option

Paul Shepel tacid at tacid.kiev.ua
Wed Dec 11 18:03:14 CET 2019


Signed-off-by: Paul Shepel <tacid at tacid.kiev.ua>
---
 www/manager6/Parser.js           |  5 +++++
 www/manager6/qemu/NetworkEdit.js | 36 +++++++++++++++++++++++++++++---
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/www/manager6/Parser.js b/www/manager6/Parser.js
index 0790e683..6a9cbb78 100644
--- a/www/manager6/Parser.js
+++ b/www/manager6/Parser.js
@@ -131,6 +131,8 @@ Ext.define('PVE.Parser', { statics: {
 		res.disconnect = match_res[1];
 	    } else if ((match_res = p.match(/^queues=(\d+)$/)) !== null) {
 		res.queues = match_res[1];
+	    } else if ((match_res = p.match(/^mtu=(\d+)$/)) !== null) {
+		res.mtu = match_res[1];
 	    } else if ((match_res = p.match(/^trunks=(\d+(?:-\d+)?(?:;\d+(?:-\d+)?)*)$/)) !== null) {
 		res.trunks = match_res[1];
 	    } else {
@@ -167,6 +169,9 @@ Ext.define('PVE.Parser', { statics: {
 	if (net.queues) {
 	    netstr += ",queues=" + net.queues;
 	}
+	if (net.mtu) {
+	    netstr += ",mtu=" + net.mtu;
+	}
 	if (net.disconnect) {
 	    netstr += ",link_down=" + net.disconnect;
 	}
diff --git a/www/manager6/qemu/NetworkEdit.js b/www/manager6/qemu/NetworkEdit.js
index abce4903..c66da59c 100644
--- a/www/manager6/qemu/NetworkEdit.js
+++ b/www/manager6/qemu/NetworkEdit.js
@@ -26,6 +26,12 @@ Ext.define('PVE.qemu.NetworkInputPanel', {
 	    delete me.network.rate;
 	}
 
+	if (values.mtu) {
+	    me.network.mtu = values.mtu;
+	} else {
+	    delete me.network.mtu;
+	}
+
 	var params = {};
 
 	params[me.confid] = PVE.Parser.printQemuNetwork(me.network);
@@ -92,7 +98,19 @@ Ext.define('PVE.qemu.NetworkInputPanel', {
 		xtype: 'proxmoxcheckbox',
 		fieldLabel: gettext('Disconnect'),
 		name: 'disconnect'
-	    }
+	    },
+	    {
+		xtype: 'numberfield',
+		fieldLabel: gettext('MTU'),
+		minValue: 576,
+		maxValue: 65535,
+		value: '',
+		emptyText: '1500',
+		name: 'mtu',
+		disabled: true,
+		hidden: true,
+		allowBlank: true
+            }
 	];
 
 	if (me.insideWizard) {
@@ -111,7 +129,8 @@ Ext.define('PVE.qemu.NetworkInputPanel', {
 			    'model',
 			    'macaddr',
 			    'rate',
-			    'queues'
+			    'queues',
+			    'mtu',
 			];
 			fields.forEach(function(fieldname) {
 			    me.down('field[name='+fieldname+']').setDisabled(value);
@@ -150,7 +169,18 @@ Ext.define('PVE.qemu.NetworkInputPanel', {
 		maxValue: 10*1024,
 		value: '',
 		emptyText: 'unlimited',
-		allowBlank: true
+		allowBlank: true,
+		listeners: {
+                    change: function(f, value) {
+                        if (!me.rendered) {
+                            return;
+                        }
+                        var mtuField = me.down('field[name=mtu]');
+                        var isVirtioNet = ( value == 'virtio' );
+                        mtuField.setDisabled(!isVirtioNet);
+                        mtuField.setHidden(!isVirtioNet);
+                    }
+                }
 	    },
 	    {
 		xtype: 'proxmoxintegerfield',
-- 
2.17.1



More information about the pve-devel mailing list