config_tools: category based on different log levels

category based on different log levels:
1) If the board inspector show CRITICAL error messages, it means that the
board inspector tool exit instantly and generate no file.
2) If the board inspector show ERROR messages, it means that the board
inspector will generate the board XML file successfully, but several conditions
may result in ACRN build or boot failure cannot continue execution due to the error.
3) If the board inspector show WARNING messages, this means that the board inspector
generate the board XML file successfully, but this board XML file is lack of
some feature which could still boot ACRN but loss some features.
4) If the board inspector show INFO messages, this means that board inspector
printed out some normal information.
5) If the board inspector show DEBUG messages, this means that it is used to
debug board inspector workflow.

v1->v2
1. Keep the assertions or exceptions under the acpiparser, inspectorlib
and smbiosparser directory.
2. Exit after all check_deps() completes instead of any unsatisfied dep
is identified.
3. As Amy's advice, Replace the message "{board_xml} saved successfully" with
the message "SUCCESS: Board configuration file <file name> generated successfully
and saved to <path>."

To do:
Print all messages using the colored font.

Tracked-On: #6689
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
Signed-off-by: Kunhui-Li <kunhuix.li@intel.com>
This commit is contained in:
Kunhui-Li
2022-02-11 11:36:29 +08:00
committed by acrnsi-robot
parent 2e20494db1
commit 4bf53e4b83
15 changed files with 128 additions and 114 deletions

View File

@@ -10,7 +10,7 @@ import shutil
from collections import defaultdict
import dmar
import parser_lib
import logging
SYS_PATH = ['/proc/cpuinfo', '/sys/firmware/acpi/tables/', '/sys/devices/system/cpu/']
@@ -438,17 +438,22 @@ def store_cx_data(sysnode1, sysnode2, config):
idle_driver = acpi_idle.read(32)
if idle_driver.find("acpi_idle") == -1:
parser_lib.print_yel("The Cx data for ACRN relies on " +\
"acpi_idle driver but it is not found, ", warn=True, end=False)
logging.info("Failed to collect processor power states because the current CPU idle driver " \
"does not expose C-state data. If you need ACPI C-states in post-launched VMs, append 'idle=nomwait' " \
"to the kernel command line in GRUB config file.")
if idle_driver.find("intel_idle") == 0:
print("please add idle=nomwait in kernel " +\
"cmdline to fall back to acpi_idle driver")
logging.info("Failed to collect processor power states because the current CPU idle driver " \
"does not expose C-state data. If you need ACPI C-states in post-launched VMs, append 'idle=nomwait' " \
"to the kernel command line in GRUB config file.")
else:
parser_lib.print_yel("please make sure ACPI Cstate is enabled in BIOS.", warn=True)
logging.info("Failed to collect processor power states because the platform does not provide " \
"C-state data. If you need ACPI C-states in post-launched VMs, enable C-state support in BIOS.")
print("\t/* Cx data is not available */", file=config)
return
except IOError:
parser_lib.print_yel("No idle driver found.", warn=True)
logging.info("Failed to collect processor power states because CPU idle PM support is disabled " \
"in the current kernel. If you need ACPI C-states in post-launched VMs, rebuild the current kernel " \
"with CONFIG_CPU_IDLE set to 'y' or 'm'.")
print("\t/* Cx data is not available */", file=config)
return
@@ -512,17 +517,15 @@ def store_px_data(sysnode, config):
with open(sysnode+'cpu0/cpufreq/scaling_driver', 'r') as f_node:
freq_driver = f_node.read()
if freq_driver.find("acpi-cpufreq") == -1:
parser_lib.print_yel("The Px data for ACRN relies on " +\
"acpi-cpufreq driver but it is not found, ", warn=True, end=False)
logging.info("The Px data for ACRN relies on acpi-cpufreq driver but it is not found, ")
if freq_driver.find("intel_pstate") == 0:
print("please add intel_pstate=disable in kernel " +\
"cmdline to fall back to acpi-cpufreq driver")
logging.info("please add intel_pstate=disable in kernel cmdline to fall back to acpi-cpufreq driver")
else:
parser_lib.print_yel("please make sure ACPI Pstate is enabled in BIOS.", warn=True)
logging.info("Enable ACPI Pstate in BIOS.")
print("\t/* Px data is not available */", file=config)
return
except IOError:
parser_lib.print_yel("No scaling_driver found.", warn=True)
logging.info("No scaling_driver found.", warn=True)
print("\t/* Px data is not available */", file=config)
return
@@ -531,7 +534,7 @@ def store_px_data(sysnode, config):
boost = f_node.read()
except IOError:
boost = 0
parser_lib.print_yel("CPU turbo is not enabled!")
logging.info("Enable CPU turbo in BIOS.")
with open(sysnode + 'cpu0/cpufreq/scaling_available_frequencies', 'r') as f_node:
freqs = f_node.read()
@@ -546,8 +549,8 @@ def store_px_data(sysnode, config):
try:
subprocess.check_call('/usr/sbin/rdmsr 0x1ad', shell=True, stdout=subprocess.PIPE)
except subprocess.CalledProcessError:
parser_lib.print_red("MSR 0x1ad not support in this platform!", err=True)
sys.exit(1)
logging.debug("MSR 0x1ad not support in this platform!")
return
res = subprocess.Popen('/usr/sbin/rdmsr 0x1ad', shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
@@ -583,8 +586,8 @@ def store_mmcfg_base_data(mmcfg_node, config):
mmcfg_len_int = int.from_bytes(mmcfg_len_obj, 'little')
if mmcfg_len_int > MCFG_ENTRY1_OFFSET:
parser_lib.print_red("Multiple PCI segment groups is not supported!", err=True)
sys.exit(1)
logging.debug("Multiple PCI segment groups is not supported!")
return
mmcfg.seek(MCFG_ENTRY0_BASE_OFFSET, 0)
mmcfg_base_addr_obj = mmcfg.read(DWORD_LEN)
@@ -658,7 +661,7 @@ def generate_info(board_file):
out_dir = os.path.dirname(board_file)
if os.path.isfile(SYS_PATH[1] + 'PTCT'):
shutil.copy(SYS_PATH[1] + 'PTCT', out_dir if out_dir != "" else "./")
print("PTCT table has been saved to {} successfully!".format(os.path.join(out_dir, 'PTCT')))
logging.info("PTCT table has been saved to {} successfully!".format(os.path.join(out_dir, 'PTCT')))
if os.path.isfile(SYS_PATH[1] + 'RTCT'):
shutil.copy(SYS_PATH[1] + 'RTCT', out_dir if out_dir != "" else "./")
print("RTCT table has been saved to {} successfully!".format(os.path.join(out_dir, 'RTCT')))
logging.info("RTCT table has been saved to {} successfully!".format(os.path.join(out_dir, 'RTCT')))

View File

@@ -14,6 +14,7 @@ import acpi
import clos
import misc
import parser_lib
import logging
OUTPUT = "./out/"
PY_CACHE = "__pycache__"
@@ -23,7 +24,7 @@ CPU_VENDOR = "GenuineIntel"
def check_permission():
"""Check if it is root permission"""
if os.getuid():
parser_lib.print_red("You need run this tool with root privileges (sudo)!")
logging.critical("Run this tool with root privileges (sudo).")
sys.exit(1)
def vendor_check():
@@ -59,18 +60,19 @@ def check_env():
stderr=subprocess.PIPE, close_fds=True)
err_msg = res.stderr.readline().decode('ascii')
if err_msg:
parser_lib.print_red("{}".format(err_msg), err=True)
logging.critical("{}".format(err_msg))
exit(-1)
msr_info = check_msr_files(cpu_dirs)
if msr_info:
for cpu_num in msr_info:
parser_lib.print_red("Missing CPU msr file in the {}/{}/".format(cpu_dirs, cpu_num), err=True)
parser_lib.print_red("Missing CPU msr file, please check the value of CONFIG_X86_MSR in the kernel config.", err=True)
logging.critical("Missing CPU MSR file at {}/{}/msr".format(cpu_dirs, cpu_num))
logging.critical("Missing CPU MSR file /dev/cpu/#/msr. Check the value of CONFIG_X86_MSR in the kernel config." \
" Set it to 'Y' and rebuild the OS. Then rerun the Board Inspector.")
exit(-1)
# check cpu vendor id
if not vendor_check():
parser_lib.print_red("Please run this tools on {}!".format(CPU_VENDOR))
logging.critical(f"Unsupported processor {CPU_VENDOR} found. ACRN requires using a {CPU_VENDOR} processor.")
sys.exit(1)
if os.path.exists(OUTPUT):

View File

@@ -4,6 +4,7 @@
#
import parser_lib
import logging
RDT_TYPE = {
"L2":4,
@@ -64,7 +65,7 @@ def get_clos_info():
rdt_res = dump_cpuid_reg(cmd, "ebx")
if len(rdt_res) == 0:
parser_lib.print_yel("Resource Allocation is not supported!")
logging.debug("Resource Allocation is not supported!")
else:
for i in range(len(rdt_res)):
if rdt_res[i] == "L2":