[Kimchi-devel] [PATCH] [Kimchi 2/6] Adding 'sockets' field in the topology of Templates

dhbarboza82 at gmail.com dhbarboza82 at gmail.com
Wed Nov 23 12:11:16 UTC 2016


From: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>

Following the changes of bug fix #1072, this patch adds the
'sockets' values to be editable in the CPU topology. Since
sockets is now a component of the calculation of Max CPUs of
a VM, it makes sense to allow user control of it.

As with cores and threads, the defautl value of sockets is
returned by the cpu_info API.

Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.template_edit_main.js | 21 +++++++++++++++++----
 ui/pages/template-edit.html.tmpl       | 12 +++++++-----
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 9b9828d..457246e 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -641,8 +641,15 @@ kimchi.template_edit_main = function() {
 
         var initProcessor = function(){
             var setCPUValue = function(){
-                if(!$('#cores').hasClass("invalid-field")&&$('#cores').val()!=""){
-                    var computedCpu = parseInt($("#cores").val())*parseInt($("#threads").val());
+                if(!$('#sockets').hasClass("invalid-field") &&
+                   !$('#cores').hasClass("invalid-field") &&
+                   $('#sockets').val()!="" && $('#cores').val()!=""){
+
+                    var sockets = parseInt($("#sockets").val());
+                    var cores = parseInt($("#cores").val());
+                    var threads = parseInt($("#threads").val());
+
+                    var computedCpu = sockets * cores * threads;
                     $("#vcpus").val(computedCpu);
                     if ($("#cpus-check").prop("checked")) {
                         //If topology is checked, set maxcpu to be the same as # of cpu otherwise, backend gives error
@@ -654,7 +661,10 @@ kimchi.template_edit_main = function() {
             };
             $("input:text", "#form-template-processor").on('keyup', function() {
                 $(this).toggleClass("invalid-field", !$(this).val().match('^[0-9]*$'));
-                if ($(this).prop('id') == 'cores') setCPUValue();
+                if ($(this).prop('id') == 'sockets' ||
+                    $(this).prop('id') == 'cores') {
+                        setCPUValue();
+                }
             });
             $("input:checkbox", "#form-template-processor").click(function() {
                 $('#threads').selectpicker();
@@ -680,6 +690,9 @@ kimchi.template_edit_main = function() {
                 if (template.cpu_info.maxvcpus) {
                     $("#guest-edit-max-processor-textbox").val(template.cpu_info.maxvcpus);
                 }
+                if (topo && topo.sockets) {
+                    $("#sockets").val(topo.sockets);
+                }
                 if (topo && topo.cores) {
                     $("#cores").val(topo.cores);
                 }
@@ -815,7 +828,7 @@ kimchi.template_edit_main = function() {
                 vcpus: cpu,
                 maxvcpus: maxCpuFinal,
                 topology: {
-                    sockets: 1,
+                    sockets: parseInt($("#sockets").val()),
                     cores: parseInt($("#cores").val()),
                     threads: parseInt($("#threads").val())
                 }
diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
index e9a479e..0ba4c4b 100644
--- a/ui/pages/template-edit.html.tmpl
+++ b/ui/pages/template-edit.html.tmpl
@@ -169,14 +169,16 @@
                         </div>
                         <div class="topology">
                             <div class="form-group">
+                                <label for="sockets">$_("Sockets")</label>
+                                <input type="text" class="form-control" value="1" id="sockets" />
+                            </div>
+                            <div class="form-group">
                                 <label for="cores">$_("Cores")</label>
                                 <input type="text" class="form-control" value="1" id="cores" />
                             </div>
-                            <div>
-                                <div class="form-group">
-                                    <label for="threads">$_("Threads")</label>
-                                    <select id="threads" class="selectpicker col-md-12 col-lg-12"></select>
-                                </div>
+                            <div class="form-group">
+                                <label for="threads">$_("Threads")</label>
+                                <select id="threads" class="selectpicker col-md-12 col-lg-12"></select>
                             </div>
                         </div>
                     </form>
-- 
2.7.4




More information about the Kimchi-devel mailing list