[Kimchi-devel] [PATCH 2/2] Check and align number of memory slot to 32 in PowerPC

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Nov 10 15:51:44 UTC 2015


This patch checks the number os memory slots needed in PowerPC and
raises an error if > 32, or set it to 32.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/wok/plugins/kimchi/model/vms.py  | 8 ++++++++
 src/wok/plugins/kimchi/vmtemplate.py | 7 ++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/wok/plugins/kimchi/model/vms.py b/src/wok/plugins/kimchi/model/vms.py
index 3965906..401cfc6 100644
--- a/src/wok/plugins/kimchi/model/vms.py
+++ b/src/wok/plugins/kimchi/model/vms.py
@@ -819,6 +819,10 @@ class VMModel(object):
                    int(maxMem.text) != (host_mem * 1024):
                     force_max_mem_update = True
 
+                # max 32 slots on Power
+                if slots > 32:
+                    slots = 32
+
             if maxMem is None:
                 max_mem_xml = E.maxMemory(
                     str(host_mem * 1024),
@@ -877,6 +881,10 @@ class VMModel(object):
             # New memory value is same that current memory set
             return
 
+        distro, _, _ = platform.linux_distribution()
+        if distro == "IBM_PowerKVM" and needed_slots > 32:
+            raise OperationFailed('KCHVM0045E')
+
         # Finally, we are ok to hot add the memory devices
         try:
             self._hot_add_memory_devices(dom, needed_slots)
diff --git a/src/wok/plugins/kimchi/vmtemplate.py b/src/wok/plugins/kimchi/vmtemplate.py
index 283d94d..4556ee6 100644
--- a/src/wok/plugins/kimchi/vmtemplate.py
+++ b/src/wok/plugins/kimchi/vmtemplate.py
@@ -328,13 +328,18 @@ class VMTemplate(object):
 
         # Setting maximum number of slots to avoid errors when hotplug memory
         # Number of slots are the numbers of chunks of 1GB that fit inside
-        # the max_memory of the host minus memory assigned to the VM
+        # the max_memory of the host minus memory assigned to the VM. It
+        # cannot have more than 32 slots in Power.
         params['slots'] = ((params['max_memory'] >> 10) -
                            params['memory']) >> 10
         if params['slots'] < 0:
             raise OperationFailed("KCHVM0041E")
         elif params['slots'] == 0:
             params['slots'] = 1
+        elif params['slots'] > 32:
+            distro, _, _ = platform.linux_distribution()
+            if distro == "IBM_PowerKVM":
+                params['slots'] = 32
 
         xml = """
         <domain type='%(domain)s'>
-- 
2.1.0




More information about the Kimchi-devel mailing list