mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-18 19:57:31 +00:00
acrn-config: expends parameters and functions to common lib
For purpose to refine the library/common and xx_cfg_lib, should have to expands parameters and functions to common.py firstly. Tracked-On: #3854 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>
This commit is contained in:
parent
2d66d39529
commit
78ce220eb9
@ -13,6 +13,7 @@ import pci_devices_h
|
||||
import acpi_platform_h
|
||||
import misc_cfg_h
|
||||
import new_board_kconfig
|
||||
import common
|
||||
|
||||
ACRN_PATH = board_cfg_lib.SOURCE_ROOT_DIR
|
||||
ACRN_CONFIG_TARGET = ACRN_PATH + "hypervisor/arch/x86/configs/"
|
||||
@ -41,9 +42,12 @@ def main(args):
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
common.BOARD_INFO_FILE = board_info_file
|
||||
common.SCENARIO_INFO_FILE = scenario_info_file
|
||||
common.get_vm_num(scenario_info_file)
|
||||
board_cfg_lib.BOARD_INFO_FILE = board_info_file
|
||||
board_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file
|
||||
board_cfg_lib.get_vm_count(scenario_info_file)
|
||||
board_cfg_lib.get_vm_num(scenario_info_file)
|
||||
|
||||
# get board name
|
||||
(err_dic, board) = board_cfg_lib.get_board_name()
|
||||
|
@ -9,6 +9,7 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '
|
||||
from launch_item import AvailablePthru, PthruSelected, VirtioDeviceSelect, AcrnDmArgs
|
||||
import launch_cfg_lib
|
||||
import com
|
||||
import common
|
||||
|
||||
ACRN_PATH = launch_cfg_lib.SOURCE_ROOT_DIR
|
||||
ACRN_CONFIG_TARGET = ACRN_PATH + '/misc/acrn-config/xmls/config-xmls/'
|
||||
@ -60,6 +61,9 @@ def validate_launch_setting(board_info, scenario_info, launch_info):
|
||||
:return: return a dictionary contain errors
|
||||
"""
|
||||
launch_cfg_lib.ERR_LIST = {}
|
||||
common.BOARD_INFO_FILE = board_info
|
||||
common.SCENARIO_INFO_FILE = scenario_info
|
||||
common.LAUNCH_INFO_FILE = launch_info
|
||||
launch_cfg_lib.BOARD_INFO_FILE = board_info
|
||||
launch_cfg_lib.SCENARIO_INFO_FILE = scenario_info
|
||||
launch_cfg_lib.LAUNCH_INFO_FILE = launch_info
|
||||
@ -161,6 +165,9 @@ def main(args):
|
||||
# 1: generate launch script for 1st post vm launch script
|
||||
# 2: generate launch script for 2nd post vm launch script
|
||||
|
||||
common.BOARD_INFO_FILE = board_info_file
|
||||
common.SCENARIO_INFO_FILE = scenario_info_file
|
||||
common.LAUNCH_INFO_FILE = launch_info_file
|
||||
launch_cfg_lib.BOARD_INFO_FILE = board_info_file
|
||||
launch_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file
|
||||
launch_cfg_lib.LAUNCH_INFO_FILE = launch_info_file
|
||||
|
@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import board_cfg_lib
|
||||
import launch_cfg_lib
|
||||
|
||||
class AcrnDmArgs:
|
||||
@ -26,7 +27,7 @@ class AcrnDmArgs:
|
||||
self.args["xhci"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "usb_xhci")
|
||||
|
||||
def check_item(self):
|
||||
rootfs = launch_cfg_lib.get_rootdev_info(self.board_info)
|
||||
rootfs = board_cfg_lib.get_rootfs(self.board_info)
|
||||
launch_cfg_lib.args_aval_check(self.args["uos_type"], "uos_type", launch_cfg_lib.UOS_TYPES)
|
||||
launch_cfg_lib.args_aval_check(self.args["rtos_type"], "rtos_type", launch_cfg_lib.RTOS_TYPE)
|
||||
launch_cfg_lib.mem_size_check(self.args["mem_size"], "mem_size")
|
||||
|
@ -3,10 +3,11 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import re
|
||||
import sys
|
||||
import common
|
||||
|
||||
SOURCE_ROOT_DIR = common.SOURCE_PATH
|
||||
SOURCE_ROOT_DIR = common.SOURCE_ROOT_DIR
|
||||
BOARD_NAME = ''
|
||||
BOARD_INFO_FILE = "board_info.txt"
|
||||
SCENARIO_INFO_FILE = ""
|
||||
@ -47,7 +48,7 @@ SIZE_G = common.SIZE_G
|
||||
|
||||
def prepare():
|
||||
""" check environment """
|
||||
return common.check_env()
|
||||
return common.prepare()
|
||||
|
||||
|
||||
def print_yel(msg, warn=False):
|
||||
@ -56,7 +57,7 @@ def print_yel(msg, warn=False):
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
:param warn: the condition if needs to be output the color of yellow with 'Warning'
|
||||
"""
|
||||
common.print_if_yel(msg, warn)
|
||||
common.print_yel(msg, warn)
|
||||
|
||||
|
||||
def print_red(msg, err=False):
|
||||
@ -65,7 +66,7 @@ def print_red(msg, err=False):
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
:param err: the condition if needs to be output the color of red with 'Error'
|
||||
"""
|
||||
common.print_if_red(msg, err)
|
||||
common.print_red(msg, err)
|
||||
|
||||
|
||||
def get_board_name():
|
||||
@ -73,8 +74,7 @@ def get_board_name():
|
||||
Get board name from board.xml at fist line
|
||||
:param board_info: it is a file what contains board information for script to read from
|
||||
"""
|
||||
(err_dic, board) = common.get_xml_attrib(BOARD_INFO_FILE, "board")
|
||||
return (err_dic, board)
|
||||
return common.get_board_name()
|
||||
|
||||
|
||||
def get_scenario_name():
|
||||
@ -82,19 +82,12 @@ def get_scenario_name():
|
||||
Get scenario name from scenario.xml at fist line
|
||||
:param scenario_info: it is a file what contains board information for script to read from
|
||||
"""
|
||||
(err_dic, scenario) = common.get_xml_attrib(SCENARIO_INFO_FILE, "scenario")
|
||||
return (err_dic, scenario)
|
||||
return common.get_scenario_name()
|
||||
|
||||
|
||||
def is_config_file_match():
|
||||
|
||||
(err_dic, scenario_for_board) = common.get_xml_attrib(SCENARIO_INFO_FILE, "board")
|
||||
(err_dic, board_name) = common.get_xml_attrib(BOARD_INFO_FILE, "board")
|
||||
|
||||
if scenario_for_board == board_name:
|
||||
return (err_dic, True)
|
||||
else:
|
||||
return (err_dic, False)
|
||||
return common.is_config_file_match()
|
||||
|
||||
|
||||
def usage(file_name):
|
||||
@ -117,8 +110,34 @@ def get_info(board_info, msg_s, msg_e):
|
||||
:param msg_s: it is a pattern of key stings what start to match from board information
|
||||
:param msg_e: it is a pattern of key stings what end to match from board information
|
||||
"""
|
||||
info_lines = common.get_board_info(board_info, msg_s, msg_e)
|
||||
return info_lines
|
||||
info_start = False
|
||||
info_end = False
|
||||
info_lines = []
|
||||
num = len(msg_s.split())
|
||||
|
||||
with open(board_info, 'rt') as f_board:
|
||||
while True:
|
||||
|
||||
line = f_board.readline()
|
||||
if not line:
|
||||
break
|
||||
|
||||
if " ".join(line.split()[0:num]) == msg_s:
|
||||
info_start = True
|
||||
info_end = False
|
||||
continue
|
||||
|
||||
if " ".join(line.split()[0:num]) == msg_e:
|
||||
info_start = False
|
||||
info_end = True
|
||||
continue
|
||||
|
||||
if info_start and not info_end:
|
||||
info_lines.append(line)
|
||||
continue
|
||||
|
||||
if not info_start and info_end:
|
||||
return info_lines
|
||||
|
||||
|
||||
def handle_bios_info(config):
|
||||
@ -156,17 +175,44 @@ def handle_bios_info(config):
|
||||
print(" */", file=config)
|
||||
|
||||
|
||||
def get_tree_tag(config_file, tag_str):
|
||||
def handle_root_dev(line):
|
||||
"""Handle if it match root device information pattern
|
||||
:param line: one line of information which had decoded to 'ASCII'
|
||||
"""
|
||||
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
|
||||
"""
|
||||
return common.get_tree_tag_val(config_file, tag_str)
|
||||
for root_type in line.split():
|
||||
# only support ext4 rootfs
|
||||
if "ext4" in root_type:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def get_sub_leaf_tag(config_file, branch_tag, tag_str):
|
||||
def get_max_clos_mask(board_file):
|
||||
"""
|
||||
Parse CLOS information
|
||||
:param board_file: it is a file what contains board information for script to read from
|
||||
:return: type of rdt resource supported and their corresponding clos max.
|
||||
"""
|
||||
rdt_res=[]
|
||||
rdt_res_clos_max=[]
|
||||
rdt_res_mask_max=[]
|
||||
|
||||
clos_lines = get_info(board_file, "<CLOS_INFO>", "</CLOS_INFO>")
|
||||
for line in clos_lines:
|
||||
if line.split(':')[0].strip() == "rdt resources supported":
|
||||
rdt_res = line.split(':')[1].strip()
|
||||
elif line.split(':')[0].strip() == "rdt resource clos max":
|
||||
rdt_res_clos_max = line.split(':')[1].strip()
|
||||
elif line.split(':')[0].strip() == "rdt resource mask max":
|
||||
rdt_res_mask_max = line.split(':')[1].strip()
|
||||
|
||||
if (len(rdt_res) == 0) or (len(rdt_res_clos_max) == 0):
|
||||
return rdt_res, rdt_res_clos_max, rdt_res_mask_max
|
||||
else:
|
||||
return list(re.split(', |\s |,', rdt_res)), list(map(int, rdt_res_clos_max.split(','))), list(re.split(', |\s |,', rdt_res_mask_max))
|
||||
|
||||
|
||||
def get_sub_leaf_tag(config_file, branch_tag, 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
|
||||
@ -174,17 +220,7 @@ def get_sub_leaf_tag(config_file, branch_tag, tag_str):
|
||||
:param tag_str: it is key of pattern to config file leaf tag item
|
||||
:return: value of tag_str item
|
||||
"""
|
||||
return common.get_leaf_tag_val(config_file, branch_tag, tag_str)
|
||||
|
||||
|
||||
def is_hpa_size(hpa_size_list):
|
||||
"""
|
||||
This is identify if the host physical size list is correct format
|
||||
:param hpa_size_list: host physical size list
|
||||
:return: True if good format
|
||||
"""
|
||||
ret = common.check_hpa_size(hpa_size_list)
|
||||
return ret
|
||||
return common.get_sub_leaf_tag(config_file, branch_tag, tag_str)
|
||||
|
||||
|
||||
def get_rootfs(config_file):
|
||||
@ -204,7 +240,7 @@ def get_rootfs(config_file):
|
||||
if not rootfs_line:
|
||||
break
|
||||
|
||||
if not common.handle_root_dev(rootfs_line):
|
||||
if not handle_root_dev(rootfs_line):
|
||||
continue
|
||||
|
||||
root_dev = rootfs_line.strip().split(':')[0]
|
||||
@ -215,27 +251,17 @@ def get_rootfs(config_file):
|
||||
|
||||
def clos_info_parser(board_info):
|
||||
""" Parse CLOS information """
|
||||
return common.get_max_clos_mask(board_info)
|
||||
return get_max_clos_mask(board_info)
|
||||
|
||||
|
||||
def get_pre_launch_cnt(config_file):
|
||||
"""
|
||||
This is get pre launched vm count
|
||||
:param config_file: it is a file what contains vm information for script to read from
|
||||
:return: number of per launched vm
|
||||
"""
|
||||
pre_launch_cnt = common.vm_pre_launch_cnt(config_file)
|
||||
return pre_launch_cnt
|
||||
|
||||
|
||||
def get_vm_count(config_file):
|
||||
def get_vm_num(config_file):
|
||||
"""
|
||||
This is get vm count
|
||||
:param config_file: it is a file what contains vm information for script to read from
|
||||
:return: number of vm
|
||||
"""
|
||||
global VM_COUNT
|
||||
VM_COUNT = common.get_vm_count(config_file)
|
||||
VM_COUNT = common.get_vm_num(config_file)
|
||||
|
||||
|
||||
def get_order_type_by_vmid(idx):
|
||||
@ -383,6 +409,29 @@ def get_board_private_vuart(branch_tag, tag_console):
|
||||
return (err_dic, vuart0_console_dic, vuart1_console_dic)
|
||||
|
||||
|
||||
def get_vuart_id(tmp_vuart, leaf_tag, leaf_text):
|
||||
"""
|
||||
Get all vuart id member of class
|
||||
:param tmp_vuart: a dictionary to store member:value
|
||||
:param leaf_tag: key pattern of item tag
|
||||
:param leaf_text: key pattern of item tag's value
|
||||
:return: a dictionary to which stored member:value
|
||||
"""
|
||||
if leaf_tag == "type":
|
||||
tmp_vuart['type'] = leaf_text
|
||||
if leaf_tag == "base":
|
||||
tmp_vuart['base'] = leaf_text
|
||||
if leaf_tag == "irq":
|
||||
tmp_vuart['irq'] = leaf_text
|
||||
|
||||
if leaf_tag == "target_vm_id":
|
||||
tmp_vuart['target_vm_id'] = leaf_text
|
||||
if leaf_tag == "target_uart_id":
|
||||
tmp_vuart['target_uart_id'] = leaf_text
|
||||
|
||||
return tmp_vuart
|
||||
|
||||
|
||||
def get_vuart_info_id(config_file, idx):
|
||||
"""
|
||||
Get vuart information by vuart id indexx
|
||||
@ -390,7 +439,23 @@ def get_vuart_info_id(config_file, idx):
|
||||
:param idx: vuart index in range: [0,1]
|
||||
:return: dictionary which stored the vuart-id
|
||||
"""
|
||||
tmp_tag = common.get_vuart_info_id(config_file, idx)
|
||||
tmp_tag = {}
|
||||
vm_id = 0
|
||||
root = common.get_config_root(config_file)
|
||||
for item in root:
|
||||
for sub in item:
|
||||
tmp_vuart = {}
|
||||
for leaf in sub:
|
||||
if sub.tag == "vuart" and int(sub.attrib['id']) == idx:
|
||||
tmp_vuart = get_vuart_id(tmp_vuart, leaf.tag, leaf.text)
|
||||
|
||||
# append vuart for each vm
|
||||
if tmp_vuart and sub.tag == "vuart":
|
||||
tmp_tag[vm_id] = tmp_vuart
|
||||
|
||||
if item.tag == "vm":
|
||||
vm_id += 1
|
||||
|
||||
return tmp_tag
|
||||
|
||||
|
||||
@ -421,6 +486,100 @@ def get_processor_info():
|
||||
return tmp_list
|
||||
|
||||
|
||||
def get_ttys_info(board_info):
|
||||
"""
|
||||
Get ttySn from board info
|
||||
:param board_info: it is a file what contains board information for script to read from
|
||||
:return: serial console list
|
||||
"""
|
||||
ttys_list = []
|
||||
ttys_info = get_info(board_info, "<TTYS_INFO>", "</TTYS_INFO>")
|
||||
|
||||
for ttys_line in ttys_info:
|
||||
if not ttys_line:
|
||||
break
|
||||
|
||||
ttys_dev = ttys_line.split()[0].split(':')[1]
|
||||
ttysn = ttys_dev.split('/')[-1]
|
||||
# currently SOS console can only support legacy serial port
|
||||
if ttysn not in list(LEGACY_TTYS.keys()):
|
||||
continue
|
||||
ttys_list.append(ttys_dev)
|
||||
|
||||
return ttys_list
|
||||
|
||||
def get_total_mem():
|
||||
"""
|
||||
get total memory size from config file which is dumped from native board
|
||||
:return: integer number of total memory size, Unit: MByte
|
||||
"""
|
||||
scale_to_mb = 1
|
||||
total_mem_mb = scale_to_mb
|
||||
mem_lines = get_info(common.BOARD_INFO_FILE, "<TOTAL_MEM_INFO>", "</TOTAL_MEM_INFO>")
|
||||
for mem_line in mem_lines:
|
||||
mem_info_list = mem_line.split()
|
||||
|
||||
if len(mem_info_list) <= 1:
|
||||
return total_mem_mb
|
||||
|
||||
if mem_info_list[1] == "kB":
|
||||
scale_to_mb = 1024
|
||||
|
||||
total_mem_mb = int(mem_info_list[0]) / scale_to_mb
|
||||
return total_mem_mb
|
||||
|
||||
|
||||
def get_pci_info(board_info):
|
||||
pci_bdf_vpid = {}
|
||||
pci_vid_start = False
|
||||
pci_vid_end = False
|
||||
pci_desc = {}
|
||||
pci_start = False
|
||||
pci_end = False
|
||||
|
||||
with open(board_info, 'r') as f:
|
||||
while True:
|
||||
line = f.readline()
|
||||
if not line:
|
||||
break
|
||||
|
||||
s = " "
|
||||
if s.join(line.split()[0:2]) == "<PCI_DEVICE>":
|
||||
pci_start = True
|
||||
pci_end = False
|
||||
continue
|
||||
|
||||
if s.join(line.split()[0:2]) == "</PCI_DEVICE>":
|
||||
pci_start = False
|
||||
pci_end = True
|
||||
continue
|
||||
|
||||
# all pci device wiht description
|
||||
if pci_start and not pci_end:
|
||||
if "Region" in line and "Memory at" in line:
|
||||
continue
|
||||
bdf = line.split()[0]
|
||||
pci_desc[bdf] = line
|
||||
|
||||
if s.join(line.split()[0:2]) == "<PCI_VID_PID>":
|
||||
pci_vid_start = True
|
||||
pci_vid_end = False
|
||||
continue
|
||||
|
||||
if s.join(line.split()[0:2]) == "</PCI_VID_PID>":
|
||||
pci_vid_start = False
|
||||
pci_vid_end = True
|
||||
continue
|
||||
|
||||
# all pci device with vid/pid and bdf
|
||||
if pci_vid_start and not pci_vid_end:
|
||||
bdf_str = line.split()[0]
|
||||
vid_pid = line.split()[2]
|
||||
pci_bdf_vpid[bdf_str] = vid_pid
|
||||
|
||||
return (pci_desc, pci_bdf_vpid)
|
||||
|
||||
|
||||
def undline_name(name):
|
||||
"""
|
||||
This convert name which has contain '-' to '_'
|
||||
|
@ -8,20 +8,15 @@ import sys
|
||||
import getopt
|
||||
import shutil
|
||||
import subprocess
|
||||
import re
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
SOURCE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../')
|
||||
HV_LICENSE_FILE = SOURCE_PATH + 'misc/acrn-config/library/hypervisor_license'
|
||||
SOURCE_ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../')
|
||||
HV_LICENSE_FILE = SOURCE_ROOT_DIR + 'misc/acrn-config/library/hypervisor_license'
|
||||
|
||||
|
||||
PY_CACHES = ["__pycache__", "../board_config/__pycache__", "../scenario_config/__pycache__"]
|
||||
GUEST_FLAG = ["0UL", "GUEST_FLAG_SECURE_WORLD_ENABLED", "GUEST_FLAG_LAPIC_PASSTHROUGH",
|
||||
"GUEST_FLAG_IO_COMPLETION_POLLING", "GUEST_FLAG_HIDE_MTRR", "GUEST_FLAG_RT"]
|
||||
# Support 512M, 1G, 2G
|
||||
# pre launch less then 2G, sos vm less than 24G
|
||||
START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE']
|
||||
|
||||
|
||||
MULTI_ITEM = ["guest_flag", "pcpu_id", "vcpu_clos", "input", "block", "network"]
|
||||
|
||||
@ -31,6 +26,11 @@ SIZE_2G = 2 * SIZE_M * SIZE_K
|
||||
SIZE_4G = 2 * SIZE_2G
|
||||
SIZE_G = SIZE_M * 1024
|
||||
|
||||
VM_COUNT = 0
|
||||
BOARD_INFO_FILE = ""
|
||||
SCENARIO_INFO_FILE = ""
|
||||
LAUNCH_INFO_FILE = ""
|
||||
|
||||
class MultiItem():
|
||||
|
||||
def __init__(self):
|
||||
@ -55,7 +55,7 @@ def open_license():
|
||||
return license_s
|
||||
|
||||
|
||||
def print_if_yel(msg, warn=False):
|
||||
def print_yel(msg, warn=False):
|
||||
"""
|
||||
Print the message with 'Warning' if warn is true
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
@ -67,7 +67,7 @@ def print_if_yel(msg, warn=False):
|
||||
print("\033[1;33m{0}\033[0m".format(msg))
|
||||
|
||||
|
||||
def print_if_red(msg, err=False):
|
||||
def print_red(msg, err=False):
|
||||
"""
|
||||
Print the message with 'Error' if err is true
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
@ -129,7 +129,7 @@ def get_param(args):
|
||||
return (err_dic, board_info_file, scenario_info_file, output_folder)
|
||||
|
||||
|
||||
def check_env():
|
||||
def prepare():
|
||||
""" Prepare to check the environment """
|
||||
err_dic = {}
|
||||
bin_list = []
|
||||
@ -149,22 +149,6 @@ def check_env():
|
||||
|
||||
return err_dic
|
||||
|
||||
def check_hpa_size(hpa_size_list):
|
||||
"""
|
||||
This is identify if the host physical size list is correct format
|
||||
:param hpa_size_list: host physical size list
|
||||
:return: True if good format
|
||||
"""
|
||||
for hpa_size in hpa_size_list:
|
||||
hpa_sz_strip_ul = hpa_size.strip('UL')
|
||||
hpa_sz_strip_u = hpa_size.strip('U')
|
||||
if hpa_sz_strip_u not in START_HPA_SIZE_LIST and hpa_sz_strip_ul not in START_HPA_SIZE_LIST:
|
||||
if '0x' not in hpa_size and '0X' not in hpa_size:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_xml_attrib(config_file, attrib):
|
||||
"""
|
||||
Get attribute from xml at fist line
|
||||
@ -193,41 +177,33 @@ def get_xml_attrib(config_file, attrib):
|
||||
return (err_dic, value)
|
||||
|
||||
|
||||
def get_board_info(board_info, msg_s, msg_e):
|
||||
def get_board_name():
|
||||
"""
|
||||
Get information which specify by argument
|
||||
Get board name from board.xml at fist line
|
||||
:param board_info: it is a file what contains board information for script to read from
|
||||
:param msg_s: it is a pattern of key stings what start to match from board information
|
||||
:param msg_e: it is a pattern of key stings what end to match from board information
|
||||
"""
|
||||
info_start = False
|
||||
info_end = False
|
||||
info_lines = []
|
||||
num = len(msg_s.split())
|
||||
(err_dic, board) = get_xml_attrib(BOARD_INFO_FILE, "board")
|
||||
return (err_dic, board)
|
||||
|
||||
with open(board_info, 'rt') as f_board:
|
||||
while True:
|
||||
|
||||
line = f_board.readline()
|
||||
if not line:
|
||||
break
|
||||
def get_scenario_name():
|
||||
"""
|
||||
Get scenario name from scenario.xml at fist line
|
||||
:param scenario_info: it is a file what contains board information for script to read from
|
||||
"""
|
||||
(err_dic, scenario) = get_xml_attrib(SCENARIO_INFO_FILE, "scenario")
|
||||
return (err_dic, scenario)
|
||||
|
||||
if " ".join(line.split()[0:num]) == msg_s:
|
||||
info_start = True
|
||||
info_end = False
|
||||
continue
|
||||
|
||||
if " ".join(line.split()[0:num]) == msg_e:
|
||||
info_start = False
|
||||
info_end = True
|
||||
continue
|
||||
def is_config_file_match():
|
||||
|
||||
if info_start and not info_end:
|
||||
info_lines.append(line)
|
||||
continue
|
||||
(err_dic, scenario_for_board) = get_xml_attrib(SCENARIO_INFO_FILE, "board")
|
||||
(err_dic, board_name) = get_xml_attrib(BOARD_INFO_FILE, "board")
|
||||
|
||||
if not info_start and info_end:
|
||||
return info_lines
|
||||
if scenario_for_board == board_name:
|
||||
return (err_dic, True)
|
||||
else:
|
||||
return (err_dic, False)
|
||||
|
||||
|
||||
def find_index_guest_flag(flag):
|
||||
@ -276,7 +252,7 @@ def get_config_root(config_file):
|
||||
return root
|
||||
|
||||
|
||||
def get_vm_count(config_file):
|
||||
def get_vm_num(config_file):
|
||||
"""
|
||||
Get vm number
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
@ -288,61 +264,12 @@ def get_vm_count(config_file):
|
||||
# vm number in scenario
|
||||
if item.tag == "vm":
|
||||
vm_count += 1
|
||||
|
||||
VM_COUNT = vm_count
|
||||
return vm_count
|
||||
|
||||
|
||||
def launch_vm_cnt(config_file):
|
||||
"""
|
||||
Get post vm number
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:return: total post vm number in launch file
|
||||
"""
|
||||
post_vm_count = 0
|
||||
|
||||
# get post vm number
|
||||
root = get_config_root(config_file)
|
||||
for item in root:
|
||||
if item.tag == "uos":
|
||||
post_vm_count += 1
|
||||
|
||||
return post_vm_count
|
||||
|
||||
|
||||
def get_post_num_list(config_file):
|
||||
"""
|
||||
Get post vm number list
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:return: total post dic: {launch_id:scenario_id} in launch file
|
||||
"""
|
||||
post_vm_list = []
|
||||
|
||||
# get post vm number
|
||||
root = get_config_root(config_file)
|
||||
for item in root:
|
||||
if item.tag == "uos":
|
||||
post_vm_list.append(int(item.attrib['id']))
|
||||
|
||||
return post_vm_list
|
||||
|
||||
|
||||
def get_tree_tag_val(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
|
||||
"""
|
||||
root = get_config_root(config_file)
|
||||
for item in root:
|
||||
if item.tag == tag_str:
|
||||
return item.text
|
||||
|
||||
return False
|
||||
|
||||
|
||||
# TODO: This will be abandonment in future
|
||||
def get_leaf_tag_val(config_file, branch_tag, tag_str=''):
|
||||
def get_sub_leaf_tag(config_file, branch_tag, 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
|
||||
@ -500,7 +427,7 @@ def order_type_map_vmid(config_file, vm_count):
|
||||
:return: table of id:order type dictionary
|
||||
"""
|
||||
order_id_dic = {}
|
||||
load_type_list = get_leaf_tag_val(config_file, "load_order")
|
||||
load_type_list = get_sub_leaf_tag(config_file, "load_order")
|
||||
for i in range(vm_count):
|
||||
order_id_dic[i] = load_type_list[i]
|
||||
|
||||
@ -523,75 +450,6 @@ def get_load_order_by_vmid(config_file, vm_count, idx):
|
||||
return (err_dic, order_id_dic[idx])
|
||||
|
||||
|
||||
def vm_pre_launch_cnt(config_file):
|
||||
"""
|
||||
Calculate the pre launched vm number
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:return: number of pre launched vm
|
||||
"""
|
||||
pre_launch_cnt = 0
|
||||
load_type_list = get_leaf_tag_val(config_file, "load_order")
|
||||
|
||||
for vm_type in load_type_list:
|
||||
if vm_type == "PRE_LAUNCHED_VM":
|
||||
pre_launch_cnt += 1
|
||||
|
||||
return pre_launch_cnt
|
||||
|
||||
|
||||
def post_vm_cnt(config_file):
|
||||
"""
|
||||
Calculate the pre launched vm number
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:return: number of post launched vm
|
||||
"""
|
||||
post_launch_cnt = 0
|
||||
load_type_list = get_leaf_tag_val(config_file, "load_order")
|
||||
|
||||
for vm_type in load_type_list:
|
||||
if vm_type == "POST_LAUNCHED_VM":
|
||||
post_launch_cnt += 1
|
||||
|
||||
return post_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_mask(board_file):
|
||||
"""
|
||||
Parse CLOS information
|
||||
:param board_file: it is a file what contains board information for script to read from
|
||||
:return: type of rdt resource supported and their corresponding clos max.
|
||||
"""
|
||||
rdt_res=[]
|
||||
rdt_res_clos_max=[]
|
||||
rdt_res_mask_max=[]
|
||||
|
||||
clos_lines = get_board_info(board_file, "<CLOS_INFO>", "</CLOS_INFO>")
|
||||
for line in clos_lines:
|
||||
if line.split(':')[0].strip() == "rdt resources supported":
|
||||
rdt_res = line.split(':')[1].strip()
|
||||
elif line.split(':')[0].strip() == "rdt resource clos max":
|
||||
rdt_res_clos_max = line.split(':')[1].strip()
|
||||
elif line.split(':')[0].strip() == "rdt resource mask max":
|
||||
rdt_res_mask_max = line.split(':')[1].strip()
|
||||
|
||||
if (len(rdt_res) == 0) or (len(rdt_res_clos_max) == 0):
|
||||
return rdt_res, rdt_res_clos_max, rdt_res_mask_max
|
||||
else:
|
||||
return list(re.split(', |\s |,', rdt_res)), list(map(int, rdt_res_clos_max.split(','))), list(re.split(', |\s |,', rdt_res_mask_max))
|
||||
|
||||
|
||||
def undline_name(name):
|
||||
"""
|
||||
This convert name which has contain '-' to '_'
|
||||
@ -608,56 +466,6 @@ def undline_name(name):
|
||||
return name_str
|
||||
|
||||
|
||||
def get_vuart_id(tmp_vuart, leaf_tag, leaf_text):
|
||||
"""
|
||||
Get all vuart id member of class
|
||||
:param tmp_vuart: a dictionary to store member:value
|
||||
:param leaf_tag: key pattern of item tag
|
||||
:param leaf_text: key pattern of item tag's value
|
||||
:return: a dictionary to which stored member:value
|
||||
"""
|
||||
if leaf_tag == "type":
|
||||
tmp_vuart['type'] = leaf_text
|
||||
if leaf_tag == "base":
|
||||
tmp_vuart['base'] = leaf_text
|
||||
if leaf_tag == "irq":
|
||||
tmp_vuart['irq'] = leaf_text
|
||||
|
||||
if leaf_tag == "target_vm_id":
|
||||
tmp_vuart['target_vm_id'] = leaf_text
|
||||
if leaf_tag == "target_uart_id":
|
||||
tmp_vuart['target_uart_id'] = leaf_text
|
||||
|
||||
return tmp_vuart
|
||||
|
||||
|
||||
def get_vuart_info_id(config_file, idx):
|
||||
"""
|
||||
Get vuart information by vuart id indexx
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:param idx: vuart index in range: [0,1]
|
||||
:return: dictionary which stored the vuart-id
|
||||
"""
|
||||
tmp_tag = {}
|
||||
vm_id = 0
|
||||
root = get_config_root(config_file)
|
||||
for item in root:
|
||||
for sub in item:
|
||||
tmp_vuart = {}
|
||||
for leaf in sub:
|
||||
if sub.tag == "vuart" and int(sub.attrib['id']) == idx:
|
||||
tmp_vuart = get_vuart_id(tmp_vuart, leaf.tag, leaf.text)
|
||||
|
||||
# append vuart for each vm
|
||||
if tmp_vuart and sub.tag == "vuart":
|
||||
tmp_tag[vm_id] = tmp_vuart
|
||||
|
||||
if item.tag == "vm":
|
||||
vm_id += 1
|
||||
|
||||
return tmp_tag
|
||||
|
||||
|
||||
def round_up(addr, mem_align):
|
||||
"""Keep memory align"""
|
||||
return ((addr + (mem_align - 1)) & (~(mem_align - 1)))
|
||||
@ -669,4 +477,4 @@ def mkdir(path):
|
||||
try:
|
||||
subprocess.check_call('mkdir -p {}'.format(path), shell=True, stdout=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError:
|
||||
print_if_red("{} file create failed!".format(path), err=True)
|
||||
print_red("{} file create failed!".format(path), err=True)
|
||||
|
@ -6,8 +6,9 @@
|
||||
import os
|
||||
import getopt
|
||||
import common
|
||||
import board_cfg_lib
|
||||
|
||||
SOURCE_ROOT_DIR = common.SOURCE_PATH
|
||||
SOURCE_ROOT_DIR = common.SOURCE_ROOT_DIR
|
||||
BOARD_INFO_FILE = "board_info.txt"
|
||||
SCENARIO_INFO_FILE = ""
|
||||
LAUNCH_INFO_FILE = ""
|
||||
@ -62,7 +63,7 @@ MOUNT_FLAG_DIC = {}
|
||||
|
||||
def prepare():
|
||||
""" Check environment """
|
||||
return common.check_env()
|
||||
return common.prepare()
|
||||
|
||||
|
||||
def print_yel(msg, warn=False):
|
||||
@ -71,7 +72,7 @@ def print_yel(msg, warn=False):
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
:param warn: the condition if needs to be output the color of yellow with 'Warning'
|
||||
"""
|
||||
common.print_if_yel(msg, warn)
|
||||
common.print_yel(msg, warn)
|
||||
|
||||
|
||||
def print_red(msg, err=False):
|
||||
@ -80,7 +81,7 @@ def print_red(msg, err=False):
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
:param err: the condition if needs to be output the color of red with 'Error'
|
||||
"""
|
||||
common.print_if_red(msg, err)
|
||||
common.print_red(msg, err)
|
||||
|
||||
|
||||
def usage(file_name):
|
||||
@ -152,14 +153,53 @@ def get_param(args):
|
||||
return (err_dic, board_info_file, scenario_info_file, launch_info_file, int(vm_th), output_folder)
|
||||
|
||||
|
||||
def launch_vm_cnt(config_file):
|
||||
"""
|
||||
Get post vm number
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:return: total post vm number in launch file
|
||||
"""
|
||||
post_vm_count = 0
|
||||
|
||||
# get post vm number
|
||||
root = common.get_config_root(config_file)
|
||||
for item in root:
|
||||
if item.tag == "uos":
|
||||
post_vm_count += 1
|
||||
|
||||
return post_vm_count
|
||||
|
||||
|
||||
def get_post_num_list():
|
||||
"""
|
||||
Get board name from launch.xml at fist line
|
||||
:param scenario_file: it is a file what contains scenario information for script to read from
|
||||
Get post vm number list
|
||||
:return: total post dic: {launch_id:scenario_id} in launch file
|
||||
"""
|
||||
post_num_list = common.get_post_num_list(LAUNCH_INFO_FILE)
|
||||
# {launch_id:scenario_id}
|
||||
return post_num_list
|
||||
post_vm_list = []
|
||||
|
||||
# get post vm number
|
||||
root = common.get_config_root(LAUNCH_INFO_FILE)
|
||||
for item in root:
|
||||
if item.tag == "uos":
|
||||
post_vm_list.append(int(item.attrib['id']))
|
||||
|
||||
return post_vm_list
|
||||
|
||||
|
||||
def post_vm_cnt(config_file):
|
||||
"""
|
||||
Calculate the pre launched vm number
|
||||
:param config_file: it is a file what contains information for script to read from
|
||||
:return: number of post launched vm
|
||||
"""
|
||||
post_launch_cnt = 0
|
||||
load_type_list = common.get_sub_leaf_tag(config_file, "load_order")
|
||||
|
||||
for vm_type in load_type_list:
|
||||
if vm_type == "POST_LAUNCHED_VM":
|
||||
post_launch_cnt += 1
|
||||
|
||||
return post_launch_cnt
|
||||
|
||||
|
||||
def get_post_vm_cnt():
|
||||
@ -167,8 +207,8 @@ def get_post_vm_cnt():
|
||||
Get board name from launch.xml at fist line
|
||||
:param scenario_file: it is a file what contains scenario information for script to read from
|
||||
"""
|
||||
launch_vm_count = common.launch_vm_cnt(LAUNCH_INFO_FILE)
|
||||
post_vm_count = common.post_vm_cnt(SCENARIO_INFO_FILE)
|
||||
launch_vm_count = launch_vm_cnt(LAUNCH_INFO_FILE)
|
||||
post_vm_count = post_vm_cnt(SCENARIO_INFO_FILE)
|
||||
return (launch_vm_count, post_vm_count)
|
||||
|
||||
|
||||
@ -242,7 +282,7 @@ def get_info(board_info, msg_s, msg_e):
|
||||
:param msg_s: it is a pattern of key stings what start to match from board information
|
||||
:param msg_e: it is a pattern of key stings what end to match from board information
|
||||
"""
|
||||
info_lines = common.get_board_info(board_info, msg_s, msg_e)
|
||||
info_lines = board_cfg_lib.get_info(board_info, msg_s, msg_e)
|
||||
return info_lines
|
||||
|
||||
|
||||
@ -253,7 +293,7 @@ def get_rootdev_info(board_info):
|
||||
:return: root devices list
|
||||
"""
|
||||
rootdev_list = []
|
||||
rootdev_info = get_info(board_info, "<BLOCK_DEVICE_INFO>", "</BLOCK_DEVICE_INFO>")
|
||||
rootdev_info = board_cfg_lib.get_info(board_info, "<BLOCK_DEVICE_INFO>", "</BLOCK_DEVICE_INFO>")
|
||||
|
||||
if rootdev_info == None:
|
||||
return rootdev_list
|
||||
@ -262,7 +302,7 @@ def get_rootdev_info(board_info):
|
||||
if not rootdev_line:
|
||||
break
|
||||
|
||||
if not common.handle_root_dev(rootdev_line):
|
||||
if not board_cfg_lib.handle_root_dev(rootdev_line):
|
||||
continue
|
||||
|
||||
root_dev = rootdev_line.strip().split(':')[0]
|
||||
@ -276,9 +316,7 @@ def get_scenario_name():
|
||||
Get board name from scenario.xml at fist line
|
||||
:param scenario_file: it is a file what contains scenario information for script to read from
|
||||
"""
|
||||
(err_dic, scenario) = common.get_xml_attrib(SCENARIO_INFO_FILE, "scenario")
|
||||
|
||||
return (err_dic, scenario)
|
||||
return common.get_scenario_name()
|
||||
|
||||
|
||||
def get_board_name():
|
||||
@ -286,8 +324,7 @@ def get_board_name():
|
||||
Get board name from board.xml at fist line
|
||||
:param board_info: it is a file what contains board information for script to read from
|
||||
"""
|
||||
(err_dic, board) = common.get_xml_attrib(BOARD_INFO_FILE, "board")
|
||||
return (err_dic, board)
|
||||
return common.get_board_name()
|
||||
|
||||
|
||||
def is_config_file_match():
|
||||
@ -474,7 +511,7 @@ def get_cpu_processor_num():
|
||||
get cpu processor number from config file which is dumped from native board
|
||||
:return: integer number of cpu processor
|
||||
"""
|
||||
cpu_lines = get_info(BOARD_INFO_FILE, "<CPU_PROCESSOR_INFO>", "</CPU_PROCESSOR_INFO>")
|
||||
cpu_lines = board_cfg_lib.get_info(BOARD_INFO_FILE, "<CPU_PROCESSOR_INFO>", "</CPU_PROCESSOR_INFO>")
|
||||
|
||||
for cpu_line in cpu_lines:
|
||||
cpu_processor_num = len(cpu_line.split(','))
|
||||
@ -489,7 +526,7 @@ def get_total_mem():
|
||||
"""
|
||||
scale_to_mb = 1
|
||||
total_mem_mb = scale_to_mb
|
||||
mem_lines = get_info(BOARD_INFO_FILE, "<TOTAL_MEM_INFO>", "</TOTAL_MEM_INFO>")
|
||||
mem_lines = board_cfg_lib.get_info(BOARD_INFO_FILE, "<TOTAL_MEM_INFO>", "</TOTAL_MEM_INFO>")
|
||||
for mem_line in mem_lines:
|
||||
mem_info_list = mem_line.split()
|
||||
|
||||
@ -593,7 +630,7 @@ def undline_name(name):
|
||||
|
||||
def get_vuart1_from_scenario(vmid):
|
||||
"""Get the vmid's vuart1 base"""
|
||||
vuart1 = common.get_vuart_info_id(SCENARIO_INFO_FILE, 1)
|
||||
vuart1 = board_cfg_lib.get_vuart_info_id(SCENARIO_INFO_FILE, 1)
|
||||
return vuart1[vmid]['base']
|
||||
|
||||
|
||||
@ -614,7 +651,7 @@ def pt_devs_check_audio(audio_map, audio_codec_map):
|
||||
|
||||
|
||||
def check_block_mount(virtio_blk_dic):
|
||||
blk_dev_list = get_rootdev_info(BOARD_INFO_FILE)
|
||||
blk_dev_list = board_cfg_lib.get_rootfs(BOARD_INFO_FILE)
|
||||
for vmid in list(virtio_blk_dic.keys()):
|
||||
mount_flags = []
|
||||
for blk in virtio_blk_dic[vmid]:
|
||||
|
@ -4,8 +4,9 @@
|
||||
#
|
||||
|
||||
import common
|
||||
import board_cfg_lib
|
||||
|
||||
SOURCE_ROOT_DIR = common.SOURCE_PATH
|
||||
SOURCE_ROOT_DIR = common.SOURCE_ROOT_DIR
|
||||
HEADER_LICENSE = common.open_license()
|
||||
BOARD_INFO_FILE = "board_info.txt"
|
||||
SCENARIO_INFO_FILE = ""
|
||||
@ -30,6 +31,9 @@ VUART_IRQ = ['SOS_COM1_IRQ', 'SOS_COM2_IRQ', 'COM1_IRQ', 'COM2_IRQ', 'COM3_IRQ',
|
||||
|
||||
PCI_DEV_NUM_LIST = ['SOS_EMULATED_PCI_DEV_NUM', 'VM0_CONFIG_PCI_DEV_NUM', 'VM1_CONFIG_PCI_DEV_NUM']
|
||||
PCI_DEVS_LIST = ['sos_pci_devs', 'vm0_pci_devs', 'vm1_pci_devs']
|
||||
# Support 512M, 1G, 2G
|
||||
# pre launch less then 2G, sos vm less than 24G
|
||||
START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE']
|
||||
|
||||
COMMUNICATE_VM_ID = []
|
||||
|
||||
@ -54,7 +58,7 @@ LEGACY_TTYS = {
|
||||
|
||||
def prepare():
|
||||
""" Check environment """
|
||||
return common.check_env()
|
||||
return common.prepare()
|
||||
|
||||
|
||||
def print_yel(msg, warn=False):
|
||||
@ -63,7 +67,7 @@ def print_yel(msg, warn=False):
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
:param warn: the condition if needs to be output the color of yellow with 'Warning'
|
||||
"""
|
||||
common.print_if_yel(msg, warn)
|
||||
common.print_yel(msg, warn)
|
||||
|
||||
|
||||
def print_red(msg, err=False):
|
||||
@ -72,7 +76,7 @@ def print_red(msg, err=False):
|
||||
:param msg: the stings which will be output to STDOUT
|
||||
:param err: the condition if needs to be output the color of red with 'Error'
|
||||
"""
|
||||
common.print_if_red(msg, err)
|
||||
common.print_red(msg, err)
|
||||
|
||||
|
||||
def usage(file_name):
|
||||
@ -93,20 +97,12 @@ def get_scenario_name():
|
||||
Get board name from scenario.xml at fist line
|
||||
:param scenario_file: it is a file what contains scenario information for script to read from
|
||||
"""
|
||||
(err_dic, scenario) = common.get_xml_attrib(SCENARIO_INFO_FILE, "scenario")
|
||||
|
||||
return (err_dic, scenario)
|
||||
return common.get_scenario_name()
|
||||
|
||||
|
||||
def is_config_file_match():
|
||||
|
||||
(err_dic, scenario_for_board) = common.get_xml_attrib(SCENARIO_INFO_FILE, "board")
|
||||
(err_dic, board_name) = common.get_xml_attrib(BOARD_INFO_FILE, "board")
|
||||
|
||||
if scenario_for_board == board_name:
|
||||
return (err_dic, True)
|
||||
else:
|
||||
return (err_dic, False)
|
||||
return common.is_config_file_match()
|
||||
|
||||
|
||||
def get_info(board_info, msg_s, msg_e):
|
||||
@ -116,7 +112,7 @@ def get_info(board_info, msg_s, msg_e):
|
||||
:param msg_s: it is a pattern of key stings what start to match from board information
|
||||
:param msg_e: it is a pattern of key stings what end to match from board information
|
||||
"""
|
||||
info_lines = common.get_board_info(board_info, msg_s, msg_e)
|
||||
info_lines = board_cfg_lib.get_info(board_info, msg_s, msg_e)
|
||||
return info_lines
|
||||
|
||||
|
||||
@ -128,7 +124,7 @@ def get_processor_info(board_info):
|
||||
"""
|
||||
processor_list = []
|
||||
tmp_list = []
|
||||
processor_info = get_info(board_info, "<CPU_PROCESSOR_INFO>", "</CPU_PROCESSOR_INFO>")
|
||||
processor_info = board_cfg_lib.get_info(board_info, "<CPU_PROCESSOR_INFO>", "</CPU_PROCESSOR_INFO>")
|
||||
|
||||
if not processor_info:
|
||||
key = "vm:id=0,vcpu_affinity"
|
||||
@ -154,7 +150,7 @@ def get_rootdev_info(board_info):
|
||||
:return: root devices list
|
||||
"""
|
||||
rootdev_list = []
|
||||
rootdev_info = get_info(board_info, "<BLOCK_DEVICE_INFO>", "</BLOCK_DEVICE_INFO>")
|
||||
rootdev_info = board_cfg_lib.get_info(board_info, "<BLOCK_DEVICE_INFO>", "</BLOCK_DEVICE_INFO>")
|
||||
|
||||
# none 'BLOCK_DEVICE_INFO' tag
|
||||
if rootdev_info == None:
|
||||
@ -164,7 +160,7 @@ def get_rootdev_info(board_info):
|
||||
if not rootdev_line:
|
||||
break
|
||||
|
||||
if not common.handle_root_dev(rootdev_line):
|
||||
if not board_cfg_lib.handle_root_dev(rootdev_line):
|
||||
continue
|
||||
|
||||
root_dev = rootdev_line.strip().split(':')[0]
|
||||
@ -180,7 +176,7 @@ def get_ttys_info(board_info):
|
||||
:return: serial console list
|
||||
"""
|
||||
ttys_list = []
|
||||
ttys_info = get_info(board_info, "<TTYS_INFO>", "</TTYS_INFO>")
|
||||
ttys_info = board_cfg_lib.get_info(board_info, "<TTYS_INFO>", "</TTYS_INFO>")
|
||||
|
||||
for ttys_line in ttys_info:
|
||||
if not ttys_line:
|
||||
@ -232,7 +228,7 @@ def get_vm_num(config_file):
|
||||
:param config_file: it is a file what contains vm information for script to read from
|
||||
:return: number of vm
|
||||
"""
|
||||
return common.get_vm_count(config_file)
|
||||
return common.get_vm_num(config_file)
|
||||
|
||||
|
||||
def get_sub_leaf_tag(config_file, branch_tag, tag_str=''):
|
||||
@ -243,7 +239,7 @@ def get_sub_leaf_tag(config_file, branch_tag, tag_str=''):
|
||||
:param tag_str: it is key of pattern to config file leaf tag item
|
||||
:return: value of tag_str item
|
||||
"""
|
||||
return common.get_leaf_tag_val(config_file, branch_tag, tag_str)
|
||||
return common.get_sub_leaf_tag(config_file, branch_tag, tag_str)
|
||||
|
||||
|
||||
def get_order_type_by_vmid(idx):
|
||||
@ -445,8 +441,8 @@ def mem_size_check(id_hpa_size_dic, prime_item, item):
|
||||
ERR_LIST[key] = "VM start host physical memory size should not empty"
|
||||
return
|
||||
|
||||
if hpa_sz_strip_ul not in common.START_HPA_SIZE_LIST and hpa_sz_strip_u not in \
|
||||
common.START_HPA_SIZE_LIST:
|
||||
if hpa_sz_strip_ul not in START_HPA_SIZE_LIST and hpa_sz_strip_u not in \
|
||||
START_HPA_SIZE_LIST:
|
||||
key = "vm:id={},{},{}".format(id_key, prime_item, item)
|
||||
if '0x' not in hpa_size and '0X' not in hpa_size:
|
||||
ERR_LIST[key] = "Mem size should be Hex format"
|
||||
@ -696,7 +692,7 @@ def get_vuart_info_id(config_file, idx):
|
||||
:param idx: vuart index in range: [0,1]
|
||||
:return: dictionary which stored the vuart-id
|
||||
"""
|
||||
tmp_tag = common.get_vuart_info_id(config_file, idx)
|
||||
tmp_tag = board_cfg_lib.get_vuart_info_id(config_file, idx)
|
||||
return tmp_tag
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@ import scenario_cfg_lib
|
||||
import vm_configurations_c
|
||||
import vm_configurations_h
|
||||
import pci_dev_c
|
||||
import common
|
||||
|
||||
ACRN_PATH = scenario_cfg_lib.SOURCE_ROOT_DIR
|
||||
ACRN_CONFIG_TARGET = ACRN_PATH + 'hypervisor/scenarios/'
|
||||
@ -27,6 +28,8 @@ def get_scenario_item_values(board_info, scenario_info):
|
||||
hw_info = HwInfo(board_info)
|
||||
|
||||
# get vm count
|
||||
common.BOARD_INFO_FILE = board_info
|
||||
common.SCENARIO_INFO_FILE = scenario_info
|
||||
scenario_cfg_lib.SCENARIO_INFO_FILE = scenario_info
|
||||
scenario_cfg_lib.BOARD_INFO_FILE = board_info
|
||||
scenario_cfg_lib.VM_COUNT = scenario_cfg_lib.get_vm_num(scenario_info)
|
||||
@ -59,6 +62,8 @@ def validate_scenario_setting(board_info, scenario_info):
|
||||
:return: return a dictionary contain errors
|
||||
"""
|
||||
scenario_cfg_lib.ERR_LIST = {}
|
||||
common.BOARD_INFO_FILE = board_info
|
||||
common.SCENARIO_INFO_FILE = scenario_info
|
||||
scenario_cfg_lib.BOARD_INFO_FILE = board_info
|
||||
scenario_cfg_lib.SCENARIO_INFO_FILE = scenario_info
|
||||
|
||||
@ -91,6 +96,8 @@ def main(args):
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
||||
common.BOARD_INFO_FILE = board_info_file
|
||||
common.SCENARIO_INFO_FILE = scenario_info_file
|
||||
scenario_cfg_lib.BOARD_INFO_FILE = board_info_file
|
||||
scenario_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user