Skip to content

Commit 1903239

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: remove 'scenario' dependency from acrn config tool
For purpose weaken 'scenario' from config tool, remove 'scenario' dependency from config tool. 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 cc5c642 commit 1903239

File tree

13 files changed

+265
-855
lines changed

13 files changed

+265
-855
lines changed

misc/acrn-config/board_config/board_cfg_gen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def main(args):
4040
common.BOARD_INFO_FILE = params['--board']
4141
common.SCENARIO_INFO_FILE = params['--scenario']
4242
common.get_vm_num(params['--scenario'])
43+
common.get_vm_types()
4344

4445
# get board name
4546
(err_dic, board) = common.get_board_name()

misc/acrn-config/board_config/misc_cfg_h.py

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,18 @@ def sos_bootarg_diff(sos_cmdlines, config):
4848
def parse_boot_info():
4949

5050
err_dic = {}
51-
vm_types = []
5251

53-
(err_dic, scenario_name) = common.get_scenario_name()
54-
if err_dic:
55-
return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types)
56-
57-
if scenario_name != "logical_partition":
58-
sos_cmdlines = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "board_private", "bootargs")
59-
sos_rootfs = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "board_private", "rootfs")
52+
if 'SOS_VM' in common.VM_TYPES.values():
53+
sos_cmdlines = list(common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "board_private", "bootargs").values())
54+
sos_rootfs = list(common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "board_private", "rootfs").values())
6055
(err_dic, vuart0_dic, vuart1_dic) = board_cfg_lib.get_board_private_vuart("board_private", "console")
6156
else:
62-
sos_cmdlines = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "os_config", "bootargs")
57+
sos_cmdlines = list(common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "os_config", "bootargs").values())
6358

64-
sos_rootfs = common.get_sub_leaf_tag(common.SCENARIO_INFO_FILE, "os_config", "rootfs")
59+
sos_rootfs = list(common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "os_config", "rootfs").values())
6560
(err_dic, vuart0_dic, vuart1_dic) = board_cfg_lib.get_board_private_vuart("os_config", "console")
6661

67-
for i in range(common.VM_COUNT):
68-
vm_type = board_cfg_lib.get_order_type_by_vmid(i)
69-
vm_types.append(vm_type)
70-
71-
return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types)
62+
return (err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic)
7263

7364

7465
def find_hi_mmio_window(config):
@@ -129,7 +120,7 @@ def generate_file(config):
129120
return err_dic
130121

131122
# parse sos_bootargs/rootfs/console
132-
(err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic, vm_types) = parse_boot_info()
123+
(err_dic, sos_cmdlines, sos_rootfs, vuart0_dic, vuart1_dic) = parse_boot_info()
133124
if err_dic:
134125
return err_dic
135126

@@ -176,7 +167,7 @@ def generate_file(config):
176167

177168
# sos rootfs and console
178169
print("", file=config)
179-
if "SOS_VM" in vm_types:
170+
if "SOS_VM" in common.VM_TYPES.values():
180171
print('#define SOS_ROOTFS\t\t"root={} "'.format(sos_rootfs[0]), file=config)
181172
if ttys_n:
182173
print('#define SOS_CONSOLE\t\t"console={} "'.format(ttys_n), file=config)
@@ -185,12 +176,12 @@ def generate_file(config):
185176

186177
# sos com base/irq
187178
i_type = 0
188-
for vm_type in vm_types:
179+
for vm_i,vm_type in common.VM_TYPES.items():
189180
if vm_type == "SOS_VM":
181+
i_type = vm_i
190182
break
191-
i_type += 1
192183

193-
if "SOS_VM" in vm_types:
184+
if "SOS_VM" in common.VM_TYPES.values():
194185
if vuart0_dic:
195186
print("#define SOS_COM1_BASE\t\t{}U".format(vuart0_port_base), file=config)
196187
print("#define SOS_COM1_IRQ\t\t{}U".format(vuart0_irq), file=config)
@@ -204,7 +195,7 @@ def generate_file(config):
204195

205196
# sos boot command line
206197
print("", file=config)
207-
if "SOS_VM" in vm_types:
198+
if "SOS_VM" in common.VM_TYPES.values():
208199
sos_bootarg_diff(sos_cmdlines, config)
209200

210201
# set macro for HIDDEN PTDEVS

misc/acrn-config/hv_config/board_defconfig.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,10 @@ def get_serial_type():
8585
# Get ttySx information from board config file
8686
ttys_lines = board_cfg_lib.get_info(common.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>")
8787

88-
(err_dic, scenario_name) = common.get_scenario_name()
89-
if scenario_name == "logical_partition":
90-
ttyn = 'ttyS0'
91-
else:
92-
# Get ttySx from scenario config file which selected by user
93-
(err_dic, ttyn) = board_cfg_lib.parser_vuart_console()
94-
if err_dic:
95-
hv_cfg_lib.ERR_LIST.update(err_dic)
88+
# Get ttySx from scenario config file which selected by user
89+
(err_dic, ttyn) = board_cfg_lib.parser_vuart_console()
90+
if err_dic:
91+
hv_cfg_lib.ERR_LIST.update(err_dic)
9692

9793
# query the serial type from board config file
9894
for line in ttys_lines:
@@ -189,7 +185,6 @@ def get_capacities(hv_info, config):
189185
print("CONFIG_MAX_IOAPIC_NUM={}".format(hv_info.cap.max_ioapic_num), file=config)
190186
print("CONFIG_MAX_IR_ENTRIES={}".format(hv_info.cap.max_ir_entries), file=config)
191187
print("CONFIG_MAX_PCI_DEV_NUM={}".format(hv_info.cap.max_pci_dev_num), file=config)
192-
print("CONFIG_MAX_KATA_VM_NUM={}".format(hv_info.cap.max_kata_vm_num), file=config)
193188
print("CONFIG_MAX_IOAPIC_LINES={}".format(hv_info.cap.max_ioapic_lines), file=config)
194189
print("CONFIG_MAX_PT_IRQ_ENTRIES={}".format(hv_info.cap.max_pt_irq_entries), file=config)
195190
print("CONFIG_MAX_MSIX_TABLE_NUM={}".format(hv_info.cap.max_msix_table_num), file=config)
@@ -219,7 +214,6 @@ def generate_file(hv_info, config):
219214
if hv_info.log.release == 'y':
220215
print("CONFIG_RELEASE=y", file=config)
221216
print('CONFIG_BOARD="{}"'.format(board_name), file=config)
222-
print("CONFIG_{}=y".format(scenario_name.upper()), file=config)
223217

224218
get_memory(hv_info, config)
225219
get_miscfg(hv_info, config)

misc/acrn-config/launch_config/launch_cfg_gen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def main(args):
164164
common.BOARD_INFO_FILE = board_info_file
165165
common.SCENARIO_INFO_FILE = scenario_info_file
166166
common.LAUNCH_INFO_FILE = launch_info_file
167+
common.get_vm_types()
167168

168169
# get post vm dic
169170
post_num_list = launch_cfg_lib.get_post_num_list()

misc/acrn-config/library/board_cfg_lib.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,6 @@ def clos_info_parser(board_info):
170170
return get_max_clos_mask(board_info)
171171

172172

173-
def get_order_type_by_vmid(idx):
174-
"""
175-
This is get pre launched vm count
176-
:param idx: index of vm id
177-
:return: vm type of index to vmid
178-
"""
179-
(err_dic, order_type) = common.get_load_order_by_vmid(common.SCENARIO_INFO_FILE, common.VM_COUNT, idx)
180-
if err_dic:
181-
ERR_LIST.update(err_dic)
182-
183-
return order_type
184-
185-
186173
def get_valid_irq(board_info):
187174
"""
188175
This is get available irq from board info file
@@ -254,8 +241,7 @@ def parser_vuart_console():
254241
3. ttyS2
255242
"""
256243
ttys_n = ''
257-
(err_dic, scenario_name) = common.get_scenario_name()
258-
244+
err_dic = {}
259245
ttys = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "DEBUG_OPTIONS", "SERIAL_CONSOLE")
260246

261247
if not ttys or ttys == None:
@@ -345,6 +331,9 @@ def get_vuart_info_id(config_file, idx):
345331
vm_id = 0
346332
root = common.get_config_root(config_file)
347333
for item in root:
334+
if item.tag == "vm":
335+
vm_id = int(item.attrib['id'])
336+
348337
for sub in item:
349338
tmp_vuart = {}
350339
for leaf in sub:
@@ -355,9 +344,6 @@ def get_vuart_info_id(config_file, idx):
355344
if tmp_vuart and sub.tag == "vuart":
356345
tmp_tag[vm_id] = tmp_vuart
357346

358-
if item.tag == "vm":
359-
vm_id += 1
360-
361347
return tmp_tag
362348

363349

misc/acrn-config/library/common.py

Lines changed: 14 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
BOARD_INFO_FILE = ""
3232
SCENARIO_INFO_FILE = ""
3333
LAUNCH_INFO_FILE = ""
34+
VM_TYPES = {}
3435

3536
class MultiItem():
3637

@@ -204,36 +205,19 @@ def is_config_file_match():
204205
return (err_dic, False)
205206

206207

207-
def find_index_guest_flag(flag):
208+
def find_tmp_flag(flag):
208209
"""
209210
Find the index in GUEST_FLAG by flag
210211
:param flag: flag contained by GUEST_FLAG
211212
:return: index of GUEST_FLAG
212213
"""
213-
if not flag or flag == '0':
214-
return '0'
214+
if flag == None or flag == '0':
215+
return '0UL'
215216

216-
if not flag.isnumeric():
217-
for i in range(len(GUEST_FLAG)):
218-
if flag == GUEST_FLAG[i]:
219-
flag_str = i
220-
return flag_str
221-
222-
def find_tmp_flag(leaf_text):
223-
"""
224-
Get flag and append the value
225-
:param leaf_text: it is a value of guest flag item
226-
:return: a list of flag or none
227-
"""
228-
tmp_flag = []
229-
tmp_flag = find_index_guest_flag(leaf_text)
230-
#flag_index = find_index_guest_flag(leaf_text)
231-
#if flag_index == '0':
232-
# tmp_flag.append(0)
233-
#else:
234-
# tmp_flag.append(flag_index)
235-
236-
return tmp_flag
217+
flag_str = ''
218+
for i in range(len(GUEST_FLAG)):
219+
if flag == GUEST_FLAG[i]:
220+
return flag_str
237221

238222

239223
def get_config_root(config_file):
@@ -266,67 +250,12 @@ def get_vm_num(config_file):
266250
VM_COUNT = vm_count
267251

268252

269-
# TODO: This will be abandonment in future
270-
def get_sub_leaf_tag(config_file, branch_tag, tag_str=''):
271-
"""
272-
This is get tag value by tag_str from config file
273-
:param config_file: it is a file what contains information for script to read from
274-
:param branch_tag: it is key of patter to config file branch tag item
275-
:param tag_str: it is key of pattern to config file leaf tag item
276-
:return: value of tag_str item
277-
"""
278-
tmp_tag = []
279-
root = get_config_root(config_file)
280-
for item in root:
281-
# for each 2th level item
282-
for sub in item:
283-
tmp_flag = []
284-
tmp_cpus = []
285-
if sub.tag == branch_tag:
286-
if not tag_str:
287-
tmp_tag.append(sub.text)
288-
continue
289-
290-
# for each 3rd level item
291-
for leaf in sub:
292-
if leaf.tag == tag_str and tag_str not in MULTI_ITEM and sub.tag != "vuart":
293-
tmp_tag.append(leaf.text)
294-
continue
295-
296-
# get guest flag for logical partition vm1
297-
if leaf.tag == "guest_flag" and tag_str == "guest_flag":
298-
t_flag = find_tmp_flag(leaf.text)
299-
tmp_flag.append(t_flag)
300-
#continue
301-
302-
# get cpu for vm
303-
if leaf.tag == "pcpu_id" and tag_str == "pcpu_id":
304-
tmp_cpus.append(leaf.text)
305-
continue
306-
307-
# get vcpu_clos for vm
308-
if leaf.tag == "vcpu_clos" and tag_str == "vcpu_clos":
309-
tmp_cpus.append(leaf.text)
310-
continue
311-
312-
# append guest flags for each vm
313-
if tmp_flag and tag_str == "guest_flag":
314-
tmp_tag.append(tmp_flag)
315-
continue
316-
317-
# append cpus for vm
318-
if tmp_cpus and tag_str == "pcpu_id":
319-
tmp_tag.append(tmp_cpus)
320-
continue
321-
322-
return tmp_tag
323-
324-
325253
def get_leaf_value(tmp, tag_str, leaf):
326254

327255
# get guest flag for logical partition vm1
328256
if leaf.tag == "guest_flag" and tag_str == "guest_flag":
329257
t_flag = find_tmp_flag(leaf.text)
258+
#print("--debug: tag:{},{}".format(tag_str), t_flag)
330259
tmp.multi.guest_flag.append(t_flag)
331260

332261
# get cpu for vm
@@ -355,7 +284,6 @@ def get_sub_value(tmp, tag_str, vm_id):
355284
# append guest flags for each vm
356285
if tmp.multi.guest_flag and tag_str == "guest_flag":
357286
tmp.tag[vm_id] = tmp.multi.guest_flag
358-
tmp.tag.append(tmp.multi.guest_flag)
359287

360288
# append cpus for vm
361289
if tmp.multi.pcpu_id and tag_str == "pcpu_id":
@@ -442,37 +370,6 @@ def get_hv_item_tag(config_file, branch_tag, tag_str=''):
442370
return tmp
443371

444372

445-
def order_type_map_vmid(config_file, vm_count):
446-
"""
447-
This is mapping table for {id:order type}
448-
:param config_file: it is a file what contains information for script to read from
449-
:param vm_count: vm number
450-
:return: table of id:order type dictionary
451-
"""
452-
order_id_dic = {}
453-
load_type_list = get_sub_leaf_tag(config_file, "load_order")
454-
for i in range(vm_count):
455-
order_id_dic[i] = load_type_list[i]
456-
457-
return order_id_dic
458-
459-
460-
def get_load_order_by_vmid(config_file, vm_count, idx):
461-
"""
462-
Get load order by vm id
463-
:param config_file: it is a file what contains information for script to read from
464-
:param vm_count: vm number
465-
:param idx: index of vm id
466-
:return: table of id:order type dictionary
467-
"""
468-
err_dic = {}
469-
order_id_dic = order_type_map_vmid(config_file, vm_count)
470-
if idx >= vm_count or not order_id_dic:
471-
err_dic['vm number: failue'] = "Toatal vm number is less than index number"
472-
473-
return (err_dic, order_id_dic[idx])
474-
475-
476373
def undline_name(name):
477374
"""
478375
This convert name which has contain '-' to '_'
@@ -519,3 +416,8 @@ def num2int(str_value):
519416
val = int(str_value, 16)
520417

521418
return val
419+
420+
421+
def get_vm_types():
422+
global VM_TYPES
423+
VM_TYPES = get_leaf_tag_map(SCENARIO_INFO_FILE, "load_order")

misc/acrn-config/library/launch_cfg_lib.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ def post_vm_cnt(config_file):
166166
:return: number of post launched vm
167167
"""
168168
post_launch_cnt = 0
169-
load_type_list = common.get_sub_leaf_tag(config_file, "load_order")
170169

171-
for vm_type in load_type_list:
170+
for vm_type in common.VM_TYPES.values():
172171
if vm_type == "POST_LAUNCHED_VM":
173172
post_launch_cnt += 1
174173

0 commit comments

Comments
 (0)