Skip to content

Commit 16e33b3

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: add vm type sanity check
Refinement for VM type sanity check relays on VM UUID number. Tracked-On: #4641 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com> Acked-by: Terry Zou <terry.zou@intel.com>
1 parent 1195982 commit 16e33b3

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

misc/acrn-config/launch_config/launch_cfg_gen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def get_launch_item_values(board_info):
2121
Get items which capable multi select for user
2222
:param board_info: it is a file what contains board information for script to read from
2323
"""
24+
common.BOARD_INFO_FILE = board_info
2425
launch_item_values = {}
2526

2627
# passthrough devices

misc/acrn-config/library/launch_cfg_lib.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,23 @@ def is_config_file_match():
203203
return (err_dic, match)
204204

205205

206-
def get_scenario_uuid(uosid):
207-
# {id_num:uuid} (id_num:0~max)
208-
scenario_uuid = ''
209-
if common.VM_TYPES[uosid] == "KATA_VM" or common.VM_TYPES[uosid] == "POST_RT_VM":
210-
return scenario_cfg_lib.VM_DB[common.VM_TYPES[uosid]]['uuid']
206+
def get_vm_uuid_idx(vm_type, uosid):
211207

212208
i_cnt = 0
213-
for vm_i,vm_type in common.VM_TYPES.items():
214-
if vm_type == "POST_STD_VM" and vm_i <= uosid:
209+
for vm_i,vm_t in common.VM_TYPES.items():
210+
if vm_t == vm_type and vm_i <= uosid:
215211
i_cnt += 1
216212
if i_cnt > 0:
217-
i_cnt = 0
213+
i_cnt -= 1
214+
215+
return i_cnt
218216

219-
scenario_uuid = scenario_cfg_lib.VM_DB["POST_STD_VM"]['uuid'][i_cnt]
217+
218+
def get_scenario_uuid(uosid):
219+
# {id_num:uuid} (id_num:0~max)
220+
scenario_uuid = ''
221+
i_cnt = get_vm_uuid_idx(common.VM_TYPES[uosid], uosid)
222+
scenario_uuid = scenario_cfg_lib.VM_DB[common.VM_TYPES[uosid]]['uuid'][i_cnt]
220223
return scenario_uuid
221224

222225

misc/acrn-config/library/scenario_cfg_lib.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
PT_SUB_PCI['sata'] = ['SATA controller']
3939
PT_SUB_PCI['nvme'] = ['Non-Volatile memory controller']
4040
UUID_DB = {
41-
'SOS_VM':'dbbbd434-7a57-4216-a12c-2201f1ab0240',
42-
'SAFETY_VM':'fc836901-8685-4bc0-8b71-6e31dc36fa47',
41+
'SOS_VM':['dbbbd434-7a57-4216-a12c-2201f1ab0240'],
42+
'SAFETY_VM':['fc836901-8685-4bc0-8b71-6e31dc36fa47'],
4343
'PRE_STD_VM':['26c5e0d8-8f8a-47d8-8109-f201ebd61a5e', 'dd87ce08-66f9-473d-bc58-7605837f935e'],
4444
'POST_STD_VM':['d2795438-25d6-11e8-864e-cb7a18b34643', '615db82a-e189-4b4f-8dbb-d321343e4ab3',
4545
'38158821-5208-4005-b72a-8a609e4190d0', 'a6750180-f87a-48d2-91d9-4e7f62b6519e', 'd1816e4a-a9bb-4cb4-a066-3f1a8a5ce73f'],
46-
'POST_RT_VM':'495ae2e5-2603-4d64-af76-d4bc5a8ec0e5',
47-
'KATA_VM':'a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f',
46+
'POST_RT_VM':['495ae2e5-2603-4d64-af76-d4bc5a8ec0e5'],
47+
'KATA_VM':['a7ada506-1ab0-4b6b-a0da-e513ca9b8c2f'],
4848
}
4949

5050
VM_DB = {
@@ -156,19 +156,29 @@ def load_vm_check(load_vms, item):
156156
if "POST_RT_VM" == load_str:
157157
rt_vm_ids.append(order_i)
158158

159-
if len(kata_vm_ids) >=2:
159+
if len(kata_vm_ids) > len(UUID_DB["KATA_VM"]):
160160
key = "vm:id={},{}".format(kata_vm_ids[0], item)
161-
ERR_LIST[key] = "KATA VM number should not be greater than 1"
161+
ERR_LIST[key] = "KATA VM number should not be greater than {}".format(len(UUID_DB["KATA_VM"]))
162162
return
163163

164-
if len(rt_vm_ids) >= 2:
164+
if len(rt_vm_ids) > len(UUID_DB["POST_RT_VM"]):
165165
key = "vm:id={},{}".format(rt_vm_ids[0], item)
166-
ERR_LIST[key] = "POST RT VM number should not be greater than 1"
166+
ERR_LIST[key] = "POST RT VM number should not be greater than {}".format(len(UUID_DB["POST_RT_VM"]))
167167
return
168168

169-
if len(sos_vm_ids) >= 2:
169+
if len(sos_vm_ids) > 1:
170170
key = "vm:id={},{}".format(sos_vm_ids[0], item)
171-
ERR_LIST[key] = "SOS vm number should not be greater than 1"
171+
ERR_LIST[key] = "SOS VM number should not be greater than 1"
172+
return
173+
174+
if len(post_vm_ids) > len(UUID_DB["POST_STD_VM"]):
175+
key = "vm:id={},{}".format(post_vm_ids[0], item)
176+
ERR_LIST[key] = "POST Standard vm number should not be greater than {}".format(len(UUID_DB["POST_STD_VM"]))
177+
return
178+
179+
if len(pre_vm_ids) > len(UUID_DB["PRE_STD_VM"]):
180+
key = "vm:id={},{}".format(pre_vm_ids[0], item)
181+
ERR_LIST[key] = "PRE Standard vm number should not be greater than {}".format(len(UUID_DB["PRE_STD_VM"]))
172182
return
173183

174184
if post_vm_ids and sos_vm_ids:

0 commit comments

Comments
 (0)