mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-31 15:30:56 +00:00
config_tool: load default cpu affinity config by vm_name
1. load default cpu affinity config from scenario file by vm_name. Tracked-On: #6724 Signed-off-by: Weiyi Feng <weiyix.feng@intel.com>
This commit is contained in:
parent
e4a58363e3
commit
93d4e92273
@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@ -193,12 +193,6 @@ def main(args):
|
||||
err_dic['user_vmid err:'] = "--user_vmid shoudl be positive and less than total post vm count in scenario"
|
||||
if vm_th and vm_th not in post_num_list:
|
||||
err_dic['user_vmid err:'] = "--user_vmid generate the {} post vm, but this vm's config not in launch xml".format(vm_th)
|
||||
if launch_vm_count > post_vm_count:
|
||||
err_dic['xm config err:'] = "too many vms config than scenario"
|
||||
|
||||
for post_num in post_num_list:
|
||||
if post_num > post_vm_count:
|
||||
err_dic['xm config err:'] = "launch xml user vmid config is bigger than scenario post vm count"
|
||||
|
||||
# validate vm_names
|
||||
scenario_names = common.get_leaf_tag_map(scenario_info_file, "name").values()
|
||||
@ -208,8 +202,11 @@ def main(args):
|
||||
err_dic[err_name] = 'vm_name only allowed 1-15 characters with letters, numbers & symbols ' \
|
||||
'(not include space)'
|
||||
if vm_name not in scenario_names:
|
||||
err_name = 'user_vm id="{}" name not found error:'.format(user_vm_id)
|
||||
err_dic[err_name] = 'user_vm id="{}" vm_name not found in it scenario file:'.format(user_vm_id)
|
||||
logging.warning(
|
||||
'user_vm id="{}"\'s vm_name ({}) not found in scenario file, set it to dynamic vm.'.format(
|
||||
user_vm_id, vm_name
|
||||
)
|
||||
)
|
||||
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
@ -20,6 +20,7 @@ class AcrnDmArgs:
|
||||
def get_args(self):
|
||||
self.args["user_vm_type"] = common.get_leaf_tag_map(self.launch_info, "user_vm_type")
|
||||
self.args["rtos_type"] = common.get_leaf_tag_map(self.launch_info, "rtos_type")
|
||||
self.args['vm_name'] = common.get_leaf_tag_map(self.launch_info, 'vm_name')
|
||||
self.args["mem_size"] = common.get_leaf_tag_map(self.launch_info, "mem_size")
|
||||
self.args["vbootloader"] = common.get_leaf_tag_map(self.launch_info, "vbootloader")
|
||||
self.args["vuart0"] = common.get_leaf_tag_map(self.launch_info, "vuart0")
|
||||
@ -27,12 +28,19 @@ class AcrnDmArgs:
|
||||
self.args["pm_channel"] = common.get_leaf_tag_map(self.launch_info, "poweroff_channel")
|
||||
self.args["cpu_affinity"] = common.get_leaf_tag_map(self.launch_info, "cpu_affinity", "pcpu_id")
|
||||
# get default cpu_affinity from scenario file
|
||||
scenario_names = {v: k for k, v in common.get_leaf_tag_map(self.scenario_info, "name").items()}
|
||||
scenario_cpu_aff = common.get_leaf_tag_map(self.scenario_info, "cpu_affinity", "pcpu_id")
|
||||
for vm_id, cpu_ids in self.args["cpu_affinity"].items():
|
||||
cpu_ids = [x for x in cpu_ids if x is not None]
|
||||
if cpu_ids:
|
||||
continue
|
||||
self.args["cpu_affinity"][vm_id] = scenario_cpu_aff[vm_id]
|
||||
vm_name = self.args['vm_name'][vm_id]
|
||||
if vm_name not in scenario_names:
|
||||
key = "vm:id={},{}".format(vm_id, 'cpu_affinity')
|
||||
launch_cfg_lib.ERR_LIST[key] = "Dynamic VM needs to configure cpu_affinity parameters"
|
||||
continue
|
||||
|
||||
self.args["cpu_affinity"][vm_id] = scenario_cpu_aff[scenario_names[vm_name]]
|
||||
|
||||
self.args["shm_enabled"] = common.get_hv_item_tag(self.scenario_info, "FEATURES", "IVSHMEM", "IVSHMEM_ENABLED")
|
||||
self.args["shm_regions"] = common.get_leaf_tag_map(self.launch_info, "shm_regions", "shm_region")
|
||||
@ -57,7 +65,7 @@ class AcrnDmArgs:
|
||||
launch_cfg_lib.args_aval_check(self.args["enable_ptm"], "enable_ptm", launch_cfg_lib.y_n)
|
||||
launch_cfg_lib.args_aval_check(self.args["allow_trigger_s5"], "allow_trigger_s5", launch_cfg_lib.y_n)
|
||||
cpu_affinity = launch_cfg_lib.user_vm_cpu_affinity(self.args["cpu_affinity"])
|
||||
err_dic = scenario_cfg_lib.vm_cpu_affinity_check(self.scenario_info, cpu_affinity)
|
||||
err_dic = scenario_cfg_lib.vm_cpu_affinity_check(self.scenario_info, self.launch_info, cpu_affinity)
|
||||
launch_cfg_lib.ERR_LIST.update(err_dic)
|
||||
launch_cfg_lib.check_shm_regions(self.args["shm_regions"], self.scenario_info)
|
||||
launch_cfg_lib.check_console_vuart(self.args["console_vuart"], self.args["vuart0"], self.scenario_info)
|
||||
|
@ -6,6 +6,7 @@
|
||||
import math
|
||||
import common
|
||||
import board_cfg_lib
|
||||
import launch_cfg_lib
|
||||
|
||||
HEADER_LICENSE = common.open_license()
|
||||
SERVICE_VM_UART1_VALID_NUM = ""
|
||||
@ -293,7 +294,7 @@ def guest_flag_check(guest_flags, branch_tag, leaf_tag):
|
||||
ERR_LIST[key] = "Unknow guest flag"
|
||||
|
||||
|
||||
def vm_cpu_affinity_check(scenario_file, cpu_affinity):
|
||||
def vm_cpu_affinity_check(scenario_file, launch_file, cpu_affinity):
|
||||
"""
|
||||
Check cpu number of per vm
|
||||
:param : vm cpu_affinity item in xml
|
||||
@ -308,12 +309,26 @@ def vm_cpu_affinity_check(scenario_file, cpu_affinity):
|
||||
cpu_sharing_enabled = False
|
||||
|
||||
# validate cpu_affinity config with scenario file
|
||||
sos_vmid = launch_cfg_lib.get_sos_vmid()
|
||||
scenario_cpu_aff = common.get_leaf_tag_map(scenario_file, "cpu_affinity", "pcpu_id")
|
||||
for vm_id, cpu_ids in cpu_affinity.items():
|
||||
for vm_cpu in cpu_ids:
|
||||
if vm_cpu not in scenario_cpu_aff[vm_id]:
|
||||
key = "vm:id={},{}".format(vm_id, 'pcpu_id')
|
||||
err_dic[key] = "This pCPU is not included in this VM's allowed CPU pool. Please update your scenario file accordingly or remove it from this list."
|
||||
scenario_vm_names = {v: k for k, v in common.get_leaf_tag_map(scenario_file, 'name').items()}
|
||||
if launch_file:
|
||||
launch_vm_names = common.get_leaf_tag_map(launch_file, 'vm_name')
|
||||
for vm_id, cpu_ids in cpu_affinity.items():
|
||||
launch_vm_name = launch_vm_names[vm_id - sos_vmid]
|
||||
if launch_vm_name not in scenario_vm_names:
|
||||
# Dynamic VM, skip scenario cpu affinity subset check
|
||||
continue
|
||||
abs_vmid = scenario_vm_names[launch_vm_name]
|
||||
for vm_cpu in cpu_ids:
|
||||
if vm_cpu is None:
|
||||
key = "vm:id={},{}".format(abs_vmid - sos_vmid, 'pcpu_id')
|
||||
err_dic[key] = "This vm cpu_affinity is empty. " \
|
||||
"Please update your launch file accordingly."
|
||||
if vm_cpu not in scenario_cpu_aff[abs_vmid]:
|
||||
key = "vm:id={},{}".format(abs_vmid - sos_vmid, 'pcpu_id')
|
||||
err_dic[key] = "This pCPU is not included in this VM's allowed CPU pool. " \
|
||||
"Please update your scenario file accordingly or remove it from this list."
|
||||
|
||||
if err_dic:
|
||||
return err_dic
|
||||
|
@ -399,7 +399,7 @@ class VmInfo:
|
||||
scenario_cfg_lib.vm_name_check(self.name, "name")
|
||||
scenario_cfg_lib.load_vm_check(self.load_vm, "load_vm")
|
||||
scenario_cfg_lib.guest_flag_check(self.guest_flags, "guest_flags", "guest_flag")
|
||||
err_dic = scenario_cfg_lib.vm_cpu_affinity_check(self.scenario_info, self.cpus_per_vm)
|
||||
err_dic = scenario_cfg_lib.vm_cpu_affinity_check(self.scenario_info, None, self.cpus_per_vm)
|
||||
scenario_cfg_lib.vcpu_clos_check(self.cpus_per_vm, self.clos_per_vm, self.guest_flags, "clos", "vcpu_clos")
|
||||
|
||||
self.mem_info.check_item()
|
||||
|
Loading…
Reference in New Issue
Block a user