[Kimchi-devel] [PATCH 3/3 - v2] Change memory multipliers/divisors by bitwise operators
Aline Manera
alinefm at linux.vnet.ibm.com
Mon Nov 16 20:32:50 UTC 2015
Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>
On 12/11/2015 23:42, Rodrigo Trujillo wrote:
> In Kimchi memory manipulation code, memory values are most of the time
> multiplied or divided by 1024. This patch changes these operations,
> replacing by << 10 or >> 10, as standard.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
> src/wok/plugins/kimchi/model/vms.py | 4 ++--
> src/wok/plugins/kimchi/tests/test_livemigration.py | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/wok/plugins/kimchi/model/vms.py b/src/wok/plugins/kimchi/model/vms.py
> index 3c4c3d4..ab44c4b 100644
> --- a/src/wok/plugins/kimchi/model/vms.py
> +++ b/src/wok/plugins/kimchi/model/vms.py
> @@ -829,7 +829,7 @@ class VMModel(object):
>
> if maxMem is None:
> max_mem_xml = E.maxMemory(
> - str(host_mem * 1024),
> + str(host_mem << 10),
> unit='Kib',
> slots=str(slots))
> root.insert(0, max_mem_xml)
> @@ -877,7 +877,7 @@ class VMModel(object):
>
> # Check slot spaces:
> total_slots = int(xpath_get_text(xml, './maxMemory/@slots')[0])
> - needed_slots = (new_mem - old_mem) / 1024
> + needed_slots = (new_mem - old_mem) >> 10
> used_slots = len(xpath_get_text(xml, './devices/memory'))
> if needed_slots > (total_slots - used_slots):
> raise OperationFailed('KCHVM0045E')
> diff --git a/src/wok/plugins/kimchi/tests/test_livemigration.py b/src/wok/plugins/kimchi/tests/test_livemigration.py
> index 1fdcd65..1c6d92d 100644
> --- a/src/wok/plugins/kimchi/tests/test_livemigration.py
> +++ b/src/wok/plugins/kimchi/tests/test_livemigration.py
> @@ -94,7 +94,7 @@ class LiveMigrationTests(unittest.TestCase):
> 'disks': [],
> 'cdrom': UBUNTU_ISO,
> 'memory': 2048,
> - 'max_memory': 4096*1024}
> + 'max_memory': 4096 << 10}
> self.inst.templates_create(params)
>
> def tearDown(self):
More information about the Kimchi-devel
mailing list