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

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Fri Nov 13 01:42:54 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 | 8 +++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/wok/plugins/kimchi/model/vms.py b/src/wok/plugins/kimchi/model/vms.py
index 8b7d4bd..3c4c3d4 100644
--- a/src/wok/plugins/kimchi/model/vms.py
+++ b/src/wok/plugins/kimchi/model/vms.py
@@ -823,6 +823,10 @@ class VMModel(object):
                    int(maxMem.text) != (host_mem << 10):
                     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),
@@ -881,6 +885,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..d653665 100644
--- a/src/wok/plugins/kimchi/vmtemplate.py
+++ b/src/wok/plugins/kimchi/vmtemplate.py
@@ -18,6 +18,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
 import os
+import platform
 import stat
 import time
 import urlparse
@@ -328,13 +329,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