From: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
This patch makes the following changes to enable CPU
hotplug/unplug on a running/paused guest:
- if the guest is running, lock all fields but the current CPU
in the Edit Guest dialog. A message is displayed informing
the user that on a running or paused guest the only CPU
setting that can be changed is the current CPU value;
- in the form validation processorSubmit function, discard
every info but the current CPU value if the guest is running
or paused.
Changes in guests.dita were also made to add information about
the guest support for this feature.
Signed-off-by: Daniel Henrique Barboza <danielhb(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_edit_main.js | 44 ++++++++++++++++++++++++-------------
ui/pages/guest-edit.html.tmpl | 5 ++++-
ui/pages/help/en_US/guests.dita | 8 +++++++
3 files changed, 41 insertions(+), 16 deletions(-)
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index f06e0fa..7667fad 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -1032,7 +1032,17 @@ kimchi.guest_edit_main = function() {
setupPermission();
setupPCIDevice();
setupSnapshot();
+
kimchi.init_processor_tab(guest.cpu_info, $(saveButton));
+ if ((kimchi.thisVMState === "running") || (kimchi.thisVMState ===
"paused")) {
+ $('#guest-edit-max-processor-textbox').attr("disabled",
true);
+ $('#sockets').attr("disabled", true);
+ $('#cores').attr("disabled", true);
+ $('#threads').attr("disabled", true);
+
+ $("#topology-checkbox").hide();
+ $("#settings-readonly-help").removeClass('hidden');
+ }
wok.topic('kimchi/vmCDROMAttached').subscribe(onAttached);
wok.topic('kimchi/vmCDROMReplaced').subscribe(onReplaced);
@@ -1176,22 +1186,26 @@ kimchi.guest_edit_main = function() {
if (maxCpu >= cpu) {
maxCpuFinal = maxCpu;
}
- if ($("input:checkbox",
"#form-edit-processor").prop("checked")) {
- data['cpu_info'] = {
- vcpus: cpu,
- maxvcpus: maxCpuFinal,
- topology: {
- sockets: parseInt($("#sockets").val()),
- cores: parseInt($("#cores").val()),
- threads: parseInt($("#threads").val())
- }
- };
+ if (kimchi.thisVMState === 'running' || kimchi.thisVMState ===
'paused') {
+ data['cpu_info'] = {vcpus: cpu};
} else {
- data['cpu_info'] = {
- vcpus: cpu,
- maxvcpus: maxCpuFinal,
- topology: {}
- };
+ if ($("input:checkbox",
"#form-edit-processor").prop("checked")) {
+ data['cpu_info'] = {
+ vcpus: cpu,
+ maxvcpus: maxCpuFinal,
+ topology: {
+ sockets: parseInt($("#sockets").val()),
+ cores: parseInt($("#cores").val()),
+ threads: parseInt($("#threads").val())
+ }
+ };
+ } else {
+ data['cpu_info'] = {
+ vcpus: cpu,
+ maxvcpus: maxCpuFinal,
+ topology: {}
+ };
+ }
}
kimchi.updateVM(kimchi.selectedGuest, data, function() {
diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl
index ce63471..2ee5bda 100644
--- a/ui/pages/guest-edit.html.tmpl
+++ b/ui/pages/guest-edit.html.tmpl
@@ -197,6 +197,9 @@
$_("Current CPU must be equal or lower than the Maximum
CPU value. If a topology is set, it must be also be a multiple of the 'threads'
value.")
</p>
</div>
+ <div id="settings-readonly-help"
class="hidden">
+ <b>$_("Unable to edit maximum CPU or CPU topology when
editing a running or paused virtual machine.")</b>
+ </div>
<div id="guest-max-processor-panel"
class="form-group">
<label
for="guest-edit-max-processor-textbox">$_("Max CPU")</label>
<input id="guest-edit-max-processor-textbox"
class="form-control" name="max-processor" type="number"
min="1" />
@@ -206,7 +209,7 @@
</p>
</div>
</div>
- <div class="manual form-group">
+ <div class="manual form-group"
id="topology-checkbox">
<input type="checkbox" class="wok-checkbox"
id="cpus-check" />
<label for="cpus-check">$_("Manually set CPU
topology")</label>
</div>
diff --git a/ui/pages/help/en_US/guests.dita b/ui/pages/help/en_US/guests.dita
index 45cf7da..5c71694 100644
--- a/ui/pages/help/en_US/guests.dita
+++ b/ui/pages/help/en_US/guests.dita
@@ -77,6 +77,14 @@ create a template.</li>
can be edited only while guest is stopped. Others will take effect
in next boot.</shortdesc>
<csbody>
+<ol><li><uicontrol>If guest is off: </uicontrol>CPU and Memory
new values
+takes effect after next boot.</li>
+<li><uicontrol>If guest is running: </uicontrol>Guest must support
+hotplug/hotunplug of CPU and Memory devices, otherwise changes in these fields will not
take effect. For Power systems, the guest must have:<ul>
+<li>Latest versions of packages <uicontrol>powerpc-utils,
ppc64-diag</uicontrol> and <uicontrol>librtas</uicontrol>
+must be installed.</li>
+<li>Service <uicontrol>rtas_err</uicontrol> must be
running.</li></ul>
+</li></ol>
<dl><dlentry>
<dt>General</dt>
<dd>Displays information about your guest, including name, CPUs, memory,
--
2.7.4