From: Daniel Henrique Barboza <danielhb(a)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(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.template_edit_main.js | 22 ++++++++++++++++++----
ui/pages/template-edit.html.tmpl | 12 +++++++-----
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/ui/js/src/kimchi.template_edit_main.js
b/ui/js/src/kimchi.template_edit_main.js
index 99e4601..be53701 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -270,8 +270,16 @@ 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
@@ -283,7 +291,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();
@@ -309,6 +320,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);
}
@@ -416,7 +430,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 6cac885..f1a0eee 100644
--- a/ui/pages/template-edit.html.tmpl
+++ b/ui/pages/template-edit.html.tmpl
@@ -149,14 +149,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