[pve-devel] [PATCH] expose balloon to gui.

Alexandre Derumier aderumier at odiso.com
Wed Dec 5 09:38:43 CET 2012


- balloon size cannot be bigger than memory size
- if we reduce the memory size lower than balloon size, we set balloon size equal to memory size

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/qemu/HardwareView.js |   11 ++++++++++-
 www/manager/qemu/MemoryEdit.js   |   32 ++++++++++++++++++++++++++++----
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/www/manager/qemu/HardwareView.js b/www/manager/qemu/HardwareView.js
index 7bb4a88..cb9206c 100644
--- a/www/manager/qemu/HardwareView.js
+++ b/www/manager/qemu/HardwareView.js
@@ -45,7 +45,13 @@ Ext.define('PVE.qemu.HardwareView', {
 		defaultValue: 512,
 		tdCls: 'pve-itype-icon-memory',
 		renderer: function(value) {
-		    return PVE.Utils.format_size(value*1024*1024);
+		    var res = '';
+		    var balloon = me.getObjectValue('balloon');
+		    res = PVE.Utils.format_size(value*1024*1024);
+		    if (balloon){
+			res += ' (Balloon: ' + PVE.Utils.format_size(balloon*1024*1024) + ')';
+		    }
+		    return res;		
 		}
 	    },
 	    sockets: {
@@ -91,6 +97,9 @@ Ext.define('PVE.qemu.HardwareView', {
 	    },
 	    cpu: {
 		visible: false
+	    },
+	    balloon: {
+		visible: false
 	    }
 	};
 
diff --git a/www/manager/qemu/MemoryEdit.js b/www/manager/qemu/MemoryEdit.js
index 4b88295..1beed24 100644
--- a/www/manager/qemu/MemoryEdit.js
+++ b/www/manager/qemu/MemoryEdit.js
@@ -9,7 +9,7 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 
 	var labelWidth = 120;
 
-	var items = {
+	var items = [{
 	    xtype: 'numberfield',
 	    name: 'memory',
 	    minValue: 32,
@@ -18,8 +18,32 @@ Ext.define('PVE.qemu.MemoryInputPanel', {
 	    step: 32,
 	    fieldLabel: gettext('Memory') + ' (MB)',
 	    labelWidth: labelWidth,
-	    allowBlank: false
-	};
+	    allowBlank: false,
+            listeners: {
+                  change: function(f, value) {
+			me.down('field[name=balloon]').setMaxValue(value);
+
+			var balloon = me.query('textfield[name="balloon"]')[0];
+			if(value < balloon.getValue){
+				me.down('field[name=balloon]').setValue(value);
+			}
+                   }
+            } 
+	},
+	{
+	    xtype: 'numberfield',
+	    name: 'balloon',
+	    minValue: 32,
+	    maxValue: 512,
+	    value: '512',
+	    step: 32,
+	    fieldLabel: 'Balloon Size' + ' (MB)',
+	    labelWidth: labelWidth,
+	    allowBlank: true,
+
+	},
+
+	];
 
 	if (me.insideWizard) {
 	    me.column1 = items;
@@ -46,4 +70,4 @@ Ext.define('PVE.qemu.MemoryEdit', {
 
 	me.load();
     }
-});
\ No newline at end of file
+});
-- 
1.7.10.4




More information about the pve-devel mailing list