
Signed-off-by: Lucio Correia <luciojhc@linux.vnet.ibm.com> --- ui/js/src/kimchi.guest_edit_main.js | 8 ++++++-- ui/js/src/kimchi.template_edit_main.js | 15 +++++++++------ ui/pages/guest-edit.html.tmpl | 2 +- ui/pages/template-edit.html.tmpl | 4 ++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js index 136469b..94b521e 100644 --- a/ui/js/src/kimchi.guest_edit_main.js +++ b/ui/js/src/kimchi.guest_edit_main.js @@ -660,6 +660,7 @@ kimchi.guest_edit_main = function() { }; var initContent = function(guest) { + guest['vcpus'] = guest['cpu_info']['vcpus'] guest['icon'] = guest['icon'] || 'plugins/kimchi/images/icon-vm.png'; $('#form-guest-edit-general').fillWithObject(guest); kimchi.thisVMState = guest['state']; @@ -707,8 +708,11 @@ kimchi.guest_edit_main = function() { if (data['memory'] !== undefined) { data['memory'] = Number(data['memory']); } - if (data['cpus'] !== undefined) { - data['cpus'] = Number(data['cpus']); + if (data['vcpus'] !== undefined) { + data['cpu_info'] = { + vcpus: Number(data['vcpus']) + }; + delete data['vcpus']; } kimchi.updateVM(kimchi.selectedGuest, data, function() { diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js index f120e91..53f74ba 100644 --- a/ui/js/src/kimchi.template_edit_main.js +++ b/ui/js/src/kimchi.template_edit_main.js @@ -241,9 +241,9 @@ kimchi.template_edit_main = function() { var initProcessor = function(){ var setCPUValue = function(){ if(!$('#cores').hasClass("invalid-field")&&$('#cores').val()!=""){ - $("#cpus").val(parseInt($("#cores").val())*parseInt($("#threads").val())); + $("#vcpus").val(parseInt($("#cores").val())*parseInt($("#threads").val())); }else{ - $("#cpus").val(''); + $("#vcpus").val(''); } }; $("input:text", "#form-template-processor").on('keyup', function(){ @@ -252,7 +252,7 @@ kimchi.template_edit_main = function() { }); $("input:checkbox", "#form-template-processor").click(function(){ $(".topology", "#form-template-processor").toggleClass("hide", !$(this).prop("checked")); - $("#cpus").attr("disabled", $(this).prop("checked")); + $("#vcpus").attr("disabled", $(this).prop("checked")); setCPUValue(); }); $('select', '#form-template-processor').change(function(){ @@ -266,7 +266,7 @@ kimchi.template_edit_main = function() { } $('select', '#form-template-processor').append(options); $('select', '#form-template-processor').selectpicker(); - if(template.cpus) $("#cpus").val(template.cpus); + if(template.cpu_info.vcpus) $("#vcpus").val(template.cpu_info.vcpus); var topo = template.cpu_info.topology; if(topo&&topo.cores) $("#cores").val(topo.cores); if(topo&&topo.threads){ @@ -320,9 +320,10 @@ kimchi.template_edit_main = function() { } }); data['memory'] = Number(data['memory']); - data['cpus'] = parseInt($('#cpus').val()); if($("input:checkbox", "#form-template-processor").prop("checked")){ data['cpu_info'] = { + vcpus: parseInt($('#vcpus').val()), + maxvcpus: parseInt($('#vcpus').val()), topology: { sockets: 1, cores: parseInt($("#cores").val()), @@ -330,7 +331,9 @@ kimchi.template_edit_main = function() { } }; }else{ - data['cpu_info'] = {}; + data['cpu_info'] = { + vcpus: parseInt($('#vcpus').val()) + }; } var networks = $('.template-tab-body .item', '#form-template-interface'); var networkForUpdate = new Array(); diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl index 0ad635c..32576e9 100644 --- a/ui/pages/guest-edit.html.tmpl +++ b/ui/pages/guest-edit.html.tmpl @@ -46,7 +46,7 @@ </div> <div class="form-group"> <label for="guest-edit-cores-textbox">$_("CPUs")</label> - <input id="guest-edit-cores-textbox" class="form-control" name="cpus" type="text" /> + <input id="guest-edit-cores-textbox" class="form-control" name="vcpus" type="text" /> </div> <div class="form-group"> <label for="guest-edit-memory-textbox">$_("Memory (MB)")</label> diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl index 478ccd5..36d0751 100644 --- a/ui/pages/template-edit.html.tmpl +++ b/ui/pages/template-edit.html.tmpl @@ -123,8 +123,8 @@ <form id="form-template-processor"> <div class="form-inline"> <div class="form-group"> - <label for="cpus">$_("CPU Number"):</label> - <input type="text" class="form-control" value="1" id="cpus" /> + <label for="vcpus">$_("CPU Number"):</label> + <input type="text" class="form-control" value="1" id="vcpus" /> </div> </div> <div class="manual form-group"> -- 1.9.1