[pve-devel] [PATCH manager] gui: cpu: fix processor editing

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Feb 1 10:21:34 CET 2016


The last processor editing commit broke various parts of the
cpu editor window.
Most noticeably switching between the default and non-default
cpu types dealt with empty values wrongly and tried to
delete the 'cputype' property rather than the cputype
portion of the cpu property string.
---
 www/manager/Parser.js             | 14 ++++++++++----
 www/manager/qemu/ProcessorEdit.js | 34 ++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/www/manager/Parser.js b/www/manager/Parser.js
index 5a5e47f..f6f5cf0 100644
--- a/www/manager/Parser.js
+++ b/www/manager/Parser.js
@@ -352,7 +352,7 @@ Ext.define('PVE.Parser', { statics: {
 
     parseQemuCpu: function(value) {
 	if (!value) {
-	    return;
+	    return {};
 	}
 
 	var res = {};
@@ -396,15 +396,21 @@ Ext.define('PVE.Parser', { statics: {
 
     printQemuCpu: function(cpu) {
 	var cpustr = cpu.cputype;
+	var optstr = '';
 
 	Ext.Object.each(cpu, function(key, value) {
 	    if (!Ext.isDefined(value) || key === 'cputype') {
 		return; // continue
 	    }
-	    cpustr += ',' + key + '=' + value;
+	    optstr += ',' + key + '=' + value;
 	});
 
-	return cpustr;
-    },
+	if (!cpustr) {
+	    if (optstr)
+		return 'kvm64' + optstr;
+	    return;
+	}
 
+	return cpustr + optstr;
+    },
 }});
diff --git a/www/manager/qemu/ProcessorEdit.js b/www/manager/qemu/ProcessorEdit.js
index bec77d9..ee8f528 100644
--- a/www/manager/qemu/ProcessorEdit.js
+++ b/www/manager/qemu/ProcessorEdit.js
@@ -4,10 +4,35 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
 
     onGetValues: function(values) {
 	var me = this;
+
+	// build the cpu options:
 	me.cpu.cputype = values['cputype'];
-	return {
-	    cpu: PVE.Parser.printQemuCpu(me.cpu)
-	};
+	delete values['cputype'];
+	var cpustring = PVE.Parser.printQemuCpu(me.cpu);
+
+	// remove cputype delete request:
+	var del = values['delete'];
+	delete values['delete'];
+	if (del) {
+	    del = del.split(',');
+	    Ext.Array.remove(del, 'cputype');
+	} else {
+	    del = [];
+	}
+	console.log(del);
+
+	if (cpustring) {
+	    values['cpu'] = cpustring;
+	} else {
+	    del.push('cpu');
+	}
+
+	del = del.join(',');
+	if (del) {
+	    values['delete'] = del;
+	}
+
+	return values;
     },
 
     initComponent : function() {
@@ -96,7 +121,8 @@ Ext.define('PVE.qemu.ProcessorEdit', {
 		var value = response.result.data['cpu'];
 		var cpu = PVE.Parser.parseQemuCpu(value);
 		ipanel.cpu = cpu;
-		me.setValues({ cputype: cpu.cputype });
+		if (value)
+		    me.setValues({ cputype: cpu.cputype });
 	    }
 	});
     }
-- 
2.1.4





More information about the pve-devel mailing list