mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-15 06:44:58 +00:00
config-tools: remove obsolete files of launch configuration
With the launch script generation script rewritten, some other files under launch_config are no longer used. This patch removes these obsoleted files. Tracked-On: #6690 Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
parent
2450b4c77f
commit
5b9c45da17
@ -1,684 +0,0 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import scenario_cfg_lib
|
||||
import launch_cfg_lib
|
||||
import lxml.etree
|
||||
import common
|
||||
import pt
|
||||
|
||||
|
||||
def is_nuc_whl_linux(names, vmid):
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
board_name = names['board_name']
|
||||
|
||||
if launch_cfg_lib.is_linux_like(user_vm_type) and board_name not in ("apl-mrb", "apl-up2"):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def is_mount_needed(virt_io, vmid):
|
||||
|
||||
if True in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def tap_user_vm_net(names, virt_io, vmid, config):
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
board_name = names['board_name']
|
||||
|
||||
vm_name = names['user_vm_names'][vmid]
|
||||
|
||||
if launch_cfg_lib.is_linux_like(user_vm_type) or user_vm_type in ("ANDROID", "ALIOS"):
|
||||
i = 0
|
||||
for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
|
||||
if not mount_flag:
|
||||
i += 1
|
||||
continue
|
||||
blk = virt_io['block'][vmid][i]
|
||||
rootfs_img = blk.split(':')[1].strip(':')
|
||||
print('if [ ! -f "/data{}/{}" ]; then'.format(i, rootfs_img), file=config)
|
||||
print(' echo "no /data{}/{}, exit"'.format(i, rootfs_img), file=config)
|
||||
print(" exit", file=config)
|
||||
print("fi", file=config)
|
||||
print("", file=config)
|
||||
i += 1
|
||||
|
||||
print("#vm-name used to generate user-vm-mac address", file=config)
|
||||
print("mac=$(cat /sys/class/net/e*/address)", file=config)
|
||||
print("vm_name=\"{}\"".format(vm_name), file=config)
|
||||
print("mac_seed=${mac:0:17}-${vm_name}", file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
||||
for net in virt_io['network'][vmid]:
|
||||
if net:
|
||||
net_name = net
|
||||
if ',' in net:
|
||||
net_name = net.split(',')[0]
|
||||
print("tap_net tap_{}".format(net_name), file=config)
|
||||
|
||||
print("#check if the vm is running or not", file=config)
|
||||
print("vm_ps=$(pgrep -a -f acrn-dm)", file=config)
|
||||
print('result=$(echo $vm_ps | grep -w "${vm_name}")', file=config)
|
||||
print('if [[ "$result" != "" ]]; then', file=config)
|
||||
print(' echo "$vm_name is running, can\'t create twice!"', file=config)
|
||||
print(" exit", file=config)
|
||||
print("fi", file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
||||
def off_line_cpus(args, vmid, user_vm_type, config):
|
||||
"""
|
||||
:param args: the dictionary of argument for acrn-dm
|
||||
:param vmid: ID of the vm
|
||||
:param user_vm_type: the type of User VM
|
||||
:param config: it is a file pointer to write offline cpu information
|
||||
"""
|
||||
pcpu_id_list = get_cpu_affinity_list(args["cpu_affinity"], vmid)
|
||||
if not pcpu_id_list:
|
||||
sos_vmid = launch_cfg_lib.get_sos_vmid()
|
||||
cpu_affinity = common.get_leaf_tag_map(common.SCENARIO_INFO_FILE, "cpu_affinity", "pcpu_id")
|
||||
pcpu_id_list = get_cpu_affinity_list(cpu_affinity, sos_vmid+vmid)
|
||||
|
||||
if not pcpu_id_list:
|
||||
key = "scenario config error"
|
||||
launch_cfg_lib.ERR_LIST[key] = "No available cpu to offline and pass it to vm {}".format(vmid)
|
||||
|
||||
print("# offline pinned vCPUs from Service VM before launch User VM", file=config)
|
||||
print('cpu_path="/sys/devices/system/cpu"', file=config)
|
||||
print("for i in `ls ${cpu_path}`; do", file=config)
|
||||
print(" for j in {}; do".format(' '.join([str(i) for i in pcpu_id_list])), file=config)
|
||||
print(' if [ "cpu"$j = $i ]; then', file=config)
|
||||
print(' online=`cat ${cpu_path}/$i/online`', file=config)
|
||||
print(' idx=`echo $i | tr -cd "[0-9]"`', file=config)
|
||||
print(' echo $i online=$online', file=config)
|
||||
print(' if [ "$online" = "1" ] && [ "$idx" != "0" ]; then', file=config)
|
||||
print(" echo 0 > ${cpu_path}/$i/online", file=config)
|
||||
print(" online=`cat ${cpu_path}/$i/online`", file=config)
|
||||
print(" # during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod", file=config)
|
||||
print(' while [ "$online" = "1" ]; do', file=config)
|
||||
print(" sleep 1", file=config)
|
||||
print(" echo 0 > ${cpu_path}/$i/online", file=config)
|
||||
print(" online=`cat ${cpu_path}/$i/online`", file=config)
|
||||
print(" done", file=config)
|
||||
print(" echo $idx > /sys/devices/virtual/misc/acrn_hsm/remove_cpu", file=config)
|
||||
print(" fi", file=config)
|
||||
print(" fi", file=config)
|
||||
print(" done", file=config)
|
||||
print("done", file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
||||
def run_container(board_name, user_vm_type, config):
|
||||
"""
|
||||
The container contains the clearlinux as rootfs
|
||||
:param board_name: board name
|
||||
:param user_vm_type: the os name of user os
|
||||
:param config: the file pointer to store the information
|
||||
"""
|
||||
# the runC.json is store in the path under board name, but for nuc7i7dnb/nuc6cayh/kbl-nuc-i7 is under nuc/
|
||||
if 'nuc' in board_name:
|
||||
board_name = 'nuc'
|
||||
|
||||
if board_name not in ("apl-mrb", "nuc") or not launch_cfg_lib.is_linux_like(user_vm_type):
|
||||
return
|
||||
|
||||
print("function run_container()", file=config)
|
||||
print("{", file=config)
|
||||
print("vm_name=vm1", file=config)
|
||||
print('config_src="/usr/share/acrn/samples/{}/runC.json"'.format(board_name), file=config)
|
||||
print('shell="/usr/share/acrn/conf/add/$vm_name.sh"', file=config)
|
||||
print('arg_file="/usr/share/acrn/conf/add/$vm_name.args"', file=config)
|
||||
print('runc_bundle="/usr/share/acrn/conf/add/runc/$vm_name"', file=config)
|
||||
print('rootfs_dir="/usr/share/acrn/conf/add/runc/rootfs"', file=config)
|
||||
print('config_dst="$runc_bundle/config.json"', file=config)
|
||||
print("", file=config)
|
||||
print("", file=config)
|
||||
print("input=$(runc list -f table | awk '{print $1}''{print $3}')", file=config)
|
||||
print("arr=(${input// / })", file=config)
|
||||
print("", file=config)
|
||||
print("for((i=0;i<${#arr[@]};i++))", file=config)
|
||||
print("do", file=config)
|
||||
print(' if [ "$vm_name" = "${arr[$i]}" ]; then', file=config)
|
||||
print(' if [ "running" = "${arr[$i+1]}" ]; then', file=config)
|
||||
print(' echo "runC instance ${arr[$i]} is running"', file=config)
|
||||
print(" exit", file=config)
|
||||
print(" else", file=config)
|
||||
print(" runc kill ${arr[$i]}", file=config)
|
||||
print(" runc delete ${arr[$i]}", file=config)
|
||||
print(" fi", file=config)
|
||||
print(" fi", file=config)
|
||||
print("done", file=config)
|
||||
print("vmsts=$(acrnctl list)", file=config)
|
||||
print("vms=(${vmsts// / })", file=config)
|
||||
print("for((i=0;i<${#vms[@]};i++))", file=config)
|
||||
print("do", file=config)
|
||||
print(' if [ "$vm_name" = "${vms[$i]}" ]; then', file=config)
|
||||
print(' if [ "stopped" != "${vms[$i+1]}" ]; then', file=config)
|
||||
print(' echo "Uos ${vms[$i]} ${vms[$i+1]}"', file=config)
|
||||
print(" acrnctl stop ${vms[$i]}", file=config)
|
||||
print(" fi", file=config)
|
||||
print(" fi", file=config)
|
||||
print("done", file=config)
|
||||
|
||||
dst_str = """ cp "$config_src" "$config_dst"
|
||||
args=$(sed '{s/-C//g;s/^[ \\t]*//g;s/^/\\"/;s/ /\\",\\"/g;s/$/\\"/}' ${arg_file})
|
||||
sed -i "s|\\"sh\\"|\\"$shell\\", $args|" $config_dst"""
|
||||
print('', file=config)
|
||||
print('if [ ! -f "$shell" ]; then', file=config)
|
||||
print(' echo "Pls add the vm at first!"', file=config)
|
||||
print(' exit', file=config)
|
||||
print('fi', file=config)
|
||||
print('', file=config)
|
||||
print('if [ ! -f "$arg_file" ]; then', file=config)
|
||||
print(' echo "Pls add the vm args!"', file=config)
|
||||
print(' exit', file=config)
|
||||
print('fi', file=config)
|
||||
print('', file=config)
|
||||
print('if [ ! -d "$rootfs_dir" ]; then', file=config)
|
||||
print(' mkdir -p "$rootfs_dir"', file=config)
|
||||
print('fi', file=config)
|
||||
print('if [ ! -d "$runc_bundle" ]; then', file=config)
|
||||
print(' mkdir -p "$runc_bundle"', file=config)
|
||||
print('fi', file=config)
|
||||
print('if [ ! -f "$config_dst" ]; then', file=config)
|
||||
print('{}'.format(dst_str), file=config)
|
||||
print('fi', file=config)
|
||||
print('runc run --bundle $runc_bundle -d $vm_name', file=config)
|
||||
print('echo "The runC container is running in backgroud"', file=config)
|
||||
print('echo "\'#runc exec <vmname> bash\' to login the container bash"', file=config)
|
||||
print('exit', file=config)
|
||||
print('}', file=config)
|
||||
print('', file=config)
|
||||
|
||||
|
||||
def interrupt_storm(pt_sel, config):
|
||||
if not pt_sel:
|
||||
return
|
||||
|
||||
# TODO: --intr_monitor should be configurable by user
|
||||
print("#interrupt storm monitor for pass-through devices, params order:", file=config)
|
||||
print("#threshold/s,probe-period(s),intr-inject-delay-time(ms),delay-duration(ms)", file=config)
|
||||
print('intr_storm_monitor="--intr_monitor 10000,10,1,100"', file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
||||
def gpu_pt_arg_set(dm, sel, vmid, config):
|
||||
gpu_bdf = sel.bdf["gpu"][vmid]
|
||||
|
||||
if gpu_bdf:
|
||||
print(' -s 2,passthru,{}/{}/{} \\'.format(gpu_bdf[0:2], gpu_bdf[3:5], gpu_bdf[6:7]), file=config)
|
||||
|
||||
|
||||
def log_level_set(user_vm_type, config):
|
||||
|
||||
print("#logger_setting, format: logger_name,level; like following", file=config)
|
||||
print('logger_setting="--logger_setting console,level=4;kmsg,level=3;disk,level=5"', file=config)
|
||||
print("", file=config)
|
||||
|
||||
def tap_network(virt_io, vmid, config):
|
||||
|
||||
none_i = 0
|
||||
tap_net_list = virt_io['network'][vmid]
|
||||
for net in tap_net_list:
|
||||
if net == None:
|
||||
none_i += 1
|
||||
tap_net_num = len(tap_net_list) - none_i
|
||||
|
||||
if tap_net_num >= 1:
|
||||
print("function tap_net() {", file=config)
|
||||
print("# create a unique tap device for each VM", file=config)
|
||||
print("tap=$1", file=config)
|
||||
print('tap_exist=$(ip a | grep "$tap" | awk \'{print $1}\')', file=config)
|
||||
print('if [ "$tap_exist"x != "x" ]; then', file=config)
|
||||
print(' echo "tap device existed, reuse $tap"', file=config)
|
||||
print("else", file=config)
|
||||
print(" ip tuntap add dev $tap mode tap", file=config)
|
||||
print("fi", file=config)
|
||||
print("", file=config)
|
||||
print("# if acrn-br0 exists, add VM's unique tap device under it", file=config)
|
||||
print("br_exist=$(ip a | grep acrn-br0 | awk '{print $1}')", file=config)
|
||||
print('if [ "$br_exist"x != "x" -a "$tap_exist"x = "x" ]; then', file=config)
|
||||
print(' echo "acrn-br0 bridge aleady exists, adding new tap device to it..."', file=config)
|
||||
print(' ip link set "$tap" master acrn-br0', file=config)
|
||||
print(' ip link set dev "$tap" down', file=config)
|
||||
print(' ip link set dev "$tap" up', file=config)
|
||||
print("fi", file=config)
|
||||
print("}", file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
||||
def launch_begin(names, virt_io, vmid, config):
|
||||
board_name = names['board_name']
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
|
||||
launch_uos = common.undline_name(user_vm_type).lower()
|
||||
tap_network(virt_io, vmid, config)
|
||||
run_container(board_name, user_vm_type, config)
|
||||
print("function launch_{}()".format(launch_uos), file=config)
|
||||
print("{", file=config)
|
||||
|
||||
|
||||
def wa_usage(user_vm_type, config):
|
||||
if user_vm_type in ("ANDROID", "ALIOS"):
|
||||
print("# WA for USB role switch hang issue, disable runtime PM of xHCI device", file=config)
|
||||
print("echo on > /sys/devices/pci0000:00/0000:00:15.0/power/control", file=config)
|
||||
print("", file=config)
|
||||
|
||||
def mem_size_set(args, vmid, config):
|
||||
mem_size = args['mem_size'][vmid]
|
||||
|
||||
print("mem_size={}M".format(mem_size), file=config)
|
||||
|
||||
|
||||
def user_vm_launch(names, args, virt_io, vmid, config):
|
||||
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
launch_uos = common.undline_name(user_vm_type).lower()
|
||||
board_name = names['board_name']
|
||||
if 'nuc' in board_name:
|
||||
board_name = 'nuc'
|
||||
|
||||
if user_vm_type == "CLEARLINUX" and board_name in ("apl-mrb", "nuc"):
|
||||
print('if [ "$1" = "-C" ];then', file=config)
|
||||
print(' if [ $(hostname) = "runc" ]; then', file=config)
|
||||
print(' echo "Already in container exit!"', file=config)
|
||||
print(" exit", file=config)
|
||||
print(" fi", file=config)
|
||||
print(' echo "runc_container"', file=config)
|
||||
print(" run_container", file=config)
|
||||
if board_name == "apl-mrb":
|
||||
print(" exit", file=config)
|
||||
print("fi", file=config)
|
||||
if is_mount_needed(virt_io, vmid):
|
||||
print("", file=config)
|
||||
print('launch_{} {} "{}" $debug'.format(launch_uos, vmid, vmid), file=config)
|
||||
print("", file=config)
|
||||
i = 0
|
||||
for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
|
||||
if not mount_flag:
|
||||
i += 1
|
||||
continue
|
||||
print("umount /data{}".format(i), file=config)
|
||||
i += 1
|
||||
|
||||
else:
|
||||
print("else", file=config)
|
||||
print(' launch_{} {}'.format(launch_uos, vmid), file=config)
|
||||
print("fi", file=config)
|
||||
return
|
||||
elif not is_mount_needed(virt_io, vmid):
|
||||
print('launch_{} {}'.format(launch_uos, vmid), file=config)
|
||||
else:
|
||||
print("", file=config)
|
||||
print('launch_{} {} "{}" $debug'.format(launch_uos, vmid, vmid), file=config)
|
||||
print("", file=config)
|
||||
i = 0
|
||||
for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
|
||||
if not mount_flag:
|
||||
i += 1
|
||||
continue
|
||||
print("umount /data{}".format(i), file=config)
|
||||
i += 1
|
||||
|
||||
|
||||
def launch_end(names, args, virt_io, vmid, config):
|
||||
|
||||
board_name = names['board_name']
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
mem_size = args["mem_size"][vmid]
|
||||
|
||||
if user_vm_type in ("CLEARLINUX", "ANDROID", "ALIOS") and not is_nuc_whl_linux(names, vmid):
|
||||
print("debug=0", file=config)
|
||||
print("", file=config)
|
||||
print('while getopts "hdC" opt', file=config)
|
||||
print("do", file=config)
|
||||
print(" case $opt in", file=config)
|
||||
print(" d) debug=1", file=config)
|
||||
print(" ;;", file=config)
|
||||
print(" C)", file=config)
|
||||
print(" ;;", file=config)
|
||||
print(" h) help", file=config)
|
||||
print(" exit 1", file=config)
|
||||
print(" ;;", file=config)
|
||||
print(" ?) help", file=config)
|
||||
print(" exit 1", file=config)
|
||||
print(" ;;", file=config)
|
||||
print(" esac", file=config)
|
||||
print("done", file=config)
|
||||
print("", file=config)
|
||||
|
||||
if is_mount_needed(virt_io, vmid):
|
||||
i = 0
|
||||
for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
|
||||
if not mount_flag:
|
||||
i += 1
|
||||
continue
|
||||
blk = virt_io['block'][vmid][i]
|
||||
root_fs = blk.split(':')[0]
|
||||
print('if [ ! -b "{}" ]; then'.format(root_fs), file=config)
|
||||
print(' echo "no {} data partition, exit"'.format(root_fs), file=config)
|
||||
print(" exit", file=config)
|
||||
print("fi", file=config)
|
||||
print("mkdir -p /data{}".format(i), file=config)
|
||||
print("mount {} /data{}".format(root_fs, i), file=config)
|
||||
print("", file=config)
|
||||
i += 1
|
||||
|
||||
sos_vmid = launch_cfg_lib.get_sos_vmid()
|
||||
if args['cpu_sharing'] == "SCHED_NOOP" or common.VM_TYPES[vmid+sos_vmid] == "POST_RT_VM":
|
||||
off_line_cpus(args, vmid, user_vm_type, config)
|
||||
|
||||
user_vm_launch(names, args, virt_io, vmid, config)
|
||||
|
||||
|
||||
def set_dm_pt(names, sel, vmid, config, dm):
|
||||
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
|
||||
if sel.bdf['usb_xdci'][vmid] and sel.slot['usb_xdci'][vmid]:
|
||||
sub_attr = ''
|
||||
if user_vm_type == "WINDOWS":
|
||||
sub_attr = ',d3hot_reset'
|
||||
print(' -s {},passthru,{}/{}/{}{} \\'.format(sel.slot["usb_xdci"][vmid], sel.bdf["usb_xdci"][vmid][0:2],\
|
||||
sel.bdf["usb_xdci"][vmid][3:5], sel.bdf["usb_xdci"][vmid][6:7], sub_attr), file=config)
|
||||
|
||||
# pass through audio/audio_codec
|
||||
if sel.bdf['audio'][vmid]:
|
||||
print(" $boot_audio_option \\", file=config)
|
||||
|
||||
if sel.bdf['cse'][vmid] and sel.slot['cse'][vmid]:
|
||||
print(" $boot_cse_option \\", file=config)
|
||||
|
||||
if sel.bdf["sd_card"][vmid] and sel.slot['sd_card'][vmid]:
|
||||
print(' -s {},passthru,{}/{}/{} \\'.format(sel.slot["sd_card"][vmid], sel.bdf["sd_card"][vmid][0:2], \
|
||||
sel.bdf["sd_card"][vmid][3:5], sel.bdf["sd_card"][vmid][6:7]), file=config)
|
||||
|
||||
if sel.bdf['bluetooth'][vmid] and sel.slot['bluetooth'][vmid]:
|
||||
print(' -s {},passthru,{}/{}/{} \\'.format(sel.slot["bluetooth"][vmid], sel.bdf["bluetooth"][vmid][0:2], \
|
||||
sel.bdf["bluetooth"][vmid][3:5], sel.bdf["bluetooth"][vmid][6:7]), file=config)
|
||||
|
||||
if sel.bdf['wifi'][vmid] and sel.slot['wifi'][vmid]:
|
||||
if user_vm_type == "ANDROID":
|
||||
print(" -s {},passthru,{}/{}/{},keep_gsi \\".format(sel.slot["wifi"][vmid], sel.bdf["wifi"][vmid][0:2], \
|
||||
sel.bdf["wifi"][vmid][3:5], sel.bdf["wifi"][vmid][6:7]), file=config)
|
||||
else:
|
||||
print(" -s {},passthru,{}/{}/{} \\".format(sel.slot["wifi"][vmid], sel.bdf["wifi"][vmid][0:2], \
|
||||
sel.bdf["wifi"][vmid][3:5], sel.bdf["wifi"][vmid][6:7]), file=config)
|
||||
|
||||
if sel.bdf['ipu'][vmid] or sel.bdf['ipu_i2c'][vmid]:
|
||||
print(" $boot_ipu_option \\", file=config)
|
||||
|
||||
if sel.bdf['ethernet'][vmid] and sel.slot['ethernet'][vmid]:
|
||||
if vmid in dm["enable_ptm"] and dm["enable_ptm"][vmid] == 'y':
|
||||
print(" -s {},passthru,{}/{}/{},enable_ptm \\".format(sel.slot["ethernet"][vmid], sel.bdf["ethernet"][vmid][0:2], \
|
||||
sel.bdf["ethernet"][vmid][3:5], sel.bdf["ethernet"][vmid][6:7]), file=config)
|
||||
else:
|
||||
print(" -s {},passthru,{}/{}/{} \\".format(sel.slot["ethernet"][vmid], sel.bdf["ethernet"][vmid][0:2], \
|
||||
sel.bdf["ethernet"][vmid][3:5], sel.bdf["ethernet"][vmid][6:7]), file=config)
|
||||
|
||||
if sel.bdf['sata'] and sel.slot["sata"][vmid]:
|
||||
print(" -s {},passthru,{}/{}/{} \\".format(sel.slot["sata"][vmid], sel.bdf["sata"][vmid][0:2], \
|
||||
sel.bdf["sata"][vmid][3:5], sel.bdf["sata"][vmid][6:7]), file=config)
|
||||
|
||||
if sel.bdf['nvme'] and sel.slot["nvme"][vmid]:
|
||||
print(" -s {},passthru,{}/{}/{} \\".format(sel.slot["nvme"][vmid], sel.bdf["nvme"][vmid][0:2], \
|
||||
sel.bdf["nvme"][vmid][3:5], sel.bdf["nvme"][vmid][6:7]), file=config)
|
||||
|
||||
|
||||
def vboot_arg_set(dm, vmid, config):
|
||||
"""
|
||||
Set the argument of vbootloader
|
||||
:param dm: the dictionary of argument for acrn-dm
|
||||
:param vmid: ID of the vm
|
||||
:param config: it is a file pointer to write vboot loader information
|
||||
:return: None
|
||||
"""
|
||||
# TODO: Support to generate '-k' xml config from webUI and to parse it
|
||||
if dm['vbootloader'][vmid] == "ovmf":
|
||||
print(" --ovmf /usr/share/acrn/bios/OVMF.fd \\", file=config)
|
||||
|
||||
|
||||
def xhci_args_set(dm, vmid, config):
|
||||
# usb_xhci set, the value is string
|
||||
if dm['xhci'][vmid]:
|
||||
print(" -s {},xhci,{} \\".format(
|
||||
launch_cfg_lib.virtual_dev_slot("xhci"), dm['xhci'][vmid]), file=config)
|
||||
|
||||
|
||||
def shm_arg_set(dm, vmid, config):
|
||||
|
||||
if dm['shm_enabled'] == "n":
|
||||
return
|
||||
for shm_region in dm["shm_regions"][vmid]:
|
||||
print(" -s {},ivshmem,{} \\".format(
|
||||
launch_cfg_lib.virtual_dev_slot("shm_region_{}".format(shm_region)), shm_region), file=config)
|
||||
|
||||
|
||||
def virtio_args_set(dm, names, virt_io, vmid, config):
|
||||
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
# 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)
|
||||
|
||||
# virtio-blk set, the value type is a list
|
||||
i = 0
|
||||
for mount_flag in launch_cfg_lib.MOUNT_FLAG_DIC[vmid]:
|
||||
blk = virt_io['block'][vmid][i]
|
||||
if not mount_flag:
|
||||
if blk:
|
||||
rootfs_img = blk.strip(':')
|
||||
print(" -s {},virtio-blk,{} \\".format(launch_cfg_lib.virtual_dev_slot("virtio-blk{}".format(blk)), rootfs_img), file=config)
|
||||
i += 1
|
||||
continue
|
||||
|
||||
rootfs_img = blk.split(':')[1].strip(':')
|
||||
print(" -s {},virtio-blk,/data{}/{} \\".format(launch_cfg_lib.virtual_dev_slot("blk_mount_{}".format(i)), i, rootfs_img), file=config)
|
||||
i += 1
|
||||
|
||||
# virtio-net set, the value type is a list
|
||||
for net in virt_io['network'][vmid]:
|
||||
if net:
|
||||
if launch_cfg_lib.is_linux_like(user_vm_type) or user_vm_type in ("ANDROID", "ALIOS"):
|
||||
print(" -s {},virtio-net,tap={},mac_seed=$mac_seed \\".format(launch_cfg_lib.virtual_dev_slot("virtio-net{}".format(net)), net), file=config)
|
||||
else:
|
||||
print(" -s {},virtio-net,tap={} \\".format(launch_cfg_lib.virtual_dev_slot("virtio-net{}".format(net)), net), file=config)
|
||||
|
||||
# virtio-console set, the value type is a string
|
||||
if virt_io['console'][vmid]:
|
||||
print(" -s {},virtio-console,{} \\".format(
|
||||
launch_cfg_lib.virtual_dev_slot("virtio-console"),
|
||||
virt_io['console'][vmid]), file=config)
|
||||
|
||||
|
||||
def sriov_args_set(dm, sriov, vmid, config):
|
||||
|
||||
# sriov-gpu
|
||||
gpu_bdf = sriov['gpu'][vmid]
|
||||
if gpu_bdf:
|
||||
bus = int(gpu_bdf[0:2], 16)
|
||||
dev = int(gpu_bdf[3:5], 16)
|
||||
fun = int(gpu_bdf[6:7], 16)
|
||||
print(' -s 2,passthru,{}/{}/{},igd-vf \\'.format(bus, dev, fun), file=config)
|
||||
|
||||
# sriov-net
|
||||
if sriov['network'][vmid]:
|
||||
net_bdf = sriov['network'][vmid]
|
||||
bus = int(net_bdf[0:2], 16)
|
||||
dev = int(net_bdf[3:5], 16)
|
||||
fun = int(net_bdf[6:7], 16)
|
||||
print(" -s {},passthru,{}/{}/{} \\".format(
|
||||
launch_cfg_lib.virtual_dev_slot("sriov-net{}".format(net_bdf)), bus, dev, fun
|
||||
), file=config)
|
||||
|
||||
|
||||
def get_cpu_affinity_list(cpu_affinity, vmid):
|
||||
pcpu_id_list = ''
|
||||
for user_vmid,cpus in cpu_affinity.items():
|
||||
if vmid == user_vmid:
|
||||
pcpu_id_list = [id for id in list(cpu_affinity[user_vmid]) if id != None]
|
||||
return pcpu_id_list
|
||||
|
||||
|
||||
def get_apic_id_list(scenario_pcpu_id_list):
|
||||
|
||||
apic_id_list = []
|
||||
board_etree = lxml.etree.parse(common.BOARD_INFO_FILE)
|
||||
board_root = board_etree.getroot()
|
||||
board_pcpu_list = board_root.find('CPU_PROCESSOR_INFO').text.strip().split(',')
|
||||
if isinstance(board_pcpu_list, list):
|
||||
board_pcpu_list = [cpu.strip() for cpu in board_pcpu_list]
|
||||
|
||||
if scenario_pcpu_id_list is not None:
|
||||
for scenario_pcup_id in scenario_pcpu_id_list:
|
||||
if scenario_pcup_id not in board_pcpu_list:
|
||||
key = "scenario config error"
|
||||
launch_cfg_lib.ERR_LIST[key] = "No available cpu {} in {} file.".format(scenario_pcup_id, common.BOARD_INFO_FILE)
|
||||
|
||||
for pcpu_id in scenario_pcpu_id_list:
|
||||
apic_id = common.get_node(f"//processors/die/core/thread[cpu_id='{pcpu_id}']/apic_id/text()", board_etree)
|
||||
apic_id_list.append(int(apic_id, 16))
|
||||
|
||||
return apic_id_list
|
||||
|
||||
|
||||
def pcpu_arg_set(dm, vmid, config):
|
||||
|
||||
pcpu_id_list = get_cpu_affinity_list(dm["cpu_affinity"], vmid)
|
||||
apic_id_list = get_apic_id_list(pcpu_id_list)
|
||||
|
||||
if apic_id_list:
|
||||
print(" --cpu_affinity {} \\".format(','.join([str(id) for id in apic_id_list])), file=config)
|
||||
|
||||
|
||||
def dm_arg_set(names, sel, virt_io, dm, sriov, vmid, config):
|
||||
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
board_name = names['board_name']
|
||||
|
||||
sos_vmid = launch_cfg_lib.get_sos_vmid()
|
||||
|
||||
# clearlinux/android/alios
|
||||
print('acrn-dm -m $mem_size -s 0:0,hostbridge \\', file=config)
|
||||
if launch_cfg_lib.is_linux_like(user_vm_type) or user_vm_type in ("ANDROID", "ALIOS"):
|
||||
if user_vm_type in ("ANDROID", "ALIOS"):
|
||||
print(" -s {},virtio-rpmb \\".format(launch_cfg_lib.virtual_dev_slot("virtio-rpmb")), file=config)
|
||||
print(" --enable_trusty \\", file=config)
|
||||
|
||||
if dm['rtos_type'][vmid] != "no":
|
||||
if virt_io:
|
||||
print(" --virtio_poll 1000000 \\", file=config)
|
||||
|
||||
if dm['rtos_type'][vmid] == "Soft RT":
|
||||
print(" --rtvm \\", file=config)
|
||||
|
||||
if dm['rtos_type'][vmid] == "Hard RT":
|
||||
print(" --rtvm \\", file=config)
|
||||
print(" --lapic_pt \\", file=config)
|
||||
|
||||
# windows
|
||||
if user_vm_type == "WINDOWS":
|
||||
print(" --windows \\", file=config)
|
||||
|
||||
# set logger_setting for all VMs
|
||||
print(" $logger_setting \\", file=config)
|
||||
|
||||
# GPU PT args set
|
||||
gpu_pt_arg_set(dm, sel, vmid, config)
|
||||
|
||||
# SRIOV args set
|
||||
sriov_args_set(dm, sriov, vmid, config)
|
||||
|
||||
# XHCI args set
|
||||
xhci_args_set(dm, vmid, config)
|
||||
|
||||
# VIRTIO args set
|
||||
virtio_args_set(dm, names, virt_io, vmid, config)
|
||||
|
||||
# vbootloader setting
|
||||
vboot_arg_set(dm, vmid, config)
|
||||
|
||||
# pcpu-list args set
|
||||
pcpu_arg_set(dm, vmid, config)
|
||||
|
||||
# shm regions args set
|
||||
shm_arg_set(dm, vmid, config)
|
||||
|
||||
# ssram set
|
||||
ssram_enabled = 'n'
|
||||
try:
|
||||
ssram_enabled = common.get_hv_item_tag(common.SCENARIO_INFO_FILE, "FEATURES", "SSRAM", "SSRAM_ENABLED")
|
||||
except:
|
||||
pass
|
||||
if user_vm_type == "PREEMPT-RT LINUX" and ssram_enabled == 'y':
|
||||
print(" --ssram \\", file=config)
|
||||
|
||||
for key, value in sel.bdf.items():
|
||||
if key == 'gpu':
|
||||
continue
|
||||
if value[vmid]:
|
||||
print(" $intr_storm_monitor \\", file=config)
|
||||
break
|
||||
|
||||
if user_vm_type != "PREEMPT-RT LINUX":
|
||||
print(" -s 1:0,lpc \\", file=config)
|
||||
|
||||
# redirect console
|
||||
if dm['vuart0'][vmid] == "Enable":
|
||||
print(" -l com1,stdio \\", file=config)
|
||||
|
||||
if launch_cfg_lib.is_linux_like(user_vm_type) or user_vm_type in ("ANDROID", "ALIOS"):
|
||||
if board_name == "apl-mrb":
|
||||
print(" -l com2,/run/acrn/ioc_$vm_name \\", file=config)
|
||||
|
||||
if not is_nuc_whl_linux(names, vmid):
|
||||
print(" -s {},wdt-i6300esb \\".format(launch_cfg_lib.virtual_dev_slot("wdt-i6300esb")), file=config)
|
||||
|
||||
set_dm_pt(names, sel, vmid, config, dm)
|
||||
|
||||
if dm['console_vuart'][vmid] == "Enable":
|
||||
print(" -s {},uart,vuart_idx:0 \\".format(launch_cfg_lib.virtual_dev_slot("console_vuart")), file=config)
|
||||
for vuart_id in dm["communication_vuarts"][vmid]:
|
||||
if not vuart_id:
|
||||
break
|
||||
print(" -s {},uart,vuart_idx:{} \\".format(
|
||||
launch_cfg_lib.virtual_dev_slot("communication_vuart_{}".format(vuart_id)), vuart_id), file=config)
|
||||
|
||||
|
||||
print(" $vm_name", file=config)
|
||||
print("}", file=config)
|
||||
|
||||
|
||||
def gen(names, pt_sel, virt_io, dm, sriov, vmid, config):
|
||||
|
||||
board_name = names['board_name']
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
|
||||
# passthrough bdf/vpid dictionay
|
||||
pt.gen_pt_head(names, dm, sriov, pt_sel, vmid, config)
|
||||
|
||||
# gen launch header
|
||||
launch_begin(names, virt_io, vmid, config)
|
||||
tap_user_vm_net(names, virt_io, vmid, config)
|
||||
|
||||
# passthrough device
|
||||
pt.gen_pt(names, dm, sriov, pt_sel, vmid, config)
|
||||
wa_usage(user_vm_type, config)
|
||||
mem_size_set(dm, vmid, config)
|
||||
interrupt_storm(pt_sel, config)
|
||||
log_level_set(user_vm_type, config)
|
||||
|
||||
# gen acrn-dm args
|
||||
dm_arg_set(names, pt_sel, virt_io, dm, sriov, vmid, config)
|
||||
|
||||
# gen launch end
|
||||
launch_end(names, dm, virt_io, vmid, config)
|
@ -1,221 +0,0 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
import re
|
||||
|
||||
import common
|
||||
import board_cfg_lib
|
||||
import launch_cfg_lib
|
||||
import scenario_cfg_lib
|
||||
|
||||
class AcrnDmArgs:
|
||||
args = {}
|
||||
|
||||
def __init__(self, board_info, scenario_info, launch_info):
|
||||
self.board_info = board_info
|
||||
self.scenario_info = scenario_info
|
||||
self.launch_info = launch_info
|
||||
|
||||
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")
|
||||
self.args["cpu_sharing"] = common.get_hv_item_tag(self.scenario_info, "FEATURES", "SCHEDULER")
|
||||
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
|
||||
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")
|
||||
for vmid, shm_regions in self.args["shm_regions"].items():
|
||||
if self.args["shm_enabled"] == 'y':
|
||||
self.args["shm_regions"][vmid] = [x for x in shm_regions if (x is not None and x.strip != '')]
|
||||
else:
|
||||
self.args["shm_regions"][vmid] = []
|
||||
self.args["xhci"] = common.get_leaf_tag_map(self.launch_info, "usb_xhci")
|
||||
self.args["communication_vuarts"] = common.get_leaf_tag_map(self.launch_info, "communication_vuarts", "communication_vuart")
|
||||
self.args["console_vuart"] = common.get_leaf_tag_map(self.launch_info, "console_vuart")
|
||||
self.args["enable_ptm"] = common.get_leaf_tag_map(self.launch_info, "enable_ptm")
|
||||
|
||||
def check_item(self):
|
||||
(rootfs, num) = board_cfg_lib.get_rootfs(self.board_info)
|
||||
launch_cfg_lib.args_aval_check(self.args["user_vm_type"], "user_vm_type", launch_cfg_lib.USER_VM_TYPES)
|
||||
launch_cfg_lib.args_aval_check(self.args["rtos_type"], "rtos_type", launch_cfg_lib.RTOS_TYPE)
|
||||
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.args_aval_check(self.args["enable_ptm"], "enable_ptm", 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, 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)
|
||||
launch_cfg_lib.check_communication_vuart(self.args["communication_vuarts"], self.scenario_info)
|
||||
launch_cfg_lib.check_enable_ptm(self.args["enable_ptm"], self.scenario_info)
|
||||
|
||||
|
||||
class AvailablePthru():
|
||||
|
||||
avl = {}
|
||||
|
||||
def __init__(self, board_info):
|
||||
self.board_info = board_info
|
||||
(self.bdf_desc_map, self.bdf_vpid_map) = board_cfg_lib.get_pci_info(board_info)
|
||||
|
||||
def get_bdf_vpid_map(self):
|
||||
return self.bdf_vpid_map
|
||||
|
||||
def get_pci_dev(self):
|
||||
self.avl["usb_xdci"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['usb_xdci'])
|
||||
self.avl["gpu"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['gpu'])
|
||||
self.avl["ipu"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu'])
|
||||
self.avl["ipu_i2c"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu_i2c'])
|
||||
self.avl["cse"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['cse'])
|
||||
self.avl["audio"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio'])
|
||||
self.avl["audio_codec"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio_codec'])
|
||||
self.avl["sd_card"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sd_card'])
|
||||
self.avl["wifi"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['wifi'])
|
||||
self.avl["ethernet"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ethernet'])
|
||||
self.avl["sata"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sata'])
|
||||
self.avl["nvme"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['nvme'])
|
||||
self.avl["bluetooth"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['bluetooth'])
|
||||
|
||||
def insert_nun(self):
|
||||
self.avl["usb_xdci"].insert(0, '')
|
||||
self.avl["gpu"].insert(0, '')
|
||||
self.avl["ipu"].insert(0, '')
|
||||
self.avl["ipu_i2c"].insert(0, '')
|
||||
self.avl["cse"].insert(0, '')
|
||||
self.avl["ethernet"].insert(0, '')
|
||||
self.avl["sd_card"].insert(0, '')
|
||||
self.avl["audio"].insert(0, '')
|
||||
self.avl["audio_codec"].insert(0, '')
|
||||
self.avl["wifi"].insert(0, '')
|
||||
self.avl["sata"].insert(0, '')
|
||||
self.avl["nvme"].insert(0, '')
|
||||
self.avl["bluetooth"].insert(0, '')
|
||||
|
||||
|
||||
class PthruSelected():
|
||||
|
||||
bdf = {}
|
||||
vpid = {}
|
||||
slot = {}
|
||||
|
||||
def __init__(self, launch_info, bdf_desc_map, bdf_vpid_map):
|
||||
self.launch_info = launch_info
|
||||
self.bdf_desc_map = bdf_desc_map
|
||||
self.bdf_vpid_map = bdf_vpid_map
|
||||
|
||||
def get_bdf(self):
|
||||
self.bdf["usb_xdci"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "usb_xdci")
|
||||
self.bdf["gpu"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "gpu")
|
||||
self.bdf["ipu"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "ipu")
|
||||
self.bdf["ipu_i2c"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "ipu_i2c")
|
||||
self.bdf["cse"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "cse")
|
||||
self.bdf["ethernet"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "ethernet")
|
||||
self.bdf["sd_card"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "sd_card")
|
||||
self.bdf["sata"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "sata")
|
||||
self.bdf["nvme"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "nvme")
|
||||
self.bdf["audio"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "audio")
|
||||
self.bdf["audio_codec"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "audio_codec")
|
||||
self.bdf["wifi"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "wifi")
|
||||
self.bdf["bluetooth"] = launch_cfg_lib.get_bdf_from_tag(self.launch_info, "passthrough_devices", "bluetooth")
|
||||
|
||||
def get_vpid(self):
|
||||
self.vpid["usb_xdci"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["usb_xdci"])
|
||||
self.vpid["gpu"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["gpu"])
|
||||
self.vpid["ipu"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["ipu"])
|
||||
self.vpid["ipu_i2c"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["ipu_i2c"])
|
||||
self.vpid["cse"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["cse"])
|
||||
self.vpid["ethernet"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["ethernet"])
|
||||
self.vpid["sd_card"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["sd_card"])
|
||||
self.vpid["sata"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["sata"])
|
||||
self.vpid["nvme"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["nvme"])
|
||||
self.vpid["audio"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["audio"])
|
||||
self.vpid["audio_codec"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["audio_codec"])
|
||||
self.vpid["wifi"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["wifi"])
|
||||
self.vpid["bluetooth"] = launch_cfg_lib.get_vpid_from_bdf(self.bdf_vpid_map, self.bdf["bluetooth"])
|
||||
|
||||
|
||||
def get_slot(self):
|
||||
self.slot["usb_xdci"] = launch_cfg_lib.get_slot(self.bdf["usb_xdci"], "usb_xdci")
|
||||
self.slot["ipu"] = launch_cfg_lib.get_slot(self.bdf["ipu"], "ipu")
|
||||
self.slot["ipu_i2c"] = launch_cfg_lib.get_slot(self.bdf["ipu_i2c"], "ipu_i2c")
|
||||
self.slot["cse"] = launch_cfg_lib.get_slot(self.bdf["cse"], "cse")
|
||||
self.slot["ethernet"] = launch_cfg_lib.get_slot(self.bdf["ethernet"], "ethernet")
|
||||
self.slot["sd_card"] = launch_cfg_lib.get_slot(self.bdf["sd_card"], "sd_card")
|
||||
self.slot["sata"] = launch_cfg_lib.get_slot(self.bdf["sata"], "sata")
|
||||
self.slot["nvme"] = launch_cfg_lib.get_slot(self.bdf["nvme"], "nvme")
|
||||
self.slot["audio"] = launch_cfg_lib.get_slot(self.bdf["audio"], "audio")
|
||||
self.slot["audio_codec"] = launch_cfg_lib.get_slot(self.bdf["audio_codec"], "audio_codec")
|
||||
self.slot["wifi"] = launch_cfg_lib.get_slot(self.bdf["wifi"], "wifi")
|
||||
self.slot["bluetooth"] = launch_cfg_lib.get_slot(self.bdf["bluetooth"], "bluetooth")
|
||||
|
||||
def check_item(self):
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["usb_xdci"], self.vpid["usb_xdci"], "usb_xdci")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["gpu"], self.vpid["gpu"], "gpu")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["ipu"], self.vpid["ipu"], "ipu")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["ipu_i2c"], self.vpid["ipu_i2c"], "ipu_i2c")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["cse"], self.vpid["cse"], "cse")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["ethernet"], self.vpid["ethernet"], "ethernet")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["sd_card"], self.vpid["sd_card"], "sd_card")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["sata"], self.vpid["sata"], "sata")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["nvme"], self.vpid["nvme"], "nvme")
|
||||
launch_cfg_lib.pt_devs_check(self.bdf["audio"], self.vpid["audio"], "audio")
|
||||
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["bluetooth"], self.vpid["bluetooth"], "bluetooth")
|
||||
|
||||
# check connections between several pass-through devices
|
||||
launch_cfg_lib.pt_devs_check_audio(self.bdf['audio'], self.bdf['audio_codec'])
|
||||
launch_cfg_lib.bdf_duplicate_check(self.bdf)
|
||||
launch_cfg_lib.check_slot(self.slot)
|
||||
|
||||
|
||||
class VirtioDeviceSelect():
|
||||
|
||||
dev = {}
|
||||
def __init__(self, launch_info):
|
||||
self.launch_info = launch_info
|
||||
|
||||
def get_virtio(self):
|
||||
self.dev["input"] = common.get_leaf_tag_map(self.launch_info, "virtio_devices", "input")
|
||||
self.dev["block"] = common.get_leaf_tag_map(self.launch_info, "virtio_devices", "block")
|
||||
self.dev["network"] = common.get_leaf_tag_map(self.launch_info, "virtio_devices", "network")
|
||||
self.dev["console"] = common.get_leaf_tag_map(self.launch_info, "virtio_devices", "console")
|
||||
|
||||
def check_virtio(self):
|
||||
launch_cfg_lib.check_block_mount(self.dev["block"])
|
||||
|
||||
|
||||
class SriovDeviceInput():
|
||||
|
||||
dev = {}
|
||||
def __init__(self, launch_info):
|
||||
self.launch_info = launch_info
|
||||
|
||||
def get_sriov(self):
|
||||
self.dev["gpu"] = common.get_leaf_tag_map(self.launch_info, "sriov", "gpu")
|
||||
temp = common.get_leaf_tag_map(self.launch_info, "sriov", "network")
|
||||
temp = {k: v[0] if v[0] else '' for k, v in temp.items()}
|
||||
self.dev["network"] = temp
|
||||
|
||||
def check_sriov(self, pt_sel):
|
||||
launch_cfg_lib.check_sriov_param(self.dev, pt_sel)
|
@ -1,266 +0,0 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import launch_cfg_lib
|
||||
|
||||
MEDIA_DEV = ['ipu', 'ipu_i2c', 'cse', 'audio', 'audio_codec']
|
||||
|
||||
|
||||
def pass_through_dev(sel, pt_dev, vmid, config):
|
||||
|
||||
bdf = sel.bdf[pt_dev][vmid]
|
||||
if not bdf:
|
||||
return
|
||||
|
||||
print("# Passthrough {}".format(pt_dev.upper()), file=config)
|
||||
print('echo ${passthru_vpid["%s"]} > /sys/bus/pci/drivers/pci-stub/new_id'%pt_dev, file=config)
|
||||
print('echo ${passthru_bdf["%s"]} > /sys/bus/pci/devices/${passthru_bdf["%s"]}/driver/unbind'%(pt_dev, pt_dev), file=config)
|
||||
print('echo ${passthru_bdf["%s"]} > /sys/bus/pci/drivers/pci-stub/bind'%pt_dev, file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
||||
def ipu_pt(sel, vmid, config):
|
||||
|
||||
if not sel.bdf['ipu'][vmid] and not sel.bdf['ipu_i2c'][vmid]:
|
||||
return
|
||||
|
||||
bdf_ipu = sel.bdf['ipu'][vmid]
|
||||
if bdf_ipu:
|
||||
bus = bdf_ipu[0:2]
|
||||
dev = bdf_ipu[3:5]
|
||||
fun = bdf_ipu[6:7]
|
||||
slot_ipu = sel.slot['ipu'][vmid]
|
||||
|
||||
bdf_ipu_i2c = sel.bdf['ipu_i2c'][vmid]
|
||||
if bdf_ipu_i2c:
|
||||
bus_i2c = bdf_ipu_i2c[0:2]
|
||||
dev_i2c = bdf_ipu_i2c[3:5]
|
||||
fun_i2c = bdf_ipu_i2c[6:7]
|
||||
slot_ipu_i2c = sel.slot['ipu_i2c'][vmid]
|
||||
|
||||
if bdf_ipu or bdf_ipu_i2c:
|
||||
print("ipu_passthrough=0", file=config)
|
||||
print("", file=config)
|
||||
print("# Check the device file of /dev/vbs_ipu to determine the IPU mode", file=config)
|
||||
print('if [ ! -e "/dev/vbs_ipu" ]; then', file=config)
|
||||
print("ipu_passthrough=1", file=config)
|
||||
print("fi", file=config)
|
||||
print('boot_ipu_option=""', file=config)
|
||||
print("if [ $ipu_passthrough == 1 ];then", file=config)
|
||||
|
||||
if bdf_ipu:
|
||||
print(" # for ipu passthrough - ipu device", file=config)
|
||||
print(' if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu"]}" ]; then', file=config)
|
||||
print(' echo ${passthru_vpid["ipu"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
|
||||
print(' echo ${passthru_bdf["ipu"]} > /sys/bus/pci/devices/${passthru_bdf["ipu"]}/driver/unbind', file=config)
|
||||
print(' echo ${passthru_bdf["ipu"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
|
||||
print(' boot_ipu_option="$boot_ipu_option"" -s {},passthru,{}/{}/{} "'.format(
|
||||
slot_ipu, bus, dev, fun), file=config)
|
||||
print(" fi", file=config)
|
||||
print("", file=config)
|
||||
|
||||
if bdf_ipu_i2c:
|
||||
print(" # for ipu passthrough - ipu related i2c", file=config)
|
||||
print(" # please use virtual slot for i2c to make sure that the i2c controller", file=config)
|
||||
print(" # could get the same virtaul BDF as physical BDF", file=config)
|
||||
print(' if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}" ]; then', file=config)
|
||||
print(' echo ${passthru_vpid["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
|
||||
print(' echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}/driver/unbind', file=config)
|
||||
print(' echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
|
||||
print(' boot_ipu_option="$boot_ipu_option"" -s {},passthru,{}/{}/{} "'.format(
|
||||
slot_ipu_i2c, bus_i2c, dev_i2c, fun_i2c), file=config)
|
||||
print(" fi", file=config)
|
||||
|
||||
if bdf_ipu or bdf_ipu_i2c:
|
||||
print("fi", file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
||||
def cse_pt(sel, vmid, config):
|
||||
|
||||
if not sel.bdf['cse'][vmid]:
|
||||
return
|
||||
|
||||
bdf = sel.bdf['cse'][vmid]
|
||||
if bdf:
|
||||
bus = bdf[0:2]
|
||||
dev = bdf[3:5]
|
||||
fun = bdf[6:7]
|
||||
slot = sel.slot['cse'][vmid]
|
||||
|
||||
if bdf:
|
||||
print("cse_passthrough=0", file=config)
|
||||
print("hbm_ver=`cat /sys/class/mei/mei0/hbm_ver`", file=config)
|
||||
print("major_ver=`echo $hbm_ver | cut -d '.' -f1`", file=config)
|
||||
print("minor_ver=`echo $hbm_ver | cut -d '.' -f2`", file=config)
|
||||
print('if [[ "$major_ver" -lt "2" ]] || \\', file=config)
|
||||
print(' [[ "$major_ver" == "2" && "$minor_ver" -le "2" ]]; then', file=config)
|
||||
print(" cse_passthrough=1", file=config)
|
||||
print("fi", file=config)
|
||||
print('boot_cse_option=""', file=config)
|
||||
print("if [ $cse_passthrough == 1 ]; then", file=config)
|
||||
print(' echo ${passthru_vpid["cse"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
|
||||
print(' echo ${passthru_bdf["cse"]} > /sys/bus/pci/devices/${passthru_bdf["cse"]}/driver/unbind', file=config)
|
||||
print(' echo ${passthru_bdf["cse"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
|
||||
print(' boot_cse_option="$boot_cse_option"" -s {},passthru,{}/{}/{} "'.format(
|
||||
slot, bus, dev, fun), file=config)
|
||||
print("else", file=config)
|
||||
print(' boot_cse_option="$boot_cse_option"" -s {},virtio-heci,{}/{}/{} "'.format(
|
||||
slot, bus, dev, fun), file=config)
|
||||
print("fi", file=config)
|
||||
print("", file=config)
|
||||
|
||||
|
||||
def audio_pt(user_vm_type, sel, vmid, config):
|
||||
|
||||
if not sel.bdf['audio'][vmid] and not sel.bdf['audio_codec'][vmid]:
|
||||
return
|
||||
|
||||
bdf_audio = sel.bdf['audio'][vmid]
|
||||
if bdf_audio:
|
||||
bus = bdf_audio[0:2]
|
||||
dev = bdf_audio[3:5]
|
||||
fun = bdf_audio[6:7]
|
||||
slot_audio = sel.slot['audio'][vmid]
|
||||
|
||||
bdf_codec = sel.bdf['audio_codec'][vmid]
|
||||
if bdf_codec:
|
||||
bus_codec = bdf_codec[0:2]
|
||||
dev_codec = bdf_codec[3:5]
|
||||
fun_codec = bdf_codec[6:7]
|
||||
slot_codec = sel.slot['audio_codec'][vmid]
|
||||
|
||||
if bdf_audio:
|
||||
print("kernel_version=$(uname -r)", file=config)
|
||||
print('audio_module="/usr/lib/modules/$kernel_version/kernel/sound/soc/intel/boards/snd-soc-sst_bxt_sos_tdf8532.ko"', file=config)
|
||||
print("", file=config)
|
||||
print("# use the modprobe to force loading snd-soc-skl/sst_bxt_bdf8532", file=config)
|
||||
print("if [ ! -e $audio_module ]; then", file=config)
|
||||
print("modprobe -q snd-soc-skl", file=config)
|
||||
print("modprobe -q snd-soc-sst_bxt_tdf8532", file=config)
|
||||
print("else", file=config)
|
||||
print("", file=config)
|
||||
print("modprobe -q snd_soc_skl", file=config)
|
||||
print("modprobe -q snd_soc_tdf8532", file=config)
|
||||
print("modprobe -q snd_soc_sst_bxt_sos_tdf8532", file=config)
|
||||
print("modprobe -q snd_soc_skl_virtio_be", file=config)
|
||||
print("fi", file=config)
|
||||
print("audio_passthrough=0", file=config)
|
||||
print("", file=config)
|
||||
print("# Check the device file of /dev/vbs_k_audio to determine the audio mode", file=config)
|
||||
print('if [ ! -e "/dev/vbs_k_audio" ]; then', file=config)
|
||||
print("audio_passthrough=1", file=config)
|
||||
print("fi", file=config)
|
||||
print('boot_audio_option=""', file=config)
|
||||
|
||||
print("if [ $audio_passthrough == 1 ]; then", file=config)
|
||||
print(" # for audio device", file=config)
|
||||
print(' echo ${passthru_vpid["audio"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
|
||||
print(' echo ${passthru_bdf["audio"]} > /sys/bus/pci/devices/${passthru_bdf["audio"]}/driver/unbind', file=config)
|
||||
print(' echo ${passthru_bdf["audio"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
|
||||
print("", file=config)
|
||||
|
||||
if bdf_codec:
|
||||
# select audio and audio_codec device to pass through to vm
|
||||
print(" # for audio codec", file=config)
|
||||
print(' echo ${passthru_vpid["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
|
||||
print(' echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/devices/${passthru_bdf["audio_codec"]}/driver/unbind', file=config)
|
||||
print(' echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
|
||||
print("", file=config)
|
||||
|
||||
if user_vm_type == "ANDROID":
|
||||
print(' boot_audio_option="-s {},passthru,{}/{}/{},keep_gsi '.format(
|
||||
slot_audio, bus, dev, fun), end="", file=config)
|
||||
else:
|
||||
print(' boot_audio_option="-s {},passthru,{}/{}/{} '.format(
|
||||
slot_audio, bus, dev, fun), end="", file=config)
|
||||
print('-s {},passthru,{}/{}/{}"'.format(
|
||||
slot_codec, bus_codec, dev_codec, fun_codec), file=config)
|
||||
else:
|
||||
# only select audio device to pass through to vm
|
||||
if user_vm_type == "ANDROID":
|
||||
print(' boot_audio_option="-s {},passthru,{}/{}/{},keep_gsi"'.format(
|
||||
slot_audio, bus, dev, fun), file=config)
|
||||
else:
|
||||
print(' boot_audio_option="-s {},passthru,{}/{}/{}"'.format(
|
||||
slot_audio, bus, dev, fun), file=config)
|
||||
|
||||
print("fi", file=config)
|
||||
|
||||
|
||||
def media_pt(user_vm_type, sel, vmid, config):
|
||||
ipu_pt(sel, vmid, config)
|
||||
cse_pt(sel, vmid, config)
|
||||
audio_pt(user_vm_type, sel, vmid, config)
|
||||
|
||||
|
||||
def gen_pt(names, dm, sriov, sel, vmid, config):
|
||||
|
||||
pt_none = True
|
||||
cap_pt = launch_cfg_lib.get_pt_dev()
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
|
||||
print("modprobe pci_stub", file=config)
|
||||
# SRIOV passthru
|
||||
if sriov['gpu'][vmid]:
|
||||
print('echo ${passthru_vpid["gpu"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
|
||||
print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind', file=config)
|
||||
print('echo ${passthru_bdf["gpu"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
|
||||
if sriov['network'][vmid]:
|
||||
print('echo ${passthru_vpid["network"]} > /sys/bus/pci/drivers/pci-stub/new_id', file=config)
|
||||
print('echo ${passthru_bdf["network"]} > /sys/bus/pci/devices/${passthru_bdf["gpu"]}/driver/unbind',
|
||||
file=config)
|
||||
print('echo ${passthru_bdf["network"]} > /sys/bus/pci/drivers/pci-stub/bind', file=config)
|
||||
|
||||
for pt_dev in cap_pt:
|
||||
if sel.bdf[pt_dev][vmid]:
|
||||
pt_none = False
|
||||
if pt_none:
|
||||
return
|
||||
|
||||
for pt_dev in cap_pt:
|
||||
if pt_dev not in MEDIA_DEV:
|
||||
pass_through_dev(sel, pt_dev, vmid, config)
|
||||
continue
|
||||
|
||||
media_pt(user_vm_type, sel, vmid, config)
|
||||
|
||||
|
||||
def gen_pt_head(names, dm, sriov, sel, vmid, config):
|
||||
|
||||
cap_pt = launch_cfg_lib.get_pt_dev()
|
||||
user_vm_type = names['user_vm_types'][vmid]
|
||||
|
||||
print("# pci devices for passthru", file=config)
|
||||
print("declare -A passthru_vpid", file=config)
|
||||
print("declare -A passthru_bdf", file=config)
|
||||
print("", file=config)
|
||||
|
||||
print("passthru_vpid=(", file=config)
|
||||
for pt_dev in cap_pt:
|
||||
if not sel.vpid[pt_dev] or not sel.vpid[pt_dev][vmid]:
|
||||
continue
|
||||
print('["{}"]="{}"'.format(pt_dev, sel.vpid[pt_dev][vmid]), file=config)
|
||||
|
||||
# SRIOV passthru
|
||||
if sriov['gpu'][vmid]:
|
||||
print('["gpu"]="{}"'.format(launch_cfg_lib.get_gpu_vpid()), file=config)
|
||||
if sriov['network'][vmid]:
|
||||
print('["network"]="{}"'.format(launch_cfg_lib.get_vpid_by_bdf(sriov['network'][vmid])), file=config)
|
||||
|
||||
print(')', file=config)
|
||||
|
||||
print("passthru_bdf=(", file=config)
|
||||
for pt_dev in cap_pt:
|
||||
if not sel.bdf[pt_dev] or not sel.bdf[pt_dev][vmid]:
|
||||
continue
|
||||
print('["{}"]="0000:{}"'.format(pt_dev, sel.bdf[pt_dev][vmid]), file=config)
|
||||
if sriov['gpu'][vmid]:
|
||||
print('["gpu"]="0000:{}"'.format(sriov['gpu'][vmid]), file=config)
|
||||
if sriov['network'][vmid]:
|
||||
print('["network"]="0000:{}"'.format(sriov['network'][vmid]), file=config)
|
||||
print(')', file=config)
|
||||
|
||||
print("", file=config)
|
Loading…
Reference in New Issue
Block a user