mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-18 16:22:35 +00:00
config_tools: fix crash in board_inspector if cpuid is missing
Fix a crash in the 'board_inspector.py' tool in case 'cpuid' is not installed on the system. The tools crashes because 'cpuid' is used before the check for dependencies is done in the code. That check for dependencies is done in the 'legacy/board_parser.py' file. But the native_check() function that is called before it also expects the cpuid tool to be installed. The fix is to move the check for dependencies in the main 'board_inspector.py' file, before any other operation is done. Tracked-On: #6719 Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
This commit is contained in:
parent
54aba7a858
commit
6ad9dcb262
@ -16,6 +16,30 @@ from cpuparser import parse_cpuid, get_online_cpu_ids
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
sys.path.append(os.path.join(script_dir))
|
||||
|
||||
def check_deps():
|
||||
# Check that the required tools are installed on the system
|
||||
BIN_LIST = ['cpuid', 'rdmsr', 'lspci', ' dmidecode', 'blkid', 'stty']
|
||||
cpuid_min_ver = 20170122
|
||||
for execute in BIN_LIST:
|
||||
res = subprocess.Popen("which {}".format(execute),
|
||||
shell=True, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, close_fds=True)
|
||||
|
||||
line = res.stdout.readline().decode('ascii')
|
||||
if not line:
|
||||
logging.warning("'{}' cannot be found, please install it!".format(execute))
|
||||
sys.exit(1)
|
||||
|
||||
if execute == 'cpuid':
|
||||
res = subprocess.Popen("cpuid -v",
|
||||
shell=True, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, close_fds=True)
|
||||
line = res.stdout.readline().decode('ascii')
|
||||
version = line.split()[2]
|
||||
if int(version) < cpuid_min_ver:
|
||||
logging.warning("This tool requires CPUID version >= {}".format(cpuid_min_ver))
|
||||
sys.exit(1)
|
||||
|
||||
def native_check():
|
||||
cpu_ids = get_online_cpu_ids()
|
||||
cpu_id = cpu_ids.pop(0)
|
||||
@ -25,6 +49,9 @@ def native_check():
|
||||
"supported under KVM/QEMU. Unexpected results may occur when deviating from that combination.")
|
||||
|
||||
def main(board_name, board_xml, args):
|
||||
# Check that the dependencies are met
|
||||
check_deps()
|
||||
|
||||
# Check if this is native os
|
||||
native_check()
|
||||
|
||||
|
@ -18,12 +18,8 @@ import parser_lib
|
||||
OUTPUT = "./out/"
|
||||
PY_CACHE = "__pycache__"
|
||||
|
||||
# This file store information which query from hw board
|
||||
BIN_LIST = ['cpuid', 'rdmsr', 'lspci', ' dmidecode', 'blkid', 'stty']
|
||||
|
||||
CPU_VENDOR = "GenuineIntel"
|
||||
|
||||
|
||||
def check_permission():
|
||||
"""Check if it is root permission"""
|
||||
if os.getuid():
|
||||
@ -51,27 +47,6 @@ def check_env():
|
||||
parser_lib.print_red("Please run this tools on {}!".format(CPU_VENDOR))
|
||||
sys.exit(1)
|
||||
|
||||
# check if required tools are exists
|
||||
for excute in BIN_LIST:
|
||||
res = subprocess.Popen("which {}".format(excute),
|
||||
shell=True, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, close_fds=True)
|
||||
|
||||
line = res.stdout.readline().decode('ascii')
|
||||
if not line:
|
||||
parser_lib.print_yel("'{}' not found, please install it!".format(excute))
|
||||
sys.exit(1)
|
||||
|
||||
if excute == 'cpuid':
|
||||
res = subprocess.Popen("cpuid -v",
|
||||
shell=True, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, close_fds=True)
|
||||
line = res.stdout.readline().decode('ascii')
|
||||
version = line.split()[2]
|
||||
if int(version) < 20170122:
|
||||
parser_lib.print_yel("Need CPUID version >= 20170122")
|
||||
sys.exit(1)
|
||||
|
||||
if os.path.exists(OUTPUT):
|
||||
shutil.rmtree(OUTPUT)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user