From 08ca32013007e01db65d2bcf6bb6cfc6eb1c2424 Mon Sep 17 00:00:00 2001 From: Shuang Zheng Date: Tue, 15 Sep 2020 10:29:36 +0800 Subject: [PATCH] acrn-config: make ivshmem size configured in decimal and MB make ivshmem size configured in decimal and MB in config tool UI and XMLs to simplify input from users. Tracked-On: #4853 Signed-off-by: Shuang Zheng Acked-by: Victor Sun --- misc/acrn-config/hv_config/board_defconfig.py | 5 +---- misc/acrn-config/library/board_cfg_lib.py | 10 +++++----- misc/acrn-config/library/launch_cfg_lib.py | 10 ++-------- misc/acrn-config/library/scenario_cfg_lib.py | 9 +++------ misc/acrn-config/scenario_config/ivshmem_cfg_h.py | 14 ++++---------- 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/misc/acrn-config/hv_config/board_defconfig.py b/misc/acrn-config/hv_config/board_defconfig.py index f8d0cf750..103066fc3 100644 --- a/misc/acrn-config/hv_config/board_defconfig.py +++ b/misc/acrn-config/hv_config/board_defconfig.py @@ -93,10 +93,7 @@ def get_memory(hv_info, config): and raw_shm_splited[1].strip() != '' and len(raw_shm_splited[2].strip().split(':')) >= 1: try: size = raw_shm_splited[1].strip() - if size.isdecimal(): - int_size = int(size) - else: - int_size = int(size, 16) + int_size = int(size) * 0x100000 total_shm_size += int_size except Exception as e: print(e) diff --git a/misc/acrn-config/library/board_cfg_lib.py b/misc/acrn-config/library/board_cfg_lib.py index 2c997fd5a..405755bdb 100644 --- a/misc/acrn-config/library/board_cfg_lib.py +++ b/misc/acrn-config/library/board_cfg_lib.py @@ -34,7 +34,7 @@ KNOWN_HIDDEN_PDEVS_BOARD_DB = { TSN_DEVS = ["8086:4b30", "8086:4b31", "8086:4b32", "8086:4ba0", "8086:4ba1", "8086:4ba2", "8086:4bb0", "8086:4bb1", "8086:4bb2", "8086:a0ac", "8086:43ac", "8086:43a2"] GPIO_DEVS = ["8086:4b88", "8086:4b89"] -TPM_PASSTHRU_BOARD = ['whl-ipc-i5', 'whl-ipc-i7', 'tgl-rvp', 'ehl-crb-b'] +TPM_PASSTHRU_BOARD = ['whl-ipc-i5', 'whl-ipc-i7', 'tgl-rvp'] KNOWN_CAPS_PCI_DEVS_DB = { "VMSIX":TSN_DEVS + GPIO_DEVS, @@ -496,10 +496,10 @@ def parse_mem(): name = shm_splited[0].strip() size = shm_splited[1].strip() - if size.isdecimal(): - int_size = int(size) - else: - int_size = int(size, 16) + try: + int_size = int(size) * 0x100000 + except: + int_size = 0 ram_range = get_ram_range() tmp_bar_dict = {} hv_start_offset = 0x80000000 diff --git a/misc/acrn-config/library/launch_cfg_lib.py b/misc/acrn-config/library/launch_cfg_lib.py index 3b4de1bef..17996fc75 100644 --- a/misc/acrn-config/library/launch_cfg_lib.py +++ b/misc/acrn-config/library/launch_cfg_lib.py @@ -591,13 +591,9 @@ def set_shm_regions(launch_item_values, scenario_info): shm_splited = shmem_region.split(',') name = shm_splited[0].strip() size = shm_splited[1].strip() - if size.isdecimal(): - int_size = int(size) - else: - int_size = int(size, 16) vm_id_list = [x.strip() for x in shm_splited[2].split(':')] if str(vm_id) in vm_id_list: - launch_item_values[shm_region_key].append(','.join([name, str(int_size)])) + launch_item_values[shm_region_key].append(','.join([name, size])) except Exception as e: print(e) @@ -609,9 +605,7 @@ def check_shm_regions(launch_shm_regions, scenario_info): for uos_id, shm_regions in launch_shm_regions.items(): shm_region_key = 'uos:id={},shm_regions,shm_region'.format(uos_id) for shm_region in shm_regions: - print(shm_region) - print(launch_item_values[shm_region_key]) if shm_region_key not in launch_item_values.keys() or shm_region not in launch_item_values[shm_region_key]: ERR_LIST[shm_region_key] = "shm {} should be configured in scenario setting and the size should be decimal" \ - " and spaces should not exist.".format(shm_region) + "in MB and spaces should not exist.".format(shm_region) return diff --git a/misc/acrn-config/library/scenario_cfg_lib.py b/misc/acrn-config/library/scenario_cfg_lib.py index 6c1a8ec2e..f8a68682c 100644 --- a/misc/acrn-config/library/scenario_cfg_lib.py +++ b/misc/acrn-config/library/scenario_cfg_lib.py @@ -724,7 +724,7 @@ def share_mem_check(shmem_regions, raw_shmem_regions, vm_type_info, prime_item, try: curr_vm_id = int(shm_i) except: - ERR_LIST[key] = "share memory region should be configured with format like this: hv:/shm_region_0, 0x200000, 0:2" + ERR_LIST[key] = "share memory region should be configured with format like this: hv:/shm_region_0, 2, 0:2" return name = shm_str_splited[0].strip() size = shm_str_splited[1].strip() @@ -759,12 +759,9 @@ def share_mem_check(shmem_regions, raw_shmem_regions, vm_type_info, prime_item, int_size = 0 try: - if size.isdecimal(): - int_size = int(size) - else: - int_size = int(size, 16) + int_size = int(size) * 0x100000 except: - ERR_LIST[key] = "The size of share Memory region should be decimal or hexadecimal." + ERR_LIST[key] = "The size of share Memory region should be decimal." return if int_size < 0x200000 or int_size > 0x20000000: ERR_LIST[key] = "The size of share Memory region should be in [2MB, 512MB]." diff --git a/misc/acrn-config/scenario_config/ivshmem_cfg_h.py b/misc/acrn-config/scenario_config/ivshmem_cfg_h.py index 23fdc4c5f..5b06448a1 100644 --- a/misc/acrn-config/scenario_config/ivshmem_cfg_h.py +++ b/misc/acrn-config/scenario_config/ivshmem_cfg_h.py @@ -54,10 +54,7 @@ def write_shmem_regions(config): int_size = 0 size = shmem_region[1] try: - if size.isdecimal(): - int_size = int(size) - else: - int_size = int(size, 16) + int_size = int(size) * 0x100000 except Exception as e: print('the format of shm size error: ', str(e)) total_shm_size += int_size @@ -75,13 +72,10 @@ def write_shmem_regions(config): print("\t{ \\", file=config) print('\t\t.name = IVSHMEM_SHM_REGION_{}, \\'.format(shmem_cnt), file=config) try: - if shmem[1].isdecimal(): - int_m_size = int(int(shmem[1])/0x100000) - else: - int_m_size = int(int(shmem[1], 16)/0x100000) + int_size = int(shmem[1]) * 0x100000 except: - int_m_size = 0 - print('\t\t.size = {}UL,\t\t/* {}M */ \\'.format(shmem[1], int_m_size), file=config) + int_size = 0 + print('\t\t.size = {}UL,\t\t/* {}M */ \\'.format(hex(int_size), shmem[1]), file=config) if shmem_cnt < len(shmem_regions) - 1: print("\t}, \\", file=config) else: