[PATCH v2][Kimchi] Fix memory value return when hotplug memory devs

There is an issue when Kimchi returns the value of memory, if the guest is running. It is returning the current memory value, instead of the total memory, which includes the value of the memory devices added. This patch fix this problem returning the total value: current memory + total of memory devs. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- model/vms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/model/vms.py b/model/vms.py index e3bc266..08c3e45 100644 --- a/model/vms.py +++ b/model/vms.py @@ -1228,7 +1228,11 @@ class VMModel(object): unit = 'KiB' memory = convert_data_size(val, unit, 'MiB') else: - memory = info[2] >> 10 + # Return current memory plus the amount of memory given by memory + # devices + root = ET.fromstring(xml) + totMemDevs = len(root.findall('./devices/memory')) * 1024 + memory = (info[2] >> 10) + totMemDevs # assure there is no zombie process left for proc in self._serial_procs[:]: -- 2.1.0

On 03/23/2016 08:14 PM, Rodrigo Trujillo wrote:
There is an issue when Kimchi returns the value of memory, if the guest is running. It is returning the current memory value, instead of the total memory, which includes the value of the memory devices added. This patch fix this problem returning the total value: current memory + total of memory devs.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- model/vms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/model/vms.py b/model/vms.py index e3bc266..08c3e45 100644 --- a/model/vms.py +++ b/model/vms.py @@ -1228,7 +1228,11 @@ class VMModel(object): unit = 'KiB' memory = convert_data_size(val, unit, 'MiB') else: - memory = info[2] >> 10 + # Return current memory plus the amount of memory given by memory + # devices + root = ET.fromstring(xml)
+ totMemDevs = len(root.findall('./devices/memory')) * 1024
You are assuming each device memory has 1GB. It can be true when doing hot plug using Kimchi, but user can do it externally and set any amount of memory to each device.
+ memory = (info[2] >> 10) + totMemDevs
# assure there is no zombie process left for proc in self._serial_procs[:]:
participants (2)
-
Aline Manera
-
Rodrigo Trujillo