[Kimchi-devel] [PATCH v3][Kimchi] Increase guest Max Memory limits

Jose Ricardo Ziviani joserz at linux.vnet.ibm.com
Tue Mar 8 21:02:26 UTC 2016


Reviewed by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>

On 08-03-2016 18:00, Rodrigo Trujillo wrote:
> This patch changes the limits of max memory to 16TiB in PowerPC and 4TiB
> in x86 architectures.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   i18n.py                |  2 +-
>   model/templates.py     | 12 ++++++++----
>   tests/test_template.py |  5 +++--
>   3 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/i18n.py b/i18n.py
> index 008e327..707b74b 100644
> --- a/i18n.py
> +++ b/i18n.py
> @@ -133,7 +133,7 @@ messages = {
>       "KCHVM0076E": _("VM %(name)s must have serial and console defined to open a web serial console"),
>       "KCHVM0077E": _("Impossible to get the serial console of %(name)s"),
>       "KCHVM0078E": _("Memory or Maximum Memory value is higher than amount supported by the host: %(memHost)sMiB."),
> -    "KCHVM0079E": _("Memory or Maximum Memory value is higher than maximum amount recommended: 1TiB"),
> +    "KCHVM0079E": _("Memory or Maximum Memory value is higher than maximum amount recommended: %(value)sTiB"),
>       "KCHVM0080E": _("Cannot update Maximum Memory when guest is running."),
>
>       "KCHVMHDEV0001E": _("VM %(vmid)s does not contain directly assigned host device %(dev_name)s."),
> diff --git a/model/templates.py b/model/templates.py
> index fb63dc1..92705b6 100644
> --- a/model/templates.py
> +++ b/model/templates.py
> @@ -38,8 +38,10 @@ from wok.plugins.kimchi.vmtemplate import VMTemplate
>
>   # In PowerPC, memories must be aligned to 256 MiB
>   PPC_MEM_ALIGN = 256
> -# Max memory 1TB, in KiB
> -MAX_MEM_LIM = 1073741824
> +# Max memory 16TB for PPC and 4TiB for X (according to Red Hat), in KiB
> +MAX_MEM_LIM = 4294967296    # 4 TiB
> +if os.uname()[4] in ['ppc', 'ppc64', 'ppc64le']:
> +    MAX_MEM_LIM *= 4     # 16TiB
>
>
>   class TemplatesModel(object):
> @@ -225,9 +227,11 @@ def validate_memory(memory):
>       else:
>           host_memory = psutil.TOTAL_PHYMEM >> 10 >> 10
>
> -    # Memories must be lesser than 1TB and the Host memory limit
> +    # Memories must be lesser than 16TiB (PPC) or 4TiB (x86) and the Host
> +    # memory limit
>       if (current > (MAX_MEM_LIM >> 10)) or (maxmem > (MAX_MEM_LIM >> 10)):
> -        raise InvalidParameter("KCHVM0079E")
> +        raise InvalidParameter("KCHVM0079E",
> +                               {'value': str(MAX_MEM_LIM / (1024**3))})
>       if (current > host_memory) or (maxmem > host_memory):
>           raise InvalidParameter("KCHVM0078E", {'memHost': host_memory})
>
> diff --git a/tests/test_template.py b/tests/test_template.py
> index 4a74955..fcb2e46 100644
> --- a/tests/test_template.py
> +++ b/tests/test_template.py
> @@ -29,6 +29,7 @@ from tests.utils import get_free_port, patch_auth, request, run_server
>   from wok.plugins.kimchi.config import READONLY_POOL_TYPE
>   from wok.plugins.kimchi.mockmodel import MockModel
>   from wok.plugins.kimchi.model.featuretests import FeatureTests
> +from wok.plugins.kimchi.model.templates import MAX_MEM_LIM
>
>
>   model = None
> @@ -227,8 +228,8 @@ class TemplateTests(unittest.TestCase):
>           req = json.dumps({'memory': {'current': 2048}})
>           resp = self.request(new_tmpl_uri, req, 'PUT')
>           self.assertEquals(400, resp.status)
> -        # - max memory greater than 1TiB limit
> -        req = json.dumps({'memory': {'maxmemory': 1073741824 + 1024}})
> +        # - max memory greater than limit: 16TiB to PPC and 4TiB to x86
> +        req = json.dumps({'memory': {'maxmemory': MAX_MEM_LIM + 1024}})
>           resp = self.request(new_tmpl_uri, req, 'PUT')
>           self.assertEquals(400, resp.status)
>           self.assertTrue('KCHVM0079E' in resp.read())
>

-- 
Jose Ricardo Ziviani
-----------------------------
Software Engineer
Linux Technology Center - IBM




More information about the Kimchi-devel mailing list