]> git.proxmox.com Git - pve-manager.git/commitdiff
gui: cpu: fix processor editing
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 1 Feb 2016 09:21:34 +0000 (10:21 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 1 Feb 2016 16:10:49 +0000 (17:10 +0100)
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
www/manager/qemu/ProcessorEdit.js

index 5a5e47f91aeeceff56eda3313ab6b6e425fe4792..f6f5cf05234e2532c87845c6e06ec68da644f4a4 100644 (file)
@@ -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;
+    },
 }});
index bec77d9eb26cb0974503b3136179632800ac3355..ee8f528efefcad8f41beeee65d8fd4058eacb055 100644 (file)
@@ -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 });
            }
        });
     }