[pve-devel] [PATCH] add cpu hotplug form

Alexandre Derumier aderumier at odiso.com
Thu Feb 12 10:27:45 CET 2015


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 www/manager/Makefile             |    1 +
 www/manager/qemu/HardwareView.js |   61 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/www/manager/Makefile b/www/manager/Makefile
index 6876c74..44977a9 100644
--- a/www/manager/Makefile
+++ b/www/manager/Makefile
@@ -128,6 +128,7 @@ JSSRC= 				                 	\
 	qemu/HDResize.js				\
 	qemu/HDMove.js					\
 	qemu/HDThrottle.js				\
+	qemu/CPUHotplug.js				\
 	qemu/DisplayEdit.js				\
 	qemu/KeyboardEdit.js				\
 	qemu/HardwareView.js				\
diff --git a/www/manager/qemu/HardwareView.js b/www/manager/qemu/HardwareView.js
index ba986c4..d704391 100644
--- a/www/manager/qemu/HardwareView.js
+++ b/www/manager/qemu/HardwareView.js
@@ -63,15 +63,20 @@ Ext.define('PVE.qemu.HardwareView', {
 		    'PVE.qemu.ProcessorEdit' : undefined,
 		tdCls: 'pve-itype-icon-processor',
 		defaultValue: 1,
-		multiKey: ['sockets', 'cpu', 'cores', 'numa'],
+		multiKey: ['sockets', 'cpu', 'cores', 'numa', 'vcpus'],
 		renderer: function(value, metaData, record, rowIndex, colIndex, store, pending) {
 
+		    var vcpus = me.getObjectValue('vcpus', undefined, pending);
 		    var sockets = me.getObjectValue('sockets', 1, pending);
 		    var model = me.getObjectValue('cpu', undefined, pending);
 		    var cores = me.getObjectValue('cores', 1, pending);
 		    var numa = me.getObjectValue('numa', undefined, pending);
 
-		    var res = (sockets*cores) + ' (' + sockets + ' sockets, ' + cores + ' cores)';
+		    if(!vcpus) {
+		      vcpus = sockets*cores;
+		    }
+
+		    var res = vcpus + ' (' + sockets + ' sockets, ' + cores + ' cores)';
 		    
 		    if (model) {
 			res += ' [' + model + ']';
@@ -114,6 +119,9 @@ Ext.define('PVE.qemu.HardwareView', {
 	    },
 	    hotplug: {
 		visible: false
+	    },
+	    vcpus: {
+		visible: false
 	    }
 	};
 
@@ -260,6 +268,31 @@ Ext.define('PVE.qemu.HardwareView', {
 	    win.on('destroy', reload);
 	};
 
+	var run_cpuhotplug = function() {
+	    var rec = sm.getSelection()[0];
+	    if (!rec) {
+		return;
+	    }
+
+            var sockets = me.getObjectValue('sockets', 1);
+            var cores = me.getObjectValue('cores', 1);
+            var vcpus = me.getObjectValue('vcpus', 1);
+	    
+
+	    var win = Ext.create('PVE.qemu.CPUHotplug', {
+		maxvcpus: sockets * cores,
+		vcpus: vcpus,
+		vmid: vmid,
+		pveSelNode: me.pveSelNode,
+		confid: rec.data.key,
+		url: '/api2/extjs/' + baseurl
+	    });
+
+	    win.show();
+
+	    win.on('destroy', reload);
+	};
+
 	var run_move = function() {
 	    var rec = sm.getSelection()[0];
 	    if (!rec) {
@@ -305,6 +338,13 @@ Ext.define('PVE.qemu.HardwareView', {
 	    handler: run_diskthrottle
 	});
 
+	var cpuhotplug_btn = new PVE.button.Button({
+	    text: gettext('CPU Hotplug'),
+	    selModel: sm,
+	    disabled: true,
+	    handler: run_cpuhotplug
+	});
+
 	var remove_btn = new PVE.button.Button({
 	    text: gettext('Remove'),
 	    selModel: sm,
@@ -372,6 +412,7 @@ Ext.define('PVE.qemu.HardwareView', {
 		resize_btn.disable();
 		move_btn.disable();
 		diskthrottle_btn.disable();
+		cpuhotplug_btn.disable();
 		revert_btn.disable();
 		return;
 	    }
@@ -383,6 +424,15 @@ Ext.define('PVE.qemu.HardwareView', {
 	    var isDisk = !key.match(/^unused\d+/) && 
 		(rowdef.tdCls == 'pve-itype-icon-storage' && !value.match(/media=cdrom/));
 
+	    var hotplug  = me.getObjectValue('hotplug');
+	    var cpuhotplug;
+            if(hotplug) {
+                Ext.each(hotplug.split(','), function(el) {
+                    if (el === 'cpu') {
+                        cpuhotplug = 1;
+                    }
+            });
+
 	    remove_btn.setDisabled(rec.data['delete'] || (rowdef.never_delete === true));
 
 	    edit_btn.setDisabled(rec.data['delete'] || !rowdef.editor);
@@ -393,7 +443,13 @@ Ext.define('PVE.qemu.HardwareView', {
 
 	    diskthrottle_btn.setDisabled(pending || !isDisk);
 
+	    cpuhotplug_btn.setDisabled(!cpuhotplug || rowdef.tdCls != 'pve-itype-icon-processor');
+
 	    revert_btn.setDisabled(!pending);
+
+        }
+
+
 	};
 
 	Ext.applyIf(me, {
@@ -453,6 +509,7 @@ Ext.define('PVE.qemu.HardwareView', {
 		resize_btn,
 		move_btn,
 		diskthrottle_btn,
+		cpuhotplug_btn,
 		revert_btn
 	    ],
 	    rows: rows,
-- 
1.7.10.4




More information about the pve-devel mailing list