acrn-config: update UI to support virtio devices

Add multi device editing UI for Virtio-net and virtio-blk devices.

Tracked-On: #4185
Signed-off-by: Shuang Zheng <shuang.zheng@intel.com>
This commit is contained in:
Shuang Zheng 2019-12-03 16:38:28 +08:00 committed by wenlingz
parent 5309e41528
commit 5eb8040284
3 changed files with 30 additions and 3 deletions

View File

@ -163,11 +163,17 @@ class XmlConfig:
tag = args[-1]
args = args[:-1]
dest_node = self._get_dest_node(*args)
new_node_desc = None
for node in dest_node.getchildren():
dest_node.remove(node)
if node.tag == tag:
if 'desc' in node.attrib:
new_node_desc = node.attrib['desc']
dest_node.remove(node)
for value in values:
new_node = ElementTree.SubElement(dest_node, tag)
new_node.text = value
if new_node_desc is not None:
new_node.attrib['desc'] = new_node_desc
def set_curr_attr(self, attr_name, attr_value, *args):
"""

View File

@ -510,7 +510,14 @@ function save_launch(generator=null) {
$("input").each(function(){
var id = $(this).attr('id');
var value = $(this).val();
if(id!='new_launch_name' && id!='board_info_file'
if(id.indexOf('virtio_devices,network')>=0 || id.indexOf('virtio_devices,block')>=0) {
if(id in launch_config) {
launch_config[id].push(value);
} else {
launch_config[id] = [value];
}
} else if(id!='new_launch_name' && id!='board_info_file'
&& id!='board_info_upload' && id!='scenario_name'
&& id!="launch_file") {
launch_config[id] = value;

View File

@ -157,6 +157,7 @@
{% elif elem.getchildren() != [] %}
{% if 'multiselect' not in elem.attrib or elem.attrib['multiselect'] != 'true' %}
{% set first_child = [] %}
{% set first_multi_child = {'block': 0, 'network': 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' %}
@ -178,7 +179,7 @@
{{sub_elem.tag}}</label>
{% if ','.join(['uos', elem.tag, sub_elem.tag]) not in launch_item_values %}
<div class="col-sm-6">
<div class="col-sm-5">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}
<input type="text" class="form-control" readonly
id="{{'uos:id='+vm.attrib['id']+','+elem.tag+','+sub_elem.tag}}"
@ -189,6 +190,19 @@
value="{{sub_elem_text}}">
{% endif %}
</div>
{% if elem.tag in ['virtio_devices'] and sub_elem.tag in ['block', 'network'] %}
<div class="col-sm-1">
<button type="button" class="btn" id="add_virtio_{{sub_elem.tag}}_{{first_multi_child[sub_elem.tag]}}">+</button>
{% if first_multi_child[sub_elem.tag] == 0 %}
<button type="button" disabled class="btn" id="remove_virtio_{{sub_elem.tag}}_{{first_multi_child[sub_elem.tag]}}">-</button>
{% else %}
<button type="button" class="btn" id="remove_virtio_{{sub_elem.tag}}_{{first_multi_child[sub_elem.tag]}}">-</button>
{% endif %}
</div>
{% do first_multi_child.update({sub_elem.tag: first_multi_child[sub_elem.tag]+1}) %}
{% endif%}
{% else %}
<div class="dropdown col-sm-6">
{% if 'readonly' in sub_elem.attrib and sub_elem.attrib['readonly'] == 'true' %}