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>
This commit is contained in:
Wei Liu 2019-09-18 09:09:24 +08:00 committed by wenlingz
parent f50f92cc90
commit bc31dc0057
11 changed files with 104 additions and 41 deletions

View File

@ -169,8 +169,7 @@
readonly>{{sub_elem_text}}</textarea>
{% else %}
<textarea type="text" class="form-control" style="height:120px"
id="{{'vm:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}">
{{sub_elem_text}}</textarea>
id="{{'vm:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}">{{sub_elem_text}}</textarea>
{% endif %}
</div>
{% else %}

View File

@ -199,10 +199,20 @@ def get_rootfs(config_file):
:param config_file: it is a file which contain board information
:return: rootfs partition list
"""
rootfs_lines = get_info(config_file, "<ROOT_DEVICE_INFO>", "</ROOT_DEVICE_INFO>")
root_dev_list = []
rootfs_lines = get_info(config_file, "<BLOCK_DEVICE_INFO>", "</BLOCK_DEVICE_INFO>")
# none 'BLOCK_DEVICE_INFO' tag
if rootfs_lines == None:
return root_dev_list
for rootfs_line in rootfs_lines:
if not rootfs_line:
break
if not common.handle_root_dev(rootfs_line):
continue
root_dev = rootfs_line.strip().split(':')[0]
root_dev_list.append(root_dev)

View File

@ -285,9 +285,8 @@ def get_post_vm_count(config_file):
# get post vm number
root = get_config_root(config_file)
for item in root:
for sub in item:
if sub.tag == "load_order" and sub.text == "POST_LAUNCHED_VM":
post_vm_count += 1
if item.tag == "uos":
post_vm_count += 1
return post_vm_count
@ -307,22 +306,23 @@ def get_tree_tag_val(config_file, tag_str):
return False
def get_branch_tag(config_file, tag_str):
"""
This is get tag value by tag_str from config file
:param config_file: it is a file what contains information for script to read from
:param tag_str: it is key of pattern to config file item
:return: value of tag_str item list
"""
tmp_tag = []
root = get_config_root(config_file)
for item in root:
for sub in item:
if sub.tag == tag_str:
tmp_tag.append(sub.text)
return tmp_tag
#def get_spec_branch_tag(config_file, tag_str, p_id):
# """
# This is get tag value by tag_str from config file
# :param config_file: it is a file what contains information for script to read from
# :param tag_str: it is key of pattern to config file item
# :return: value of tag_str item list
# """
# tmp_tag = ''
# root = get_config_root(config_file)
# for item in root:
# if item.tag != 'vm' and item.attrib['id'] != str(p_id):
# continue
# for sub in item:
# if sub.tag == tag_str:
# tmp_tag = sub.text
#
# return tmp_tag
def get_branch_tag_val(config_file, tag_str):
@ -342,6 +342,25 @@ def get_branch_tag_val(config_file, tag_str):
return tmp_tag
def get_spec_branch_tag_val(config_file, tag_str, uos_id):
"""
This is get tag value by tag_str from config file
:param config_file: it is a file what contains information for script to read from
:param tag_str: it is key of pattern to config file item
:return: value of tag_str item list
"""
tmp_tag = ''
root = get_config_root(config_file)
for item in root:
if item.attrib['id'] != uos_id:
continue
for sub in item:
if sub.tag == tag_str:
tmp_tag = sub.text
return tmp_tag
def get_branch_tag_map(config_file, tag_str):
"""
This is get tag value by tag_str from config file
@ -363,6 +382,22 @@ def get_branch_tag_map(config_file, tag_str):
return tmp_tag
def get_spec_leaf_tag_val(config_file, branch_tag, tag_str, uos_id):
tmp_tag = ''
root = get_config_root(config_file)
for item in root:
if item.attrib['id'] != uos_id:
continue
for sub in item:
if sub.tag == branch_tag:
for leaf in sub:
if leaf.tag == tag_str and tag_str != "guest_flag" and tag_str != "pcpu_id" and\
sub.tag != "vuart":
tmp_tag = leaf.text
continue
return tmp_tag
def get_leaf_tag_val(config_file, branch_tag, tag_str):
"""
This is get tag value by tag_str from config file
@ -534,6 +569,18 @@ def vm_pre_launch_cnt(config_file):
return pre_launch_cnt
def handle_root_dev(line):
"""Handle if it match root device information pattern
:param line: one line of information which had decoded to 'ASCII'
"""
for root_type in line.split():
# only support ext4 rootfs
if "ext4" in root_type:
return True
return False
def get_max_clos(board_file):
"""
Parse CLOS information

View File

@ -137,12 +137,19 @@ def get_rootdev_info(board_info):
:return: root devices list
"""
rootdev_list = []
rootdev_info = get_info(board_info, "<ROOT_DEVICE_INFO>", "</ROOT_DEVICE_INFO>")
rootdev_info = get_info(board_info, "<BLOCK_DEVICE_INFO>", "</BLOCK_DEVICE_INFO>")
# none 'BLOCK_DEVICE_INFO' tag
if rootdev_info == None:
return rootdev_list
for rootdev_line in rootdev_info:
if not rootdev_line:
break
if not common.handle_root_dev(rootdev_line):
continue
root_dev = rootdev_line.strip().split(':')[0]
rootdev_list.append(root_dev)

View File

@ -218,7 +218,7 @@ def gen_sdc_source(vm_info, config):
print("\t\t/* Allow SOS to reboot the host since " +
"there is supposed to be the highest severity guest */", file=config)
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
if not vm_info.clos_set[0].strip():
if vm_info.clos_set[0] == None or not vm_info.clos_set[0].strip():
print("\t\t.clos = {0}U,".format(0), file=config)
else:
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):
print("\t\t/* Allow SOS to reboot the host since " +
"there is supposed to be the highest severity guest */", file=config)
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
if not vm_info.clos_set[0].strip():
if vm_info.clos_set[0] == None or not vm_info.clos_set[0].strip():
print("\t\t.clos = {0}U,".format(0), file=config)
else:
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):
print("\t\t.guest_flags = {0},".format(guest_flags), file=config)
if not vm_info.clos_set[i].strip():
if vm_info.clos_set[i] == None or not vm_info.clos_set[i].strip():
print("\t\t.clos = {0}U,".format(0), file=config)
else:
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):
return err_dic
print("\t\t")
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
if not vm_info.clos_set[i].strip():
if vm_info.clos_set[i] == None or not vm_info.clos_set[i].strip():
print("\t\t.clos = {0}U,".format(0), file=config)
else:
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):
print("\t\t.guest_flags = {0},".format(sos_guest_flags), file=config)
if i == 0:
print("\t\t.pcpu_bitmap = VM0_CONFIG_PCPU_BITMAP,", file=config)
if not vm_info.clos_set[i].strip():
if vm_info.clos_set[i] == None or not vm_info.clos_set[i].strip():
print("\t\t.clos = {0}U,".format(0), file=config)
else:
print("\t\t.clos = {0}U,".format(vm_info.clos_set[i]), file=config)

View File

@ -160,12 +160,12 @@ def dump_system_ram(config):
print("", file=config)
def dump_root_dev(config):
"""This will get available root device
def dump_block_dev(config):
"""This will get available block device
:param config: file pointer that opened for writing board config information
"""
cmd = 'blkid'
desc = 'ROOT_DEVICE_INFO'
desc = 'BLOCK_DEVICE_INFO'
parser_lib.dump_execute(cmd, desc, config)
print("", file=config)
@ -230,7 +230,7 @@ def generate_info(board_info):
dump_system_ram(config)
dump_root_dev(config)
dump_block_dev(config)
dump_ttys(config)

View File

@ -131,7 +131,7 @@ def dump_execute(cmd, desc, config):
if not ret:
continue
if desc == "ROOT_DEVICE_INFO":
if desc == "BLOCK_DEVICE_INFO":
ret = handle_root_dev(line)
if not ret:
continue

View File

@ -293,11 +293,11 @@
100000000-27fffffff : System RAM
</SYSTEM_RAM_INFO>
<ROOT_DEVICE_INFO>
<BLOCK_DEVICE_INFO>
/dev/mmcblk1p1: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4" PARTLABEL="sos_rootfs" PARTUUID="5bd5afa7-ab7e-46f3-85ad-0cfd285d5d76"
/dev/mmcblk0p1: TYPE="ext4"
/dev/sda3: TYPE="ext4"
</ROOT_DEVICE_INFO>
</BLOCK_DEVICE_INFO>
<TTYS_INFO>
BDF:(00:18.0) seri:/dev/ttyS0 base:0xB3640000 irq:4

View File

@ -273,10 +273,10 @@
100000000-17fffffff : System RAM
</SYSTEM_RAM_INFO>
<ROOT_DEVICE_INFO>
<BLOCK_DEVICE_INFO>
/dev/mmcblk0p3: UUID="bb0d14f3-e780-41d9-bcca-6f3ef493216c" TYPE="ext4" PARTLABEL="primary" PARTUUID="87cd7180-6c0b-4bc9-a0d0-5406a95988cc"
/dev/sda3: TYPE="ext4"
</ROOT_DEVICE_INFO>
</BLOCK_DEVICE_INFO>
<TTYS_INFO>
BDF:(00:18.0) seri:/dev/ttyS0 base:0x91526000 irq:4

View File

@ -231,9 +231,9 @@
100000000-27fffffff : System RAM
</SYSTEM_RAM_INFO>
<ROOT_DEVICE_INFO>
<BLOCK_DEVICE_INFO>
/dev/sda3: LABEL="root" UUID="b8352fb7-25f5-481d-aa6f-015a7c76c5aa" TYPE="ext4" PARTLABEL="/" PARTUUID="9a305316-3c78-436c-9c21-3be1b324428d"
</ROOT_DEVICE_INFO>
</BLOCK_DEVICE_INFO>
<TTYS_INFO>
BDF:(00:18.0) seri:/dev/ttyS0 base:0x91420000 irq:4

View File

@ -225,10 +225,10 @@
100000000-2707fffff : System RAM
</SYSTEM_RAM_INFO>
<ROOT_DEVICE_INFO>
<BLOCK_DEVICE_INFO>
/dev/nvme0n1p3: LABEL="root" UUID="deb9eba1-9ab6-4d1e-95b9-aa1d2f7b660e" TYPE="ext4" PARTLABEL="/" PARTUUID="80521cfb-cce4-4ccc-8cf8-46a045196c73"
/dev/sda3: TYPE="ext4"
</ROOT_DEVICE_INFO>
</BLOCK_DEVICE_INFO>
<TTYS_INFO>
BDF:(02:00.0) seri:/dev/ttyS0 base:0x3F8 irq:4