mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-07 07:56:56 +00:00
acrn-config: add virtio-input support for launch
config Add support to parse and get 'virtio-input' item value from launch config files, these values are editable by user. Tracked-On: #4163 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
9fc32043aa
commit
bc9b6d1b0c
@ -290,11 +290,11 @@ def save_launch():
|
|||||||
# call validate function
|
# call validate function
|
||||||
rename = False
|
rename = False
|
||||||
try:
|
try:
|
||||||
(error_list, pthru_sel, dm_value) = validate_launch_setting(
|
(error_list, pthru_sel, virtio, dm_value) = validate_launch_setting(
|
||||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', xml_configs[0]+'.xml'),
|
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res', xml_configs[0]+'.xml'),
|
||||||
scenario_file_path,
|
scenario_file_path,
|
||||||
tmp_launch_file)
|
tmp_launch_file)
|
||||||
print(pthru_sel, dm_value)
|
print(pthru_sel, virtio, dm_value)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
if os.path.isfile(tmp_launch_file):
|
if os.path.isfile(tmp_launch_file):
|
||||||
os.remove(tmp_launch_file)
|
os.remove(tmp_launch_file)
|
||||||
|
@ -426,7 +426,16 @@ def xhci_args_set(names, vmid, config):
|
|||||||
print(" -s {},xhci,1-2:2-4 \\".format(launch_cfg_lib.virtual_dev_slot("xhci")), file=config)
|
print(" -s {},xhci,1-2:2-4 \\".format(launch_cfg_lib.virtual_dev_slot("xhci")), file=config)
|
||||||
|
|
||||||
|
|
||||||
def dm_arg_set(names, sel, dm, vmid, config):
|
def vritio_args_set(virt_io, vmid, config):
|
||||||
|
|
||||||
|
# virtio-input set, the value type is a list
|
||||||
|
for input_val in virt_io['input'][vmid]:
|
||||||
|
if input_val:
|
||||||
|
print(" -s {},virtio-input,{} \\".format(
|
||||||
|
launch_cfg_lib.virtual_dev_slot("virtio-input{}".format(input_val)), input_val), file=config)
|
||||||
|
|
||||||
|
|
||||||
|
def dm_arg_set(names, sel, virt_io, dm, vmid, config):
|
||||||
|
|
||||||
uos_type = names['uos_types'][vmid]
|
uos_type = names['uos_types'][vmid]
|
||||||
board_name = names['board_name']
|
board_name = names['board_name']
|
||||||
@ -498,6 +507,9 @@ def dm_arg_set(names, sel, dm, vmid, config):
|
|||||||
# WA: XHCI args set
|
# WA: XHCI args set
|
||||||
xhci_args_set(names, vmid, config)
|
xhci_args_set(names, vmid, config)
|
||||||
|
|
||||||
|
# VIRTIO args set
|
||||||
|
vritio_args_set(virt_io, vmid, config)
|
||||||
|
|
||||||
# GVT args set
|
# GVT args set
|
||||||
gvt_arg_set(uos_type, config)
|
gvt_arg_set(uos_type, config)
|
||||||
|
|
||||||
@ -545,7 +557,7 @@ def dm_arg_set(names, sel, dm, vmid, config):
|
|||||||
print("}", file=config)
|
print("}", file=config)
|
||||||
|
|
||||||
|
|
||||||
def gen(names, pt_sel, dm, vmid, config):
|
def gen(names, pt_sel, virt_io, dm, vmid, config):
|
||||||
|
|
||||||
board_name = names['board_name']
|
board_name = names['board_name']
|
||||||
uos_type = names['uos_types'][vmid]
|
uos_type = names['uos_types'][vmid]
|
||||||
@ -566,7 +578,7 @@ def gen(names, pt_sel, dm, vmid, config):
|
|||||||
log_level_set(uos_type, config)
|
log_level_set(uos_type, config)
|
||||||
|
|
||||||
# gen acrn-dm args
|
# gen acrn-dm args
|
||||||
dm_arg_set(names, pt_sel, dm, vmid, config)
|
dm_arg_set(names, pt_sel, virt_io, dm, vmid, config)
|
||||||
|
|
||||||
# gen launch end
|
# gen launch end
|
||||||
launch_end(names, dm, vmid, config)
|
launch_end(names, dm, vmid, config)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
|
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'library'))
|
||||||
from launch_item import AvailablePthru, PthruSelected, AcrnDmArgs
|
from launch_item import AvailablePthru, PthruSelected, VirtioDeviceSelect, AcrnDmArgs
|
||||||
import launch_cfg_lib
|
import launch_cfg_lib
|
||||||
import com
|
import com
|
||||||
|
|
||||||
@ -21,6 +21,7 @@ def get_launch_item_values(board_info):
|
|||||||
"""
|
"""
|
||||||
launch_item_values = {}
|
launch_item_values = {}
|
||||||
|
|
||||||
|
# passthrough devices
|
||||||
pthru = AvailablePthru(board_info)
|
pthru = AvailablePthru(board_info)
|
||||||
pthru.get_pci_dev()
|
pthru.get_pci_dev()
|
||||||
pthru.insert_nun()
|
pthru.insert_nun()
|
||||||
@ -66,19 +67,21 @@ def validate_launch_setting(board_info, scenario_info, launch_info):
|
|||||||
# init available pt devices and get selected pt devices
|
# init available pt devices and get selected pt devices
|
||||||
pt_avl = AvailablePthru(board_info)
|
pt_avl = AvailablePthru(board_info)
|
||||||
pt_sel = PthruSelected(launch_info, pt_avl.bdf_desc_map, pt_avl.bdf_vpid_map)
|
pt_sel = PthruSelected(launch_info, pt_avl.bdf_desc_map, pt_avl.bdf_vpid_map)
|
||||||
dm = AcrnDmArgs(board_info, scenario_info, launch_info)
|
|
||||||
|
|
||||||
# get bdf/vpid list from config xml
|
|
||||||
pt_sel.get_bdf()
|
pt_sel.get_bdf()
|
||||||
pt_sel.get_vpid()
|
pt_sel.get_vpid()
|
||||||
pt_sel.get_slot()
|
pt_sel.get_slot()
|
||||||
dm.get_args()
|
|
||||||
|
|
||||||
# check items in config xml
|
|
||||||
pt_sel.check_item()
|
pt_sel.check_item()
|
||||||
|
|
||||||
|
# virt-io devices
|
||||||
|
virtio = VirtioDeviceSelect(launch_info)
|
||||||
|
virtio.get_virtio()
|
||||||
|
|
||||||
|
# acrn dm arguments
|
||||||
|
dm = AcrnDmArgs(board_info, scenario_info, launch_info)
|
||||||
|
dm.get_args()
|
||||||
dm.check_item()
|
dm.check_item()
|
||||||
|
|
||||||
return (launch_cfg_lib.ERR_LIST, pt_sel, dm)
|
return (launch_cfg_lib.ERR_LIST, pt_sel, virtio, dm)
|
||||||
|
|
||||||
|
|
||||||
def ui_entry_api(board_info, scenario_info, launch_info, enable_commit=False):
|
def ui_entry_api(board_info, scenario_info, launch_info, enable_commit=False):
|
||||||
@ -122,7 +125,7 @@ def get_names():
|
|||||||
return (err_dic, names)
|
return (err_dic, names)
|
||||||
|
|
||||||
|
|
||||||
def generate_script_file(names, pt_sel, dm, vmid, config):
|
def generate_script_file(names, pt_sel, virt_io, dm, vmid, config):
|
||||||
|
|
||||||
uos_type = names['uos_types'][vmid]
|
uos_type = names['uos_types'][vmid]
|
||||||
board_name = names['board_name']
|
board_name = names['board_name']
|
||||||
@ -133,7 +136,7 @@ def generate_script_file(names, pt_sel, dm, vmid, config):
|
|||||||
board_name.upper(), scenario_name.upper(), uos_type.upper())
|
board_name.upper(), scenario_name.upper(), uos_type.upper())
|
||||||
|
|
||||||
print("{}".format(header_info), file=config)
|
print("{}".format(header_info), file=config)
|
||||||
com.gen(names, pt_sel, dm, vmid, config)
|
com.gen(names, pt_sel, virt_io, dm, vmid, config)
|
||||||
if launch_cfg_lib.ERR_LIST:
|
if launch_cfg_lib.ERR_LIST:
|
||||||
return launch_cfg_lib.ERR_LIST
|
return launch_cfg_lib.ERR_LIST
|
||||||
|
|
||||||
@ -184,7 +187,7 @@ def main(args):
|
|||||||
return err_dic
|
return err_dic
|
||||||
|
|
||||||
# validate launch config file
|
# validate launch config file
|
||||||
(err_dic, pt_sel, dm) = validate_launch_setting(board_info_file, scenario_info_file, launch_info_file)
|
(err_dic, pt_sel, virt_io, dm) = validate_launch_setting(board_info_file, scenario_info_file, launch_info_file)
|
||||||
if err_dic:
|
if err_dic:
|
||||||
return err_dic
|
return err_dic
|
||||||
|
|
||||||
@ -210,7 +213,7 @@ def main(args):
|
|||||||
launch_script_file = output + script_name
|
launch_script_file = output + script_name
|
||||||
config_srcs.append(launch_script_file)
|
config_srcs.append(launch_script_file)
|
||||||
with open(launch_script_file, mode = 'w', newline=None, encoding='utf-8') as config:
|
with open(launch_script_file, mode = 'w', newline=None, encoding='utf-8') as config:
|
||||||
err_dic = generate_script_file(names, pt_sel, dm.args, vm_th, config)
|
err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, vm_th, config)
|
||||||
if err_dic:
|
if err_dic:
|
||||||
return err_dic
|
return err_dic
|
||||||
else:
|
else:
|
||||||
@ -219,7 +222,7 @@ def main(args):
|
|||||||
launch_script_file = output + script_name
|
launch_script_file = output + script_name
|
||||||
config_srcs.append(launch_script_file)
|
config_srcs.append(launch_script_file)
|
||||||
with open(launch_script_file, mode = 'w', newline='\n', encoding='utf-8') as config:
|
with open(launch_script_file, mode = 'w', newline='\n', encoding='utf-8') as config:
|
||||||
err_dic = generate_script_file(names, pt_sel, dm.args, post_vm_i, config)
|
err_dic = generate_script_file(names, pt_sel, virt_io.dev, dm.args, post_vm_i, config)
|
||||||
if err_dic:
|
if err_dic:
|
||||||
return err_dic
|
return err_dic
|
||||||
|
|
||||||
|
@ -142,3 +142,13 @@ class PthruSelected():
|
|||||||
launch_cfg_lib.pt_devs_check(self.bdf["audio_codec"], self.vpid["audio_codec"], "audio_codec")
|
launch_cfg_lib.pt_devs_check(self.bdf["audio_codec"], self.vpid["audio_codec"], "audio_codec")
|
||||||
launch_cfg_lib.pt_devs_check(self.bdf["wifi"], self.vpid["wifi"], "wifi")
|
launch_cfg_lib.pt_devs_check(self.bdf["wifi"], self.vpid["wifi"], "wifi")
|
||||||
launch_cfg_lib.pt_devs_check(self.bdf["bluetooth"], self.vpid["bluetooth"], "bluetooth")
|
launch_cfg_lib.pt_devs_check(self.bdf["bluetooth"], self.vpid["bluetooth"], "bluetooth")
|
||||||
|
|
||||||
|
|
||||||
|
class VirtioDeviceSelect():
|
||||||
|
|
||||||
|
dev = {}
|
||||||
|
def __init__(self, launch_info):
|
||||||
|
self.launch_info = launch_info
|
||||||
|
|
||||||
|
def get_virtio(self):
|
||||||
|
self.dev["input"] = launch_cfg_lib.get_leaf_tag_map(self.launch_info, "virtio_devices", "input")
|
||||||
|
@ -23,7 +23,7 @@ GUEST_FLAG = ["0UL", "GUEST_FLAG_SECURE_WORLD_ENABLED", "GUEST_FLAG_LAPIC_PASSTH
|
|||||||
START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE', 'VM0_MEM_SIZE']
|
START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE', 'VM0_MEM_SIZE']
|
||||||
|
|
||||||
|
|
||||||
MULTI_ITEM = ["guest_flag", "pcpu_id"]
|
MULTI_ITEM = ["guest_flag", "pcpu_id", "input"]
|
||||||
|
|
||||||
|
|
||||||
class MultiItem():
|
class MultiItem():
|
||||||
@ -31,6 +31,7 @@ class MultiItem():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.guest_flag = []
|
self.guest_flag = []
|
||||||
self.pcpu_id = []
|
self.pcpu_id = []
|
||||||
|
self.vir_input = []
|
||||||
self.vir_console = []
|
self.vir_console = []
|
||||||
self.vir_net = []
|
self.vir_net = []
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ class TmpItem():
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.tag = {}
|
self.tag = {}
|
||||||
self.multi = MultiItem
|
self.multi = MultiItem()
|
||||||
|
|
||||||
def open_license():
|
def open_license():
|
||||||
""" Get the license """
|
""" Get the license """
|
||||||
@ -410,6 +411,10 @@ def get_leaf_value(tmp, tag_str, leaf):
|
|||||||
if leaf.tag == "pcpu_id" and tag_str == "pcpu_id":
|
if leaf.tag == "pcpu_id" and tag_str == "pcpu_id":
|
||||||
tmp.multi.pcpu_id.append(leaf.text)
|
tmp.multi.pcpu_id.append(leaf.text)
|
||||||
|
|
||||||
|
# get virtio-input for vm
|
||||||
|
if leaf.tag == "input" and tag_str == "input":
|
||||||
|
tmp.multi.vir_input.append(leaf.text)
|
||||||
|
|
||||||
|
|
||||||
def get_sub_value(tmp, tag_str, vm_id):
|
def get_sub_value(tmp, tag_str, vm_id):
|
||||||
|
|
||||||
@ -422,6 +427,10 @@ def get_sub_value(tmp, tag_str, vm_id):
|
|||||||
if tmp.multi.pcpu_id and tag_str == "pcpu_id":
|
if tmp.multi.pcpu_id and tag_str == "pcpu_id":
|
||||||
tmp.tag[vm_id] = tmp.multi.pcpu_id
|
tmp.tag[vm_id] = tmp.multi.pcpu_id
|
||||||
|
|
||||||
|
# append input for vm
|
||||||
|
if tmp.multi.vir_input and tag_str == "input":
|
||||||
|
tmp.tag[vm_id] = tmp.multi.vir_input
|
||||||
|
|
||||||
|
|
||||||
def get_leaf_tag_map(config_file, branch_tag, tag_str):
|
def get_leaf_tag_map(config_file, branch_tag, tag_str):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user