Skip to content

Commit bc31dc0

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: modify rootfs tag in board information
1. grap 'ext4' rootfs, and store it as "BLOCK_DEVICE_INFO" tag 2. remove 'Tab' from app tools 3. add support to parse ' ' from scenario xml v1-v2: 1). modify the board info "ROOT_DEVICE_INFO" -> "BLOCK_DEVICE_INFO" Tracked-On: #3602 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Terry Zou <terry.zou@intel.com>
1 parent f50f92c commit bc31dc0

File tree

11 files changed

+93
-30
lines changed

11 files changed

+93
-30
lines changed

misc/acrn-config/config_app/templates/scenario.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,7 @@ <h4 class="modal-title" id="myModalLabel">Save as</h4>
169169
readonly>{{sub_elem_text}}</textarea>
170170
{% else %}
171171
<textarea type="text" class="form-control" style="height:120px"
172-
id="{{'vm:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}">
173-
{{sub_elem_text}}</textarea>
172+
id="{{'vm:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}">{{sub_elem_text}}</textarea>
174173
{% endif %}
175174
</div>
176175
{% else %}

misc/acrn-config/library/board_cfg_lib.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,20 @@ def get_rootfs(config_file):
199199
:param config_file: it is a file which contain board information
200200
:return: rootfs partition list
201201
"""
202-
rootfs_lines = get_info(config_file, "<ROOT_DEVICE_INFO>", "</ROOT_DEVICE_INFO>")
203202
root_dev_list = []
203+
rootfs_lines = get_info(config_file, "<BLOCK_DEVICE_INFO>", "</BLOCK_DEVICE_INFO>")
204+
205+
# none 'BLOCK_DEVICE_INFO' tag
206+
if rootfs_lines == None:
207+
return root_dev_list
204208

205209
for rootfs_line in rootfs_lines:
210+
if not rootfs_line:
211+
break
212+
213+
if not common.handle_root_dev(rootfs_line):
214+
continue
215+
206216
root_dev = rootfs_line.strip().split(':')[0]
207217
root_dev_list.append(root_dev)
208218

misc/acrn-config/library/common.py

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,8 @@ def get_post_vm_count(config_file):
285285
# get post vm number
286286
root = get_config_root(config_file)
287287
for item in root:
288-
for sub in item:
289-
if sub.tag == "load_order" and sub.text == "POST_LAUNCHED_VM":
290-
post_vm_count += 1
288+
if item.tag == "uos":
289+
post_vm_count += 1
291290

292291
return post_vm_count
293292

@@ -307,7 +306,26 @@ def get_tree_tag_val(config_file, tag_str):
307306
return False
308307

309308

310-
def get_branch_tag(config_file, tag_str):
309+
#def get_spec_branch_tag(config_file, tag_str, p_id):
310+
# """
311+
# This is get tag value by tag_str from config file
312+
# :param config_file: it is a file what contains information for script to read from
313+
# :param tag_str: it is key of pattern to config file item
314+
# :return: value of tag_str item list
315+
# """
316+
# tmp_tag = ''
317+
# root = get_config_root(config_file)
318+
# for item in root:
319+
# if item.tag != 'vm' and item.attrib['id'] != str(p_id):
320+
# continue
321+
# for sub in item:
322+
# if sub.tag == tag_str:
323+
# tmp_tag = sub.text
324+
#
325+
# return tmp_tag
326+
327+
328+
def get_branch_tag_val(config_file, tag_str):
311329
"""
312330
This is get tag value by tag_str from config file
313331
:param config_file: it is a file what contains information for script to read from
@@ -317,27 +335,28 @@ def get_branch_tag(config_file, tag_str):
317335
tmp_tag = []
318336
root = get_config_root(config_file)
319337
for item in root:
320-
321338
for sub in item:
322339
if sub.tag == tag_str:
323340
tmp_tag.append(sub.text)
324341

325342
return tmp_tag
326343

327344

328-
def get_branch_tag_val(config_file, tag_str):
345+
def get_spec_branch_tag_val(config_file, tag_str, uos_id):
329346
"""
330347
This is get tag value by tag_str from config file
331348
:param config_file: it is a file what contains information for script to read from
332349
:param tag_str: it is key of pattern to config file item
333350
:return: value of tag_str item list
334351
"""
335-
tmp_tag = []
352+
tmp_tag = ''
336353
root = get_config_root(config_file)
337354
for item in root:
355+
if item.attrib['id'] != uos_id:
356+
continue
338357
for sub in item:
339358
if sub.tag == tag_str:
340-
tmp_tag.append(sub.text)
359+
tmp_tag = sub.text
341360

342361
return tmp_tag
343362

@@ -363,6 +382,22 @@ def get_branch_tag_map(config_file, tag_str):
363382
return tmp_tag
364383

365384

385+
def get_spec_leaf_tag_val(config_file, branch_tag, tag_str, uos_id):
386+
tmp_tag = ''
387+
root = get_config_root(config_file)
388+
for item in root:
389+
if item.attrib['id'] != uos_id:
390+
continue
391+
for sub in item:
392+
if sub.tag == branch_tag:
393+
for leaf in sub:
394+
if leaf.tag == tag_str and tag_str != "guest_flag" and tag_str != "pcpu_id" and\
395+
sub.tag != "vuart":
396+
tmp_tag = leaf.text
397+
continue
398+
return tmp_tag
399+
400+
366401
def get_leaf_tag_val(config_file, branch_tag, tag_str):
367402
"""
368403
This is get tag value by tag_str from config file
@@ -534,6 +569,18 @@ def vm_pre_launch_cnt(config_file):
534569
return pre_launch_cnt
535570

536571

572+
def handle_root_dev(line):
573+
"""Handle if it match root device information pattern
574+
:param line: one line of information which had decoded to 'ASCII'
575+
"""
576+
for root_type in line.split():
577+
# only support ext4 rootfs
578+
if "ext4" in root_type:
579+
return True
580+
581+
return False
582+
583+
537584
def get_max_clos(board_file):
538585
"""
539586
Parse CLOS information

misc/acrn-config/library/scenario_cfg_lib.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,19 @@ def get_rootdev_info(board_info):
137137
:return: root devices list
138138
"""
139139
rootdev_list = []
140-
rootdev_info = get_info(board_info, "<ROOT_DEVICE_INFO>", "</ROOT_DEVICE_INFO>")
140+
rootdev_info = get_info(board_info, "<BLOCK_DEVICE_INFO>", "</BLOCK_DEVICE_INFO>")
141+
142+
# none 'BLOCK_DEVICE_INFO' tag
143+
if rootdev_info == None:
144+
return rootdev_list
141145

142146
for rootdev_line in rootdev_info:
143147
if not rootdev_line:
144148
break
145149

150+
if not common.handle_root_dev(rootdev_line):
151+
continue
152+
146153
root_dev = rootdev_line.strip().split(':')[0]
147154
rootdev_list.append(root_dev)
148155

misc/acrn-config/scenario_config/vm_configurations_c.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def gen_sdc_source(vm_info, config):
218218
print("\t\t/* Allow SOS to reboot the host since " +
219219
"there is supposed to be the highest severity guest */", file=config)
220220
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
221-
if not vm_info.clos_set[0].strip():
221+
if vm_info.clos_set[0] == None or not vm_info.clos_set[0].strip():
222222
print("\t\t.clos = {0}U,".format(0), file=config)
223223
else:
224224
print("\t\t.clos = {0}U,".format(vm_info.clos_set[0]), file=config)
@@ -298,7 +298,7 @@ def gen_sdc2_source(vm_info, config):
298298
print("\t\t/* Allow SOS to reboot the host since " +
299299
"there is supposed to be the highest severity guest */", file=config)
300300
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
301-
if not vm_info.clos_set[0].strip():
301+
if vm_info.clos_set[0] == None or not vm_info.clos_set[0].strip():
302302
print("\t\t.clos = {0}U,".format(0), file=config)
303303
else:
304304
print("\t\t.clos = {0}U,".format(vm_info.clos_set[0]), file=config)
@@ -416,7 +416,7 @@ def gen_logical_partition_source(vm_info, config):
416416

417417
print("\t\t.guest_flags = {0},".format(guest_flags), file=config)
418418

419-
if not vm_info.clos_set[i].strip():
419+
if vm_info.clos_set[i] == None or not vm_info.clos_set[i].strip():
420420
print("\t\t.clos = {0}U,".format(0), file=config)
421421
else:
422422
print("\t\t.clos = {0}U,".format(vm_info.clos_set[i]), file=config)
@@ -475,7 +475,7 @@ def gen_industry_source(vm_info, config):
475475
return err_dic
476476
print("\t\t")
477477
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
478-
if not vm_info.clos_set[i].strip():
478+
if vm_info.clos_set[i] == None or not vm_info.clos_set[i].strip():
479479
print("\t\t.clos = {0}U,".format(0), file=config)
480480
else:
481481
print("\t\t.clos = {0}U,".format(vm_info.clos_set[i]), file=config)
@@ -541,7 +541,7 @@ def gen_hybrid_source(vm_info, config):
541541
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
542542
if i == 0:
543543
print("\t\t.pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP,", file=config)
544-
if not vm_info.clos_set[i].strip():
544+
if vm_info.clos_set[i] == None or not vm_info.clos_set[i].strip():
545545
print("\t\t.clos = {0}U,".format(0), file=config)
546546
else:
547547
print("\t\t.clos = {0}U,".format(vm_info.clos_set[i]), file=config)

misc/acrn-config/target/misc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ def dump_system_ram(config):
160160
print("", file=config)
161161

162162

163-
def dump_root_dev(config):
164-
"""This will get available root device
163+
def dump_block_dev(config):
164+
"""This will get available block device
165165
:param config: file pointer that opened for writing board config information
166166
"""
167167
cmd = 'blkid'
168-
desc = 'ROOT_DEVICE_INFO'
168+
desc = 'BLOCK_DEVICE_INFO'
169169
parser_lib.dump_execute(cmd, desc, config)
170170
print("", file=config)
171171

@@ -230,7 +230,7 @@ def generate_info(board_info):
230230

231231
dump_system_ram(config)
232232

233-
dump_root_dev(config)
233+
dump_block_dev(config)
234234

235235
dump_ttys(config)
236236

misc/acrn-config/target/parser_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def dump_execute(cmd, desc, config):
131131
if not ret:
132132
continue
133133

134-
if desc == "ROOT_DEVICE_INFO":
134+
if desc == "BLOCK_DEVICE_INFO":
135135
ret = handle_root_dev(line)
136136
if not ret:
137137
continue

misc/acrn-config/xmls/board-xmls/apl-mrb.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@
293293
100000000-27fffffff : System RAM
294294
</SYSTEM_RAM_INFO>
295295

296-
<ROOT_DEVICE_INFO>
296+
<BLOCK_DEVICE_INFO>
297297
/dev/mmcblk1p1: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4" PARTLABEL="sos_rootfs" PARTUUID="5bd5afa7-ab7e-46f3-85ad-0cfd285d5d76"
298298
/dev/mmcblk0p1: TYPE="ext4"
299299
/dev/sda3: TYPE="ext4"
300-
</ROOT_DEVICE_INFO>
300+
</BLOCK_DEVICE_INFO>
301301

302302
<TTYS_INFO>
303303
BDF:(00:18.0) seri:/dev/ttyS0 base:0xB3640000 irq:4

misc/acrn-config/xmls/board-xmls/apl-up2.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@
273273
100000000-17fffffff : System RAM
274274
</SYSTEM_RAM_INFO>
275275

276-
<ROOT_DEVICE_INFO>
276+
<BLOCK_DEVICE_INFO>
277277
/dev/mmcblk0p3: UUID="bb0d14f3-e780-41d9-bcca-6f3ef493216c" TYPE="ext4" PARTLABEL="primary" PARTUUID="87cd7180-6c0b-4bc9-a0d0-5406a95988cc"
278278
/dev/sda3: TYPE="ext4"
279-
</ROOT_DEVICE_INFO>
279+
</BLOCK_DEVICE_INFO>
280280

281281
<TTYS_INFO>
282282
BDF:(00:18.0) seri:/dev/ttyS0 base:0x91526000 irq:4

misc/acrn-config/xmls/board-xmls/nuc6cayh.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@
231231
100000000-27fffffff : System RAM
232232
</SYSTEM_RAM_INFO>
233233

234-
<ROOT_DEVICE_INFO>
234+
<BLOCK_DEVICE_INFO>
235235
/dev/sda3: LABEL="root" UUID="b8352fb7-25f5-481d-aa6f-015a7c76c5aa" TYPE="ext4" PARTLABEL="/" PARTUUID="9a305316-3c78-436c-9c21-3be1b324428d"
236-
</ROOT_DEVICE_INFO>
236+
</BLOCK_DEVICE_INFO>
237237

238238
<TTYS_INFO>
239239
BDF:(00:18.0) seri:/dev/ttyS0 base:0x91420000 irq:4

0 commit comments

Comments
 (0)