From 4f5885c271b67e8bcdf890220561a40a2fdddfce Mon Sep 17 00:00:00 2001 From: Shuang Zheng Date: Tue, 20 Oct 2020 20:02:06 +0800 Subject: [PATCH] acrn-config: add PCI VUART config in launch config UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add PCI VUART config for post-launched VMs in launch config UI. Users can configure the console_vuart, configure or dynamically add or remove communication_vuart based on the communication vuarts which are configured from the scenario xml. Tracked-On: #5394 Signed-off-by: Shuang Zheng --- misc/acrn-config/config_app/static/main.js | 3 ++- .../config_app/templates/launch.html | 10 ++++---- .../launch_config/launch_cfg_gen.py | 1 + misc/acrn-config/library/launch_cfg_lib.py | 24 +++++++++++++++++++ misc/acrn-config/library/scenario_cfg_lib.py | 1 + 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/misc/acrn-config/config_app/static/main.js b/misc/acrn-config/config_app/static/main.js index 7c213fe38..221da6ef5 100644 --- a/misc/acrn-config/config_app/static/main.js +++ b/misc/acrn-config/config_app/static/main.js @@ -1003,7 +1003,8 @@ function save_launch(generator=null) { $("select").each(function(){ var id = $(this).attr('id'); var value = $(this).val(); - if(id.indexOf('pcpu_id')>=0 || id.indexOf('shm_region')>=0 || id.indexOf('pci_dev')>=0) { + if(id.indexOf('pcpu_id')>=0 || id.indexOf('shm_region')>=0 + || id.indexOf('communication_vuart')>=0 || id.indexOf('pci_dev')>=0) { if(id in launch_config) { launch_config[id].push(value); } else { diff --git a/misc/acrn-config/config_app/templates/launch.html b/misc/acrn-config/config_app/templates/launch.html index f9eb6efc2..0008bead8 100644 --- a/misc/acrn-config/config_app/templates/launch.html +++ b/misc/acrn-config/config_app/templates/launch.html @@ -207,7 +207,7 @@ the launch scripts will be generated into misc/acrn-config/xmls/config-xmls/[boa {% elif elem.getchildren() != [] %} {% if 'multiselect' not in elem.attrib or elem.attrib['multiselect'] != 'true' %} {% set first_multi_child = {'block': 0, 'network': 0, 'input': 0, 'pcpu_id': 0, 'shm_region': 0, - 'passthrough_devices': 0, 'virtio_devices': 0} %} + 'passthrough_devices': 0, 'virtio_devices': 0, 'communication_vuart': 0} %} {% for sub_elem in elem.getchildren() %} {% set sub_elem_text = '' if sub_elem.text == None else sub_elem.text %} {% if 'configurable' not in sub_elem.attrib or sub_elem.attrib['configurable'] != '0' %} @@ -218,7 +218,7 @@ the launch scripts will be generated into misc/acrn-config/xmls/config-xmls/[boa title="{{sub_elem.attrib['desc'] if 'desc' in sub_elem.attrib else sub_elem.tag}}"> {{elem.tag}} {% do first_multi_child.update({elem.tag: first_multi_child[elem.tag]+1}) %} - {% elif sub_elem.tag in ['pcpu_id', 'shm_region'] and first_multi_child[sub_elem.tag] == 0 %} + {% elif sub_elem.tag in ['pcpu_id', 'shm_region', 'communication_vuart'] and first_multi_child[sub_elem.tag] == 0 %} @@ -233,7 +233,7 @@ the launch scripts will be generated into misc/acrn-config/xmls/config-xmls/[boa {{sub_elem.tag}} {% if ','.join(['uos', elem.tag, sub_elem.tag]) not in launch_item_values - and elem.tag != 'cpu_affinity' and elem.tag != 'shm_regions'%} + and elem.tag not in ['cpu_affinity', 'shm_regions', 'communication_vuarts']%}
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %} - {% if elem.tag in ['cpu_affinity', 'shm_regions'] %} + {% if elem.tag in ['cpu_affinity', 'shm_regions', 'communication_vuarts'] %} {% if not first_multi_child[sub_elem.tag] %} diff --git a/misc/acrn-config/launch_config/launch_cfg_gen.py b/misc/acrn-config/launch_config/launch_cfg_gen.py index 2433ed471..955bf5286 100644 --- a/misc/acrn-config/launch_config/launch_cfg_gen.py +++ b/misc/acrn-config/launch_config/launch_cfg_gen.py @@ -53,6 +53,7 @@ def get_launch_item_values(board_info, scenario_info=None): launch_item_values['uos,poweroff_channel'] = launch_cfg_lib.PM_CHANNEL launch_item_values["uos,cpu_affinity"] = board_cfg_lib.get_processor_info() launch_cfg_lib.set_shm_regions(launch_item_values, scenario_info) + launch_cfg_lib.set_pci_vuarts(launch_item_values, scenario_info) return launch_item_values diff --git a/misc/acrn-config/library/launch_cfg_lib.py b/misc/acrn-config/library/launch_cfg_lib.py index a6b83d62c..5ebd1b39a 100644 --- a/misc/acrn-config/library/launch_cfg_lib.py +++ b/misc/acrn-config/library/launch_cfg_lib.py @@ -599,6 +599,30 @@ def set_shm_regions(launch_item_values, scenario_info): print(e) +def set_pci_vuarts(launch_item_values, scenario_info): + try: + launch_item_values['uos,console_vuart'] = DM_VUART0 + vm_types = common.get_leaf_tag_map(scenario_info, 'vm_type') + sos_vm_id = 0 + for vm_id, vm_type in vm_types.items(): + if vm_type in ['SOS_VM']: + sos_vm_id = vm_id + for vm in common.get_config_root(scenario_info).getchildren(): + if vm.tag == 'vm' and scenario_cfg_lib.VM_DB[vm_types[int(vm.attrib['id'])]]['load_type'] == 'POST_LAUNCHED_VM': + uos_id = int(vm.attrib['id']) - sos_vm_id + pci_vuart_key = 'uos:id={},communication_vuarts,communication_vuart'.format(uos_id) + for elem in vm.getchildren(): + if elem.tag == 'communication_vuart': + for sub_elem in elem.getchildren(): + if sub_elem.tag == 'base' and sub_elem.text == 'PCI_VUART': + if pci_vuart_key not in launch_item_values.keys(): + launch_item_values[pci_vuart_key] = ['', elem.attrib['id']] + else: + launch_item_values[pci_vuart_key].append(elem.attrib['id']) + except: + return + + def check_shm_regions(launch_shm_regions, scenario_info): launch_item_values = {} set_shm_regions(launch_item_values, scenario_info) diff --git a/misc/acrn-config/library/scenario_cfg_lib.py b/misc/acrn-config/library/scenario_cfg_lib.py index d65cda240..c357a1f22 100644 --- a/misc/acrn-config/library/scenario_cfg_lib.py +++ b/misc/acrn-config/library/scenario_cfg_lib.py @@ -55,6 +55,7 @@ UUID_DB = { VM_DB = { 'SOS_VM':{'load_type':'SOS_VM', 'severity':'SEVERITY_SOS', 'uuid':UUID_DB['SOS_VM']}, 'SAFETY_VM':{'load_type':'PRE_LAUNCHED_VM', 'severity':'SEVERITY_SAFETY_VM', 'uuid':UUID_DB['SAFETY_VM']}, + 'PRE_RT_VM':{'load_type':'PRE_LAUNCHED_VM', 'severity':'SEVERITY_RTVM', 'uuid':UUID_DB['PRE_RT_VM']}, 'PRE_STD_VM':{'load_type':'PRE_LAUNCHED_VM', 'severity':'SEVERITY_STANDARD_VM', 'uuid':UUID_DB['PRE_STD_VM']}, 'POST_STD_VM':{'load_type':'POST_LAUNCHED_VM', 'severity':'SEVERITY_STANDARD_VM', 'uuid':UUID_DB['POST_STD_VM']}, 'POST_RT_VM':{'load_type':'POST_LAUNCHED_VM', 'severity':'SEVERITY_RTVM', 'uuid':UUID_DB['POST_RT_VM']},