acrn-config: add 'cpu_sharing' support for launch config

Add support to parse and get 'cpu_sharing' item value
from launch config files, these values are editable by user.

Tracked-On: #3854
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
Wei Liu 2019-12-25 11:02:23 +08:00 committed by wenlingz
parent 3544f7c87e
commit ce35a00518
4 changed files with 45 additions and 1 deletions

View File

@ -382,7 +382,8 @@ def launch_end(names, args, virt_io, vmid, config):
print("", file=config)
i += 1
off_line_cpus(args, vmid, uos_type, config)
if args['cpu_sharing'][vmid] == "Disabled":
off_line_cpus(args, vmid, uos_type, config)
uos_launch(names, args, virt_io, vmid, config)

View File

@ -46,6 +46,7 @@ def get_launch_item_values(board_info):
launch_item_values["uos,vbootloader"] = launch_cfg_lib.BOOT_TYPE
launch_item_values['uos,vuart0'] = launch_cfg_lib.DM_VUART0
launch_item_values['uos,cpu_sharing'] = launch_cfg_lib.CPU_SHARING
launch_item_values['uos,poweroff_channel'] = launch_cfg_lib.PM_CHANNEL
return launch_item_values

View File

@ -20,6 +20,7 @@ class AcrnDmArgs:
self.args["gvt_args"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "gvt_args")
self.args["vbootloader"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "vbootloader")
self.args["vuart0"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "vuart0")
self.args["cpu_sharing"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "cpu_sharing")
self.args["pm_channel"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "poweroff_channel")
self.args["off_pcpus"] = launch_cfg_lib.get_leaf_tag_map(self.scenario_info, "vcpu_affinity", "pcpu_id")
self.args["xhci"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "usb_xhci")
@ -31,6 +32,7 @@ class AcrnDmArgs:
launch_cfg_lib.mem_size_check(self.args["mem_size"], "mem_size")
launch_cfg_lib.args_aval_check(self.args["vbootloader"], "vbootloader", launch_cfg_lib.BOOT_TYPE)
launch_cfg_lib.args_aval_check(self.args["vuart0"], "vuart0", launch_cfg_lib.DM_VUART0)
launch_cfg_lib.cpu_sharing_check(self.args["cpu_sharing"], "cpu_sharing")
class AvailablePthru():

View File

@ -16,6 +16,7 @@ ERR_LIST = {}
BOOT_TYPE = ['no', 'vsbl', 'ovmf']
RTOS_TYPE = ['no', 'Soft RT', 'Hard RT']
DM_VUART0 = ['Disable', 'Enable']
CPU_SHARING = ['Disabled', 'Enabled']
UOS_TYPES = ['CLEARLINUX', 'ANDROID', 'ALIOS', 'PREEMPT-RT LINUX', 'VXWORKS', 'WINDOWS', 'ZEPHYR', 'GENERIC LINUX']
PT_SUB_PCI = {}
@ -643,3 +644,42 @@ def check_block_mount(virtio_blk_dic):
mount_flags.append(False)
MOUNT_FLAG_DIC[vmid] = mount_flags
def cpu_sharing_check(cpu_sharing, item):
"""
Check cpu sharing status with cpu affinity setting
:param cpu_share_status:
:param item:
:return: None
"""
use_cpus = []
use_same_cpu = False
vm_cpu_share = []
vm_cpu_share_consistent = True
cpu_affinity = get_leaf_tag_map(SCENARIO_INFO_FILE, "vcpu_affinity", "pcpu_id")
for vm_i in cpu_affinity.keys():
for cpu in cpu_affinity[vm_i]:
if cpu in use_cpus:
use_same_cpu = True
else:
use_cpus.append(cpu)
for vm_i in cpu_sharing.keys():
cpu_share = cpu_sharing[vm_i]
stat_len = len(vm_cpu_share)
if stat_len != 0 and cpu_share not in vm_cpu_share:
vm_cpu_share_consistent = False
else:
vm_cpu_share.append(cpu_share)
if not vm_cpu_share_consistent:
key = "uos:id={},{}".format(vm_i, item)
ERR_LIST[key] = "CPU sharing for all VMs should be consistent to 'Disabled' or 'Enabled'"
return
if cpu_sharing[vm_i] == "Disabled" and use_same_cpu:
key = "uos:id={},{}".format(vm_i, item)
ERR_LIST[key] = "The same pcpu was configurated in scenario config, and not allow to set the cpu_sharing to 'Disabled'!"
return