[pve-devel] [PATCH v2 pve-manager 2/2] ui: qemu : memoryedit: add new max && virtio fields

Alexandre Derumier aderumier at odiso.com
Mon Jun 19 09:28:33 CEST 2023


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager6/qemu/MemoryEdit.js | 52 +++++++++++++++++++++++++++------
 1 file changed, 43 insertions(+), 9 deletions(-)

diff --git a/www/manager6/qemu/MemoryEdit.js b/www/manager6/qemu/MemoryEdit.js
index 5e91dc9b..be7903a2 100644
--- a/www/manager6/qemu/MemoryEdit.js
+++ b/www/manager6/qemu/MemoryEdit.js
@@ -20,12 +20,12 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 	    let me = this;
 	    let view = me.getView(), viewModel = me.getViewModel();
 	    if (view.insideWizard) {
-		let memory = view.down('pveMemoryField[name=memory]');
+		let current = view.down('pveMemoryField[name=current]');
 		// NOTE: we only set memory but that then sets balloon in its change handler
 		if (viewModel.get('current.ostype') === 'win11') {
-		    memory.setValue('4096');
+		    current.setValue('4096');
 		} else {
-		    memory.setValue('2048');
+		    current.setValue('2048');
 		}
 	    }
 	},
@@ -36,13 +36,23 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 
 	var res = {};
 
-	res.memory = values.memory;
+	let memory = {};
+	memory.current = values.current;
+	if (values.max && values.max !== 0) {
+	    memory.max = values.max;
+	}
+	if (values.virtio) {
+	    memory.virtio = values.virtio;
+	}
+
+	res.memory = PVE.Parser.printPropertyString(memory, 'current');
+
 	res.balloon = values.balloon;
 
 	if (!values.ballooning) {
 	    res.balloon = 0;
 	    res.delete = 'shares';
-	} else if (values.memory === values.balloon) {
+	} else if (values.current === values.balloon) {
 	    delete res.balloon;
 	    res.delete = 'balloon,shares';
 	} else if (Ext.isDefined(values.shares) && values.shares !== "") {
@@ -63,7 +73,7 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 		xtype: 'pveMemoryField',
 		labelWidth: labelWidth,
 		fieldLabel: gettext('Memory') + ' (MiB)',
-		name: 'memory',
+		name: 'current',
 		value: '512', // better defaults get set via the view controllers afterrender
 		minValue: 1,
 		step: 32,
@@ -96,12 +106,25 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 		allowBlank: false,
 		listeners: {
 		    change: function(f, value) {
-			var memory = me.down('field[name=memory]').getValue();
+			var memory = me.down('field[name=current]').getValue();
 			var shares = me.down('field[name=shares]');
 			shares.setDisabled(value === memory);
 		    },
 		},
 	    },
+	    {
+		xtype: 'pveMemoryField',
+		name: 'max',
+		minValue: 65536,
+		maxValue: 4194304,
+		value: '',
+		step: 65536,
+		fieldLabel: gettext('Maximum memory') + ' (MiB)',
+		labelWidth: labelWidth,
+		allowBlank: true,
+		emptyText: gettext('Disabled'),
+		submitEmptyText: false,
+	    },
 	    {
 		xtype: 'proxmoxintegerfield',
 		name: 'shares',
@@ -132,6 +155,13 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 		    },
 		},
 	    },
+	    {
+		xtype: 'proxmoxcheckbox',
+		labelWidth: labelWidth,
+		name: 'virtio',
+		defaultValue: 0,
+		fieldLabel: gettext('Virtiomem'),
+	    },
 	];
 
 	if (me.insideWizard) {
@@ -178,11 +208,15 @@ Ext.define('PVE.qemu.MemoryEdit', {
 	    success: function(response, options) {
 		var data = response.result.data;
 
+		let memory = PVE.Parser.parsePropertyString(data.memory, 'current');
+
 		var values = {
 		    ballooning: data.balloon === 0 ? '0' : '1',
 		    shares: data.shares,
-		    memory: data.memory || '512',
-		    balloon: data.balloon > 0 ? data.balloon : data.memory || '512',
+		    current: memory.current || '512',
+		    max: memory.max || '',
+		    virtio: memory.virtio,
+		    balloon: data.balloon > 0 ? data.balloon : memory.current || '512',
 		};
 
 		ipanel.setValues(values);
-- 
2.39.2





More information about the pve-devel mailing list