
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> This patch removes the limitation, in both backend and frontend, of the value 'threads' in the topology to be limited by the threads_per_core value of the host. This limitation was put in place to help the user pick a 'threads' value that provides a good performance, but it ended up being a problem to support VMs what were created outside of Kimchi and didn't impose such limitations. To compensate, a help text was added to warn the user about the recommended 'threads' values. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- i18n.py | 1 - model/cpuinfo.py | 2 -- ui/js/src/kimchi.template_edit_main.js | 49 +++++++++++++++++----------------- ui/pages/guest-edit.html.tmpl | 6 ++++- ui/pages/i18n.json.tmpl | 1 + ui/pages/template-edit.html.tmpl | 6 ++++- 6 files changed, 36 insertions(+), 29 deletions(-) diff --git a/i18n.py b/i18n.py index 9d0abee..453ede8 100644 --- a/i18n.py +++ b/i18n.py @@ -358,7 +358,6 @@ messages = { "KCHCPUINF0003E": _("This host (or current configuration) does not allow CPU topology."), "KCHCPUINF0004E": _("The maximum number of vCPUs is too large for this system."), "KCHCPUINF0005E": _("When CPU topology is defined, CPUs must be a multiple of the 'threads' number defined."), - "KCHCPUINF0006E": _("The number of threads is too large for this system."), "KCHCPUINF0007E": _("When CPU topology is specified, sockets, cores and threads are required paramaters."), "KCHCPUINF0008E": _("Parameter 'cpu_info' expects an object with fields among: 'vcpus', 'maxvcpus', 'topology'."), "KCHCPUINF0009E": _("Parameter 'topology' expects an object with fields among: 'sockets', 'cores', 'threads'."), diff --git a/model/cpuinfo.py b/model/cpuinfo.py index 5f82320..cfdecaa 100644 --- a/model/cpuinfo.py +++ b/model/cpuinfo.py @@ -134,8 +134,6 @@ class CPUInfoModel(object): if not self.guest_threads_enabled: raise InvalidOperation("KCHCPUINF0003E") - if threads > self.threads_per_core: - raise InvalidParameter("KCHCPUINF0006E") if maxvcpus != sockets * cores * threads: raise InvalidParameter("KCHCPUINF0002E") if vcpus % threads != 0: diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js index f82b615..414a108 100644 --- a/ui/js/src/kimchi.template_edit_main.js +++ b/ui/js/src/kimchi.template_edit_main.js @@ -21,7 +21,9 @@ kimchi.init_processor_tab = function(cpu_info, save_form_button) { var getMaxVCpus = function() { if (!$('#sockets').hasClass("invalid-field") && !$('#cores').hasClass("invalid-field") && - $('#sockets').val() != "" && $('#cores').val() != "") { + !$('#threads').hasClass("invalid-field") && + $('#sockets').val() != "" && $('#cores').val() != "" && + $('#threads').val() != "") { var sockets = parseInt($("#sockets").val()); var cores = parseInt($("#cores").val()); @@ -38,7 +40,6 @@ kimchi.init_processor_tab = function(cpu_info, save_form_button) { var vcpus = parseInt($("#vcpus").val()); if (computedCpu && $("#cpus-check").prop("checked")) { - // If topology is checked, set maxcpu to be the same as # of cpu otherwise, backend gives error var threads = parseInt($("#threads").val()); $("#guest-edit-max-processor-textbox").val(computedCpu); if (vcpus % threads != 0) { @@ -60,23 +61,19 @@ kimchi.init_processor_tab = function(cpu_info, save_form_button) { save_form_button.prop('disabled', invalid_field); if ($(this).prop('id') == 'sockets' || - $(this).prop('id') == 'cores') { + $(this).prop('id') == 'cores' || + $(this).prop('id') == 'threads') { setCPUValue(); } }); $("input:checkbox", "#form-edit-processor").click(function() { - $('#threads').selectpicker(); $(".topology", "#form-edit-processor").slideToggle(); $("#guest-edit-max-processor-textbox").attr("disabled", $(this).prop("checked")); setCPUValue(); }); - $('#threads').change(function() { - setCPUValue(); - }); - $("#guest-edit-max-processor-textbox").change(function() { save_form_button.prop('disabled', false); var vcpus = parseInt($('#vcpus').val()); @@ -108,12 +105,8 @@ kimchi.init_processor_tab = function(cpu_info, save_form_button) { var options = ""; var topo = cpu_info.topology; - for (var i = 0; Math.pow(2, i) <= data.threads_per_core; i++) { - var lastOne = Math.pow(2, i + 1) > data.threads_per_core ? " selected" : ""; - options += "<option" + lastOne + ">" + Math.pow(2, i) + "</option>"; - } - - $('#threads').append(options); + var threads_help_text = i18n['KCHVM0003E'].replace('%1', data.threads_per_core); + $('#threads-recommended-values').text(threads_help_text); if (cpu_info.vcpus) { $("#vcpus").val(cpu_info.vcpus); @@ -121,16 +114,24 @@ kimchi.init_processor_tab = function(cpu_info, save_form_button) { if (cpu_info.maxvcpus) { $("#guest-edit-max-processor-textbox").val(cpu_info.maxvcpus); } - if (topo && topo.sockets) { - $("#sockets").val(topo.sockets); - } - if (topo && topo.cores) { - $("#cores").val(topo.cores); - } - if (topo && topo.threads) { - $('#threads').val(topo.threads); - $('#threads').selectpicker(); - $("input:checkbox", "#form-edit-processor").trigger('click'); + + $("#sockets").val(data.sockets); + $("#cores").val(data.cores); + $('#threads').val(data.threads_per_core); + + if (topo) { + if (topo.sockets) { + $("#sockets").val(topo.sockets); + } + if (topo.cores) { + $("#cores").val(topo.cores); + } + if (topo.threads) { + $('#threads').val(topo.threads); + } + if (topo.sockets && topo.cores && topo.threads) { + $("input:checkbox", "#form-edit-processor").trigger('click'); + } } }); }; diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl index 0aa2504..ce63471 100644 --- a/ui/pages/guest-edit.html.tmpl +++ b/ui/pages/guest-edit.html.tmpl @@ -221,7 +221,11 @@ </div> <div class="form-group"> <label for="threads">$_("Threads")</label> - <select id="threads" class="selectpicker col-md-12 col-lg-12"></select> + <input type="text" class="form-control" value="1" id="threads" /> + <p class="help-block"> + <i class="fa fa-info-circle"></i> + <spam class="text" id="threads-recommended-values" /> + </p> </div> </div> </form> diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl index 0e644ed..cd23fcb 100644 --- a/ui/pages/i18n.json.tmpl +++ b/ui/pages/i18n.json.tmpl @@ -71,6 +71,7 @@ "KCHVM0001E": "$_("Input is not a number")", "KCHVM0002E": "$_("Memory value cannot be higher than Max Memory value")", + "KCHVM0003E": "$_("For better performance it is recommended a threads per core value not greater than %1.")", "KCHVMCD6001M": "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", "KCHVMCD6002M": "$_("Attach")", diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl index 6e7f97b..728ce6d 100644 --- a/ui/pages/template-edit.html.tmpl +++ b/ui/pages/template-edit.html.tmpl @@ -185,7 +185,11 @@ </div> <div class="form-group"> <label for="threads">$_("Threads")</label> - <select id="threads" class="selectpicker col-md-12 col-lg-12"></select> + <input type="text" class="form-control" value="1" id="threads" /> + <p class="help-block"> + <i class="fa fa-info-circle"></i> + <spam class="text" id="threads-recommended-values" /> + </p> </div> </div> </form> -- 2.7.4