acrn-config: refactor xmls/samples folder for acrn-config

Add xmls/samples folders under misc/vm_configs, and make soft link for
them.

Tracked-On: #5077
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
2020-07-27 11:43:29 +08:00
committed by wenlingz
parent 1210837a87
commit 72dab3f9dc
126 changed files with 3 additions and 1 deletions

1
devicemodel/samples Symbolic link
View File

@@ -0,0 +1 @@
../misc/vm_configs/sample_launch_scripts/

View File

@@ -1,16 +0,0 @@
[Unit]
Description=Start ACRN UOS
After=acrnprobe.service
After=weston.service
After=systemd-resolved.service
ConditionPathExists=/sys/kernel/gvt
ConditionPathExists=/dev/acrn_vhm
[Service]
Type=simple
RemainAfterExit=false
ExecStart=/bin/sh /usr/share/acrn/samples/apl-mrb/launch_uos.sh -V 6
[Install]
WantedBy=multi-user.target

View File

@@ -1 +0,0 @@
-V 2 -C

View File

@@ -1,601 +0,0 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
offline_path="/sys/class/vhm/acrn_vhm"
# Check the device file of /dev/acrn_hsm to determine the offline_path
if [ -e "/dev/acrn_hsm" ]; then
offline_path="/sys/class/acrn/acrn_hsm"
fi
kernel_version=$(uname -r)
audio_module="/usr/lib/modules/$kernel_version/kernel/sound/soc/intel/boards/snd-soc-sst_bxt_sos_tdf8532.ko"
ipu_passthrough=0
# Check the device file of /dev/vbs_ipu to determine the IPU mode
if [ ! -e "/dev/vbs_ipu" ]; then
ipu_passthrough=1
fi
# use the modprobe to force loading snd-soc-skl/sst_bxt_bdf8532
if [ ! -e $(audio_module)]; then
modprobe -q snd-soc-skl
modprobe -q snd-soc-sst_bxt_tdf8532
else
modprobe -q snd_soc_skl
modprobe -q snd_soc_tdf8532
modprobe -q snd_soc_sst_bxt_sos_tdf8532
modprobe -q snd_soc_skl_virtio_be
fi
audio_passthrough=0
# Check the device file of /dev/vbs_k_audio to determine the audio mode
if [ ! -e "/dev/vbs_k_audio" ]; then
audio_passthrough=1
fi
cse_passthrough=0
hbm_ver=`cat /sys/class/mei/mei0/hbm_ver`
major_ver=`echo $hbm_ver | cut -d '.' -f1`
minor_ver=`echo $hbm_ver | cut -d '.' -f2`
if [[ "$major_ver" -lt "2" ]] || \
[[ "$major_ver" == "2" && "$minor_ver" -lt "2" ]]; then
cse_passthrough=1
fi
# pci devices for passthru
declare -A passthru_vpid
declare -A passthru_bdf
passthru_vpid=(
["usb_xdci"]="8086 5aaa"
["ipu"]="8086 5a88"
["ipu_i2c"]="8086 5aac"
["cse"]="8086 5a9a"
["sd_card"]="8086 5aca"
["audio"]="8086 5a98"
["audio_codec"]="8086 5ab4"
["wifi"]="11ab 2b38"
["bluetooth"]="8086 5abc"
)
passthru_bdf=(
["usb_xdci"]="0000:00:15.1"
["ipu"]="0000:00:03.0"
["ipu_i2c"]="0000:00:16.0"
["cse"]="0000:00:0f.0"
["sd_card"]="0000:00:1b.0"
["audio"]="0000:00:0e.0"
["audio_codec"]="0000:00:17.0"
["wifi"]="0000:03:00.0"
["bluetooth"]="0000:00:18.0"
)
function launch_clearlinux()
{
if [ ! -f "/data/$4/$4.img" ]; then
echo "no /data/$4/$4.img, exit"
exit
fi
#vm-name used to generate uos-mac address
mac=$(cat /sys/class/net/e*/address)
vm_name=vm$1
mac_seed=${mac:9:8}-${vm_name}
# create a unique tap device for each VM
tap=tap_$5
tap_exist=$(ip a | grep "$tap" | awk '{print $1}')
if [ "$tap_exist"x != "x" ]; then
echo "tap device existed, reuse $tap"
else
ip tuntap add dev $tap mode tap
fi
# if acrn-br0 exists, add VM's unique tap device under it
br_exist=$(ip a | grep acrn-br0 | awk '{print $1}')
if [ "$br_exist"x != "x" -a "$tap_exist"x = "x" ]; then
echo "acrn-br0 bridge aleady exists, adding new tap device to it..."
ip link set "$tap" master acrn-br0
ip link set dev "$tap" down
ip link set dev "$tap" up
fi
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep -w "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#for VT-d device setting
modprobe pci_stub
echo ${passthru_vpid["usb_xdci"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["usb_xdci"]} > /sys/bus/pci/devices/${passthru_bdf["usb_xdci"]}/driver/unbind
echo ${passthru_bdf["usb_xdci"]} > /sys/bus/pci/drivers/pci-stub/bind
echo 100 > /sys/bus/usb/drivers/usb-storage/module/parameters/delay_use
boot_ipu_option=""
if [ $ipu_passthrough == 1 ];then
# for ipu passthrough - ipu device
if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu"]}" ]; then
echo ${passthru_vpid["ipu"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["ipu"]} > /sys/bus/pci/devices/${passthru_bdf["ipu"]}/driver/unbind
echo ${passthru_bdf["ipu"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option="$boot_ipu_option"" -s 12,passthru,0/3/0 "
fi
# for ipu passthrough - ipu related i2c
# please use virtual slot 22 for i2c to make sure that the i2c controller
# could get the same virtaul BDF as physical BDF
if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}" ]; then
echo ${passthru_vpid["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}/driver/unbind
echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option="$boot_ipu_option"" -s 22,passthru,0/16/0 "
fi
else
boot_ipu_option="$boot_ipu_option"" -s 21,virtio-ipu "
fi
boot_cse_option=""
if [ $cse_passthrough == 1 ]; then
echo ${passthru_vpid["cse"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["cse"]} > /sys/bus/pci/devices/${passthru_bdf["cse"]}/driver/unbind
echo ${passthru_bdf["cse"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_cse_option="$boot_cse_option"" -s 15,passthru,0/0f/0 "
else
boot_cse_option="$boot_cse_option"" -s 15,virtio-heci,0/0f/0 "
fi
# for sd card passthrough - SDXC/MMC Host Controller 00:1b.0
echo ${passthru_vpid["sd_card"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["sd_card"]} > /sys/bus/pci/devices/${passthru_bdf["sd_card"]}/driver/unbind
echo ${passthru_bdf["sd_card"]} > /sys/bus/pci/drivers/pci-stub/bind
#for memsize setting, total 8GB(>7.5GB) uos->6GB, 4GB(>3.5GB) uos->2GB
memsize=`cat /proc/meminfo|head -n 1|awk '{print $2}'`
if [ $memsize -gt 7500000 ];then
mem_size=6G
elif [ $memsize -gt 3500000 ];then
mem_size=2G
else
mem_size=1750M
fi
if [ "$setup_mem" != "" ];then
mem_size=$setup_mem
fi
boot_dev_flag=",b"
if [ $6 == 1 ];then
boot_image_option="--vsbl /usr/share/acrn/bios/VSBL_debug.bin"
else
boot_image_option="--vsbl /usr/share/acrn/bios/VSBL.bin"
fi
#interrupt storm monitor for pass-through devices, params order:
#threshold/s,probe-period(s),intr-inject-delay-time(ms),delay-duration(ms)
intr_storm_monitor="--intr_monitor 10000,10,1,100"
acrn-dm --help 2>&1 | grep 'GVT args'
if [ $? == 0 ];then
GVT_args=$2
boot_GVT_option=" -s 0:2:0,pci-gvt -G "
else
boot_GVT_option=''
GVT_args=''
fi
acrn-dm -A -m $mem_size $boot_GVT_option"$GVT_args" -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \
-s 5,virtio-console,@pty:pty_port \
-s 6,virtio-hyper_dmabuf \
-s 8,wdt-i6300esb \
-s 3,virtio-blk$boot_dev_flag,/data/$4/$4.img \
-s 4,virtio-net,$tap $boot_image_option \
-s 7,xhci,1-1:1-2:1-3:2-1:2-2:2-3:cap=apl \
-s 9,passthru,0/15/1 \
$boot_cse_option \
--mac_seed $mac_seed \
-s 27,passthru,0/1b/0 \
$intr_storm_monitor \
$boot_ipu_option \
-i /run/acrn/ioc_$vm_name,0x20 \
-l com2,/run/acrn/ioc_$vm_name \
--pm_notify_channel ioc \
-B "root=/dev/vda2 rw rootwait nohpet console=hvc0 \
snd_soc_skl_virtio_fe.domain_id=1 \
snd_soc_skl_virtio_fe.domain_name="GuestOS" \
console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \
consoleblank=0 tsc=reliable i915.avail_planes_per_pipe=$3 i915.enable_guc_loading=0 \
i915.enable_hangcheck=0 i915.nuclear_pageflip=1 \
i915.enable_guc_submission=0 i915.enable_guc=0" $vm_name
}
function launch_android()
{
if [ ! -f "/data/$4/$4.img" ]; then
echo "no /data/$4/$4.img, exit"
exit
fi
#vm-name used to generate uos-mac address
mac=$(cat /sys/class/net/e*/address)
vm_name=vm$1
mac_seed=${mac:9:8}-${vm_name}
# create a unique tap device for each VM
tap=tap_$5
tap_exist=$(ip a | grep "$tap" | awk '{print $1}')
if [ "$tap_exist"x != "x" ]; then
echo "tap device existed, reuse $tap"
else
ip tuntap add dev $tap mode tap
fi
# if acrn-br0 exists, add VM's unique tap device under it
br_exist=$(ip a | grep acrn-br0 | awk '{print $1}')
if [ "$br_exist"x != "x" -a "$tap_exist"x = "x" ]; then
echo "acrn-br0 bridge aleady exists, adding new tap device to it..."
ip link set "$tap" master acrn-br0
ip link set dev "$tap" down
ip link set dev "$tap" up
fi
#Use MMC name + serial for ADB serial no., same as native android
mmc_name=`cat /sys/block/mmcblk1/device/name`
mmc_serial=`cat /sys/block/mmcblk1/device/serial | sed -n 's/^..//p'`
ser=$mmc_name$mmc_serial
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep -w "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#for VT-d device setting
modprobe pci_stub
echo ${passthru_vpid["usb_xdci"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["usb_xdci"]} > /sys/bus/pci/devices/${passthru_bdf["usb_xdci"]}/driver/unbind
echo ${passthru_bdf["usb_xdci"]} > /sys/bus/pci/drivers/pci-stub/bind
#for audio device
boot_audio_option=""
if [ $audio_passthrough == 1 ]; then
echo ${passthru_vpid["audio"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["audio"]} > /sys/bus/pci/devices/${passthru_bdf["audio"]}/driver/unbind
echo ${passthru_bdf["audio"]} > /sys/bus/pci/drivers/pci-stub/bind
#for audio codec
echo ${passthru_vpid["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/devices/${passthru_bdf["audio_codec"]}/driver/unbind
echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_audio_option="-s 14,passthru,0/e/0,keep_gsi -s 23,passthru,0/17/0"
else
boot_audio_option="-s 14,virtio-audio"
fi
# for sd card passthrough - SDXC/MMC Host Controller 00:1b.0
echo ${passthru_vpid["sd_card"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["sd_card"]} > /sys/bus/pci/devices/${passthru_bdf["sd_card"]}/driver/unbind
echo ${passthru_bdf["sd_card"]} > /sys/bus/pci/drivers/pci-stub/bind
# WIFI
echo ${passthru_vpid["wifi"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["wifi"]} > /sys/bus/pci/devices/${passthru_bdf["wifi"]}/driver/unbind
echo ${passthru_bdf["wifi"]} > /sys/bus/pci/drivers/pci-stub/bind
# Bluetooth passthrough depends on WIFI
echo ${passthru_vpid["bluetooth"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["bluetooth"]} > /sys/bus/pci/devices/${passthru_bdf["bluetooth"]}/driver/unbind
echo ${passthru_bdf["bluetooth"]} > /sys/bus/pci/drivers/pci-stub/bind
# Check if the NPK device/driver is present
ls -d /sys/bus/pci/drivers/intel_th_pci/0000* 2>/dev/null 1>/dev/null
if [ $? == 0 ];then
npk_virt="-s 0:0:2,npk,8/24"
else
npk_virt=""
fi
# WA for USB role switch hang issue, disable runtime PM of xHCI device
echo on > /sys/devices/pci0000:00/0000:00:15.0/power/control
echo 100 > /sys/bus/usb/drivers/usb-storage/module/parameters/delay_use
boot_ipu_option=""
if [ $ipu_passthrough == 1 ];then
# for ipu passthrough - ipu device
if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu"]}" ]; then
echo ${passthru_vpid["ipu"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["ipu"]} > /sys/bus/pci/devices/${passthru_bdf["ipu"]}/driver/unbind
echo ${passthru_bdf["ipu"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option="$boot_ipu_option"" -s 12,passthru,0/3/0 "
fi
# for ipu passthrough - ipu related i2c
# please use virtual slot 22 for i2c to make sure that the i2c controller
# could get the same virtaul BDF as physical BDF
if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}" ]; then
echo ${passthru_vpid["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}/driver/unbind
echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option="$boot_ipu_option"" -s 22,passthru,0/16/0 "
fi
else
boot_ipu_option="$boot_ipu_option"" -s 21,virtio-ipu "
fi
boot_cse_option=""
if [ $cse_passthrough == 1 ]; then
echo ${passthru_vpid["cse"]} /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["cse"]} > /sys/bus/pci/devices/${passthru_bdf["cse"]}/driver/unbind
echo ${passthru_bdf["cse"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_cse_option="$boot_cse_option"" -s 15,passthru,0/0f/0 "
else
boot_cse_option="$boot_cse_option"" -s 15,virtio-heci,0/0f/0 "
fi
#for memsize setting, total 8GB(>7.5GB) uos->6GB, 4GB(>3.5GB) uos->2GB
memsize=`cat /proc/meminfo|head -n 1|awk '{print $2}'`
if [ $memsize -gt 7500000 ];then
mem_size=6G
elif [ $memsize -gt 3500000 ];then
mem_size=2G
else
mem_size=1750M
fi
if [ "$setup_mem" != "" ];then
mem_size=$setup_mem
fi
kernel_cmdline_generic="nohpet tsc=reliable intel_iommu=off \
androidboot.serialno=$ser \
snd_soc_skl_virtio_fe.domain_id=1 \
snd_soc_skl_virtio_fe.domain_name="GuestOS" \
i915.enable_rc6=1 i915.enable_fbc=1 i915.enable_guc_loading=0 i915.avail_planes_per_pipe=$3 \
i915.enable_hangcheck=0 use_nuclear_flip=1 i915.enable_guc_submission=0 i915.enable_guc=0"
boot_dev_flag=",b"
if [ $6 == 1 ];then
boot_image_option="--vsbl /usr/share/acrn/bios/VSBL_debug.bin"
else
boot_image_option="--vsbl /usr/share/acrn/bios/VSBL.bin"
fi
kernel_cmdline="$kernel_cmdline_generic"
: '
select right virtual slots for acrn_dm:
1. some passthru device need virtual slot same as physical, like audio 0:e.0 at
virtual #14 slot, so "-s 14,passthru,0/e/0"
2. acrn_dm share vioapic irq between some virtual slots: like 6&14, 7&15. Need
guarantee no virt irq sharing for each passthru device.
FIXME: picking a virtual slot (#24 now) which is level-triggered to make sure
audio codec passthrough working
3. the bootable device slot is configured in compile stating in Android Guest
image, it should be kept using 3 as fixed value for Android Guest on Gordon_peak
ACRN project
'
#interrupt storm monitor for pass-through devices, params order:
#threshold/s,probe-period(s),intr-inject-delay-time(ms),delay-duration(ms)
intr_storm_monitor="--intr_monitor 10000,10,1,100"
acrn-dm --help 2>&1 | grep 'GVT args'
if [ $? == 0 ];then
GVT_args=$2
boot_GVT_option=" -s 2,pci-gvt -G "
else
boot_GVT_option=''
GVT_args=''
fi
acrn-dm -A -m $mem_size $boot_GVT_option"$GVT_args" -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio $npk_virt\
-s 9,virtio-net,$tap \
-s 3,virtio-blk$boot_dev_flag,/data/$4/$4.img \
-s 7,xhci,1-1:1-2:1-3:2-1:2-2:2-3:cap=apl \
-s 8,passthru,0/15/1 \
-s 13,virtio-rpmb \
-s 10,virtio-hyper_dmabuf \
-s 11,wdt-i6300esb \
$boot_audio_option \
$boot_cse_option \
--mac_seed $mac_seed \
-s 27,passthru,0/1b/0 \
-s 24,passthru,0/18/0 \
-s 18,passthru,3/0/0,keep_gsi \
$intr_storm_monitor \
$boot_ipu_option \
-i /run/acrn/ioc_$vm_name,0x20 \
-l com2,/run/acrn/ioc_$vm_name \
--pm_notify_channel ioc \
$boot_image_option \
--enable_trusty \
-B "$kernel_cmdline" $vm_name
}
function launch_alios()
{
#AliOS is not Android, only has same configuration currently, reuse launch function
launch_android "$@"
}
function help()
{
echo "Use luanch_uos.sh like that ./launch_uos.sh -V <#>"
echo "The option -V means the UOSs group to be launched by vsbl as below"
echo "-V 1 means just launching 1 clearlinux UOS"
echo "-V 2 means just launching 1 android UOS"
echo "-V 3 means launching 1 clearlinux UOS + 1 android UOS"
echo "-V 4 means launching 2 clearlinux UOSs"
echo "-V 5 means just launching 1 alios UOS"
echo "-V 6 means auto check android/linux/alios UOS; if exist, launch it"
echo "-C means launching acrn-dm in runC container for QoS"
}
launch_type=1
debug=0
runC_enable=0
function run_container()
{
vm_name=vm1
config_src="/usr/share/acrn/samples/apl-mrb/runC.json"
shell="/usr/share/acrn/conf/add/$vm_name.sh"
arg_file="/usr/share/acrn/conf/add/$vm_name.args"
runc_bundle="/usr/share/acrn/conf/add/runc/$vm_name"
rootfs_dir="/usr/share/acrn/conf/add/runc/rootfs"
config_dst="$runc_bundle/config.json"
input=$(runc list -f table | awk '{print $1}''{print $3}')
arr=(${input// / })
for((i=0;i<${#arr[@]};i++))
do
if [ "$vm_name" = "${arr[$i]}" ]; then
if [ "running" = "${arr[$i+1]}" ]; then
echo "runC instance ${arr[$i]} is running"
exit
else
runc kill ${arr[$i]}
runc delete ${arr[$i]}
fi
fi
done
vmsts=$(acrnctl list)
vms=(${vmsts// / })
for((i=0;i<${#vms[@]};i++))
do
if [ "$vm_name" = "${vms[$i]}" ]; then
if [ "stopped" != "${vms[$i+1]}" ]; then
echo "Uos ${vms[$i]} ${vms[$i+1]}"
acrnctl stop ${vms[$i]}
fi
fi
done
if [ ! -f "$shell" ]; then
echo "Pls add the vm at first!"
exit
fi
if [ ! -f "$arg_file" ]; then
echo "Pls add the vm args!"
exit
fi
if [ ! -d "$rootfs_dir" ]; then
mkdir -p "$rootfs_dir"
fi
if [ ! -d "$runc_bundle" ]; then
mkdir -p "$runc_bundle"
fi
if [ ! -f "$config_dst" ]; then
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
fi
runc run --bundle $runc_bundle -d $vm_name
echo "The runC container is running in backgroud"
echo "'#runc exec <vmname> bash' to login the container bash"
exit
}
while getopts "V:M:hdC" opt
do
case $opt in
V) launch_type=$[$OPTARG]
;;
M) setup_mem=$OPTARG
;;
d) debug=1
;;
C) runC_enable=1
;;
h) help
exit 1
;;
?) help
exit 1
;;
esac
done
if [ ! -b "/dev/mmcblk1p3" ]; then
echo "no /dev/mmcblk1p3 data partition, exit"
exit
fi
mkdir -p /data
mount /dev/mmcblk1p3 /data
if [ $launch_type == 6 ]; then
if [ -f "/data/android/android.img" ]; then
launch_type=2;
elif [ -f "/data/alios/alios.img" ]; then
launch_type=5;
else
launch_type=1;
fi
fi
if [ $runC_enable == 1 ]; then
if [ $(hostname) = "runc" ]; then
echo "Already in container exit!"
exit
fi
run_container
exit
fi
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
online=`cat $i/online`
# during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod
while [ "$online" = "1" ]; do
sleep 1
echo 0 > $i/online
online=`cat $i/online`
done
echo $idx > ${offline_path}/offline_cpu
fi
done
case $launch_type in
1) echo "Launch clearlinux UOS"
launch_clearlinux 1 "64 448 8" 0x070F00 clearlinux "LaaG" $debug
;;
2) echo "Launch android UOS"
launch_android 1 "64 448 8" 0x070F00 android "AaaG" $debug
;;
3) echo "Launch clearlinux UOS + android UOS"
launch_android 1 "64 448 4" 0x00000C android "AaaG" $debug &
sleep 5
launch_clearlinux 2 "64 448 4" 0x070F00 clearlinux "LaaG" $debug
;;
4) echo "Launch two clearlinux UOSs"
launch_clearlinux 1 "64 448 4" 0x00000C clearlinux "L1aaG" $debug &
sleep 5
launch_clearlinux 2 "64 448 4" 0x070F00 clearlinux_dup "L2aaG" $debug
;;
5) echo "Launch alios UOS"
launch_alios 1 "64 448 8" 0x070F00 alios "AliaaG" $debug
;;
esac
umount /data

View File

@@ -1,274 +0,0 @@
{
"ociVersion": "1.0.1-dev",
"process": {
"terminal": false,
"user": {
"uid": 0,
"gid": 0
},
"args": [
"sh"
],
"env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm"
],
"cwd": "/",
"capabilities": {
"bounding": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
],
"effective": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
],
"inheritable": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
],
"permitted": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
],
"ambient": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
]
}
},
"root": {
"path": "../rootfs",
"readonly": false
},
"hostname": "runc",
"mounts": [
{
"destination": "/",
"type": "none",
"source": "/",
"options": ["rbind","rw"]
}
],
"linux": {
"resources": {
"devices": [
{
"allow": true,
"access": "rwm"
}
]
},
"uidMappings": [
{
"hostID": 0,
"containerID": 0,
"size": 1
}
],
"gidMappings": [
{
"hostID": 0,
"containerID": 0,
"size": 1
}
],
"namespaces": [
{
"type": "pid"
},
{
"type": "uts"
},
{
"type": "mount"
}
]
}
}

View File

@@ -1,488 +0,0 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
offline_path="/sys/class/vhm/acrn_vhm"
# Check the device file of /dev/acrn_hsm to determine the offline_path
if [ -e "/dev/acrn_hsm" ]; then
offline_path="/sys/class/acrn/acrn_hsm"
fi
kernel_version=$(uname -r | awk -F. '{ printf("%d.%d", $1,$2) }')
ipu_passthrough=0
# Check the device file of /dev/vbs_ipu to determine the IPU mode
if [ ! -e "/dev/vbs_ipu" ]; then
ipu_passthrough=1
fi
audio_passthrough=0
# Check the device file of /dev/vbs_k_audio to determine the audio mode
if [ ! -e "/dev/vbs_k_audio" ]; then
audio_passthrough=1
fi
cse_passthrough=0
hbm_ver=`cat /sys/class/mei/mei0/hbm_ver`
major_ver=`echo $hbm_ver | cut -d '.' -f1`
minor_ver=`echo $hbm_ver | cut -d '.' -f2`
if [[ "$major_ver" -lt "2" ]] || \
[[ "$major_ver" == "2" && "$minor_ver" -lt "2" ]]; then
cse_passthrough=1
fi
# pci devices for passthru
declare -A passthru_vpid
declare -A passthru_bdf
passthru_vpid=(
["usb_xdci"]="8086 5aaa"
["ipu"]="8086 5a88"
["ipu_i2c"]="8086 5aac"
["cse"]="8086 5a9a"
["sd_card"]="8086 5acc"
["audio"]="8086 5a98"
["audio_codec"]="8086 5ab4"
)
passthru_bdf=(
["usb_xdci"]="0000:00:15.1"
["ipu"]="0000:00:03.0"
["ipu_i2c"]="0000:00:16.0"
["cse"]="0000:00:0f.0"
["sd_card"]="0000:00:1c.0"
["audio"]="0000:00:0e.0"
["audio_codec"]="0000:00:17.0"
)
function launch_clearlinux()
{
if [ ! -f "/data/$4/$4.img" ]; then
echo "no /data/$4/$4.img, exit"
exit
fi
#vm-name used to generate uos-mac address
mac=$(cat /sys/class/net/en*/address)
vm_name=vm$1
mac_seed=${mac:9:8}-${vm_name}
# create a unique tap device for each VM
tap=tap_$5
tap_exist=$(ip a | grep "$tap" | awk '{print $1}')
if [ "$tap_exist"x != "x" ]; then
echo "tap device existed, reuse $tap"
else
ip tuntap add dev $tap mode tap
fi
# if acrn-br0 exists, add VM's unique tap device under it
br_exist=$(ip a | grep acrn-br0 | awk '{print $1}')
if [ "$br_exist"x != "x" -a "$tap_exist"x = "x" ]; then
echo "acrn-br0 bridge aleady exists, adding new tap device to it..."
ip link set "$tap" master acrn-br0
ip link set dev "$tap" down
ip link set dev "$tap" up
fi
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep -w "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#for VT-d device setting
modprobe pci_stub
echo ${passthru_vpid["usb_xdci"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["usb_xdci"]} > /sys/bus/pci/devices/${passthru_bdf["usb_xdci"]}/driver/unbind
echo ${passthru_bdf["usb_xdci"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option=""
if [ $ipu_passthrough == 1 ];then
# for ipu passthrough - ipu device 0:3.0
if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu"]}" ]; then
echo ${passthru_vpid["ipu"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["ipu"]} > /sys/bus/pci/devices/${passthru_bdf["ipu"]}/driver/unbind
echo ${passthru_bdf["ipu"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option="$boot_ipu_option"" -s 12,passthru,0/3/0 "
fi
# for ipu passthrough - ipu related i2c
# please use virtual slot 22 for i2c to make sure that the i2c controller
# could get the same virtaul BDF as physical BDF
if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}" ]; then
echo ${passthru_vpid["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}/driver/unbind
echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option="$boot_ipu_option"" -s 22,passthru,0/16/0 "
fi
else
boot_ipu_option="$boot_ipu_option"" -s 21,virtio-ipu "
fi
boot_cse_option=""
if [ $cse_passthrough == 1 ]; then
echo ${passthru_vpid["cse"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["cse"]} > /sys/bus/pci/devices/${passthru_bdf["cse"]}/driver/unbind
echo ${passthru_bdf["cse"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_cse_option="$boot_cse_option"" -s 15,passthru,0/0f/0 "
else
boot_cse_option="$boot_cse_option"" -s 15,virtio-heci,0/0f/0 "
fi
# for sd card passthrough - SDXC/MMC Host Controller
# echo ${passthru_vpid["sd_card"]} > /sys/bus/pci/drivers/pci-stub/new_id
# echo ${passthru_bdf["sd_card"]} > /sys/bus/pci/devices/${passthru_bdf["sd_card"]}/driver/unbind
# echo ${passthru_bdf["sd_card"]} > /sys/bus/pci/drivers/pci-stub/bind
#for memsize setting, total 8GB(>7.5GB) uos->6GB, 4GB(>3.5GB) uos->2GB
memsize=`cat /proc/meminfo|head -n 1|awk '{print $2}'`
if [ $memsize -gt 7500000 ];then
mem_size=6G
elif [ $memsize -gt 3500000 ];then
mem_size=2G
else
mem_size=1750M
fi
if [ "$setup_mem" != "" ];then
mem_size=$setup_mem
fi
boot_dev_flag=",b"
if [ $6 == 1 ];then
boot_image_option="--vsbl /usr/share/acrn/bios/VSBL_debug.bin"
else
boot_image_option="--vsbl /usr/share/acrn/bios/VSBL.bin"
fi
#interrupt storm monitor for pass-through devices, params order:
#threshold/s,probe-period(s),intr-inject-delay-time(ms),delay-duration(ms)
intr_storm_monitor="--intr_monitor 10000,10,1,100"
acrn-dm --help 2>&1 | grep 'GVT args'
if [ $? == 0 ];then
GVT_args=$2
boot_GVT_option=" -s 0:2:0,pci-gvt -G "
else
boot_GVT_option=''
GVT_args=''
fi
#logger_setting, format: logger_name,level; like following
logger_setting="--logger_setting console,level=4;kmsg,level=3;disk,level=5"
acrn-dm -A -m $mem_size $boot_GVT_option"$GVT_args" -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \
-s 5,virtio-console,@pty:pty_port \
-s 6,virtio-hyper_dmabuf \
-s 8,wdt-i6300esb \
-s 3,virtio-blk$boot_dev_flag,/data/$4/$4.img \
-s 4,virtio-net,$tap $boot_image_option \
-s 7,xhci,1-1:1-2:1-3:2-1:2-2:2-3:cap=apl \
-s 9,passthru,0/15/1 \
$boot_cse_option \
$intr_storm_monitor \
$logger_setting \
$boot_ipu_option \
--mac_seed $mac_seed \
--pm_notify_channel power_button \
-B "root=/dev/vda2 rw rootwait nohpet console=hvc0 \
console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M \
consoleblank=0 tsc=reliable i915.avail_planes_per_pipe=$3 i915.enable_guc_loading=0 \
i915.enable_hangcheck=0 i915.nuclear_pageflip=1 \
i915.enable_guc_submission=0 i915.enable_guc=0" $vm_name
}
function launch_android()
{
if [ ! -f "/data/$4/$4.img" ]; then
echo "no /data/$4/$4.img, exit"
exit
fi
#vm-name used to generate uos-mac address
mac=$(cat /sys/class/net/en*/address)
vm_name=vm$1
mac_seed=${mac:9:8}-${vm_name}
# create a unique tap device for each VM
tap=tap_$5
tap_exist=$(ip a | grep "$tap" | awk '{print $1}')
if [ "$tap_exist"x != "x" ]; then
echo "tap device existed, reuse $tap"
else
ip tuntap add dev $tap mode tap
fi
# if acrn-br0 exists, add VM's unique tap device under it
br_exist=$(ip a | grep acrn-br0 | awk '{print $1}')
if [ "$br_exist"x != "x" -a "$tap_exist"x = "x" ]; then
echo "acrn-br0 bridge aleady exists, adding new tap device to it..."
ip link set "$tap" master acrn-br0
ip link set dev "$tap" down
ip link set dev "$tap" up
fi
#Use MMC name + serial for ADB serial no., same as native android
mmc_name=`cat /sys/block/mmcblk0/device/name`
mmc_serial=`cat /sys/block/mmcblk0/device/serial | sed -n 's/^..//p'`
ser=$mmc_name$mmc_serial
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep -w "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#for VT-d device setting
modprobe pci_stub
echo ${passthru_vpid["usb_xdci"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["usb_xdci"]} > /sys/bus/pci/devices/${passthru_bdf["usb_xdci"]}/driver/unbind
echo ${passthru_bdf["usb_xdci"]} > /sys/bus/pci/drivers/pci-stub/bind
#for audio device
boot_audio_option=""
if [ $audio_passthrough == 1 ]; then
echo ${passthru_vpid["audio"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["audio"]} > /sys/bus/pci/devices/${passthru_bdf["audio"]}/driver/unbind
echo ${passthru_bdf["audio"]} > /sys/bus/pci/drivers/pci-stub/bind
#for audio codec
echo ${passthru_vpid["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/devices/${passthru_bdf["audio_codec"]}/driver/unbind
echo ${passthru_bdf["audio_codec"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_audio_option="-s 14,passthru,0/e/0,keep_gsi -s 23,passthru,0/17/0"
else
boot_audio_option="-s 14,virtio-audio"
fi
# # for sd card passthrough - SDXC/MMC Host Controller 00:1b.0
# echo ${passthru_vpid["sd_card"]} > /sys/bus/pci/drivers/pci-stub/new_id
# echo ${passthru_bdf["sd_card"]} > /sys/bus/pci/devices/${passthru_bdf["sd_card"]}/driver/unbind
# echo ${passthru_bdf["sd_card"]} > /sys/bus/pci/drivers/pci-stub/bind
# Check if the NPK device/driver is present
ls -d /sys/bus/pci/drivers/intel_th_pci/0000* 2>/dev/null 1>/dev/null
if [ $? == 0 ];then
npk_virt="-s 0:0:2,npk,8/24"
else
npk_virt=""
fi
# WA for USB role switch hang issue, disable runtime PM of xHCI device
echo on > /sys/devices/pci0000:00/0000:00:15.0/power/control
boot_ipu_option=""
if [ $ipu_passthrough == 1 ];then
# for ipu passthrough - ipu device
if [ -d "/sys/bus/pci/devices/${passthru_bdf["ipu"]}" ]; then
echo ${passthru_vpid["ipu"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["ipu"]} > /sys/bus/pci/devices/${passthru_bdf["ipu"]}/driver/unbind
echo ${passthru_bdf["ipu"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option="$boot_ipu_option"" -s 12,passthru,0/3/0 "
fi
# for ipu passthrough - ipu related i2c 0:16.0
# please use virtual slot 22 for i2c 0:16.0 to make sure that the i2c controller
# could get the same virtaul BDF as physical BDF
if [ -d "/sys/bus/pci/devices/0000:00:16.0" ]; then
echo ${passthru_vpid["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/devices/${passthru_bdf["ipu_i2c"]}/driver/unbind
echo ${passthru_bdf["ipu_i2c"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_ipu_option="$boot_ipu_option"" -s 22,passthru,0/16/0 "
fi
else
boot_ipu_option="$boot_ipu_option"" -s 21,virtio-ipu "
fi
boot_cse_option=""
if [ $cse_passthrough == 1 ]; then
echo ${passthru_vpid["cse"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["cse"]} > /sys/bus/pci/devices/${passthru_bdf["cse"]}/driver/unbind
echo ${passthru_bdf["cse"]} > /sys/bus/pci/drivers/pci-stub/bind
boot_cse_option="$boot_cse_option"" -s 15,passthru,0/0f/0 "
else
boot_cse_option="$boot_cse_option"" -s 15,virtio-heci,0/0f/0 "
fi
#for memsize setting, total 8GB(>7.5GB) uos->6GB, 4GB(>3.5GB) uos->2GB
memsize=`cat /proc/meminfo|head -n 1|awk '{print $2}'`
if [ $memsize -gt 7500000 ];then
mem_size=6G
elif [ $memsize -gt 3500000 ];then
mem_size=2G
else
mem_size=1750M
fi
if [ "$setup_mem" != "" ];then
mem_size=$setup_mem
fi
kernel_cmdline_generic="nohpet tsc=reliable intel_iommu=off \
androidboot.serialno=$ser \
i915.enable_rc6=1 i915.enable_fbc=1 i915.enable_guc_loading=0 i915.avail_planes_per_pipe=$3 \
i915.enable_hangcheck=0 use_nuclear_flip=1 i915.enable_guc_submission=0 i915.enable_guc=0"
boot_dev_flag=",b"
if [ $6 == 1 ];then
boot_image_option="--vsbl /usr/share/acrn/bios/VSBL_debug.bin"
else
boot_image_option="--vsbl /usr/share/acrn/bios/VSBL.bin"
fi
kernel_cmdline="$kernel_cmdline_generic"
: '
select right virtual slots for acrn_dm:
1. some passthru device need virtual slot same as physical, like audio 0:e.0 at
virtual #14 slot, so "-s 14,passthru,0/e/0"
2. acrn_dm share vioapic irq between some virtual slots: like 6&14, 7&15. Need
guarantee no virt irq sharing for each passthru device.
FIXME: picking a virtual slot (#24 now) which is level-triggered to make sure
audio codec passthrough working
3. the bootable device slot is configured in compile stating in Android Guest
image, it should be kept using 3 as fixed value for Android Guest on Gordon_peak
ACRN project
'
#interrupt storm monitor for pass-through devices, params order:
#threshold/s,probe-period(s),intr-inject-delay-time(ms),delay-duration(ms)
intr_storm_monitor="--intr_monitor 10000,10,1,100"
acrn-dm --help 2>&1 | grep 'GVT args'
if [ $? == 0 ];then
GVT_args=$2
boot_GVT_option=" -s 2,pci-gvt -G "
else
boot_GVT_option=''
GVT_args=''
fi
#logger_setting, format: logger_name,level; like following
logger_setting="--logger_setting console,level=4;kmsg,level=3;disk,level=5"
acrn-dm -A -m $mem_size $boot_GVT_option"$GVT_args" -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio $npk_virt\
-s 9,virtio-net,$tap \
-s 3,virtio-blk$boot_dev_flag,/data/$4/$4.img \
-s 7,xhci,1-1:1-2:1-3:2-1:2-2:2-3:cap=apl \
-s 8,passthru,0/15/1 \
-s 13,virtio-rpmb \
-s 10,virtio-hyper_dmabuf \
-s 11,wdt-i6300esb \
$boot_audio_option \
$boot_cse_option \
$intr_storm_monitor \
$logger_setting \
$boot_ipu_option \
--mac_seed $mac_seed \
$boot_image_option \
--enable_trusty \
--pm_notify_channel power_button \
-B "$kernel_cmdline" $vm_name
}
function launch_alios()
{
#AliOS is not Android, only has same configuration currently, reuse launch function
launch_android "$@"
}
function help()
{
echo "Use luanch_uos.sh like that ./launch_uos.sh -V <#>"
echo "The option -V means the UOSs group to be launched by vsbl as below"
echo "-V 1 means just launching 1 clearlinux UOS"
echo "-V 2 means just launching 1 android UOS"
echo "-V 3 means launching 1 clearlinux UOS + 1 android UOS"
echo "-V 4 means launching 2 clearlinux UOSs"
echo "-V 5 means just launching 1 alios UOS"
echo "-V 6 means auto check android/linux/alios UOS; if exist, launch it"
}
launch_type=1
debug=0
while getopts "V:M:hd" opt
do
case $opt in
V) launch_type=$[$OPTARG]
;;
M) setup_mem=$OPTARG
;;
d) debug=1
;;
h) help
exit 1
;;
?) help
exit 1
;;
esac
done
if [ ! -b "/dev/mmcblk0p1" ]; then
echo "no /dev/mmcblk0p1 data partition, exit"
exit
fi
mkdir -p /data
mount /dev/mmcblk0p1 /data
if [ $launch_type == 6 ]; then
if [ -f "/data/android/android.img" ]; then
launch_type=2;
elif [ -f "/data/alios/alios.img" ]; then
launch_type=5;
else
launch_type=1;
fi
fi
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
online=`cat $i/online`
# during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod
while [ "$online" = "1" ]; do
sleep 1
echo 0 > $i/online
online=`cat $i/online`
done
echo $idx > ${offline_path}/offline_cpu
fi
done
case $launch_type in
1) echo "Launch clearlinux UOS"
launch_clearlinux 1 "64 448 8" 0x070F00 clearlinux "LaaG" $debug
;;
2) echo "Launch android UOS"
launch_android 1 "64 448 8" 0x070F00 android "AaaG" $debug
;;
3) echo "Launch clearlinux UOS + android UOS"
launch_android 1 "64 448 4" 0x00000C android "AaaG" $debug &
sleep 5
launch_clearlinux 2 "64 448 4" 0x070F00 clearlinux "LaaG" $debug
;;
4) echo "Launch two clearlinux UOSs"
launch_clearlinux 1 "64 448 4" 0x00000C clearlinux "L1aaG" $debug &
sleep 5
launch_clearlinux 2 "64 448 4" 0x070F00 clearlinux_dup "L2aaG" $debug
;;
5) echo "Launch alios UOS"
launch_alios 1 "64 448 8" 0x070F00 alios "AliaaG" $debug
;;
esac
umount /data

View File

@@ -1,49 +0,0 @@
#!/bin/bash
# Copyright (C) 2020 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
function launch_ubuntu()
{
vm_name=ubuntu_vm$1
logger_setting="--logger_setting console,level=5;kmsg,level=6;disk,level=5"
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#for memsize setting
mem_size=1024M
acrn-dm -A -m $mem_size -s 0:0,hostbridge \
-s 3,virtio-blk,/home/guestl1/acrn-dm-bins/ubuntuUOS.img \
-s 4,virtio-net,tap0 \
-s 5,virtio-console,@stdio:stdio_port \
-k /home/guestl1/acrn-dm-bins/bzImage_uos \
-B "earlyprintk=serial,ttyS0,115200n8 consoleblank=0 root=/dev/vda1 rw rootwait maxcpus=1 nohpet console=tty0 console=hvc0 console=ttyS0 no_timer_check ignore_loglevel log_buf_len=16M tsc=reliable" \
$logger_setting \
$vm_name
}
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
# during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod
while [ "$online" = "1" ]; do
sleep 1
echo 0 > $i/online
online=`cat $i/online`
done
echo $idx > /sys/class/vhm/acrn_vhm/offline_cpu
fi
done
launch_ubuntu 1 "64 448 8"

View File

@@ -1,83 +0,0 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
# This is an example of launch script for KBL NUC7i7DNH, may need to revise for other platform.
# pci devices for passthru
declare -A passthru_vpid
declare -A passthru_bdf
passthru_vpid=(
["eth"]="8086 156f"
["sata"]="8086 9d03"
["nvme"]="8086 f1a6"
)
passthru_bdf=(
["eth"]="0000:00:1f.6"
["sata"]="0000:00:17.0"
["nvme"]="0000:02:00.0"
)
function launch_hard_rt_vm()
{
#for memsize setting
mem_size=1024M
modprobe pci_stub
# Ethernet pass-through
#echo ${passthru_vpid["eth"]} > /sys/bus/pci/drivers/pci-stub/new_id
#echo ${passthru_bdf["eth"]} > /sys/bus/pci/devices/${passthru_bdf["eth"]}/driver/unbind
#echo ${passthru_bdf["eth"]} > /sys/bus/pci/drivers/pci-stub/bind
# SATA pass-through
#echo ${passthru_vpid["sata"]} > /sys/bus/pci/drivers/pci-stub/new_id
#echo ${passthru_bdf["sata"]} > /sys/bus/pci/devices/${passthru_bdf["sata"]}/driver/unbind
#echo ${passthru_bdf["sata"]} > /sys/bus/pci/drivers/pci-stub/bind
# NVME pass-through
echo ${passthru_vpid["nvme"]} > /sys/bus/pci/drivers/pci-stub/new_id
echo ${passthru_bdf["nvme"]} > /sys/bus/pci/devices/${passthru_bdf["nvme"]}/driver/unbind
echo ${passthru_bdf["nvme"]} > /sys/bus/pci/drivers/pci-stub/bind
# for pm setting
pm_channel="--pm_notify_channel uart "
pm_by_vuart="--pm_by_vuart tty,/dev/ttyS1"
/usr/bin/acrn-dm -A -m $mem_size -s 0:0,hostbridge \
--lapic_pt \
--rtvm \
--virtio_poll 1000000 \
-U 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 \
-s 2,passthru,02/0/0 \
-s 3,virtio-console,@stdio:stdio_port \
$pm_channel $pm_by_vuart \
--ovmf /usr/share/acrn/bios/OVMF.fd \
hard_rtvm
}
# -s 2,passthru,0/17/0 \ #please using "lspci -nn" check the bdf info
# Depends on which partation RT_LaaG is installed in;maybe need to change
# /dev/nvme0n1p3 to /dev/sda3 on NUC and uncomment SATA pass-through
# Add following RT_LaaG kernel cmdline into loader/entries/xxx.conf of EFI partation
#root=/dev/nvme0n1p3 rw rootwait nohpet console=hvc0 console=ttyS0 \
#no_timer_check ignore_loglevel log_buf_len=16M consoleblank=0 \
#clocksource=tsc tsc=reliable x2apic_phys processor.max_cstate=0 \
#intel_idle.max_cstate=0 intel_pstate=disable mce=ignore_ce audit=0 \
#isolcpus=nohz,domain,1 nohz_full=1 rcu_nocbs=1 nosoftlockup idle=poll \
#irqaffinity=0
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
echo $idx > /sys/class/vhm/acrn_vhm/offline_cpu
fi
done
launch_hard_rt_vm

View File

@@ -1,152 +0,0 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
offline_path="/sys/class/vhm/acrn_vhm"
# Check the device file of /dev/acrn_hsm to determine the offline_path
if [ -e "/dev/acrn_hsm" ]; then
offline_path="/sys/class/acrn/acrn_hsm"
fi
function run_container()
{
vm_name=vm1
config_src="/usr/share/acrn/samples/nuc/runC.json"
shell="/usr/share/acrn/conf/add/$vm_name.sh"
arg_file="/usr/share/acrn/conf/add/$vm_name.args"
runc_bundle="/usr/share/acrn/conf/add/runc/$vm_name"
rootfs_dir="/usr/share/acrn/conf/add/runc/rootfs"
config_dst="$runc_bundle/config.json"
input=$(runc list -f table | awk '{print $1}''{print $3}')
arr=(${input// / })
for((i=0;i<${#arr[@]};i++))
do
if [ "$vm_name" = "${arr[$i]}" ]; then
if [ "running" = "${arr[$i+1]}" ]; then
echo "runC instance ${arr[$i]} is running"
exit
else
runc kill ${arr[$i]}
runc delete ${arr[$i]}
fi
fi
done
vmsts=$(acrnctl list)
vms=(${vmsts// / })
for((i=0;i<${#vms[@]};i++))
do
if [ "$vm_name" = "${vms[$i]}" ]; then
if [ "stopped" != "${vms[$i+1]}" ]; then
echo "Uos ${vms[$i]} ${vms[$i+1]}"
acrnctl stop ${vms[$i]}
fi
fi
done
if [ ! -f "$shell" ]; then
echo "Pls add the vm at first!"
exit
fi
if [ ! -f "$arg_file" ]; then
echo "Pls add the vm args!"
exit
fi
if [ ! -d "$rootfs_dir" ]; then
mkdir -p "$rootfs_dir"
fi
if [ ! -d "$runc_bundle" ]; then
mkdir -p "$runc_bundle"
fi
if [ ! -f "$config_dst" ]; then
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
fi
runc run --bundle $runc_bundle -d $vm_name
echo "The runC container is running in backgroud"
echo "'#runc exec <vmname> bash' to login the container bash"
exit
}
function launch_clear()
{
mac=$(cat /sys/class/net/e*/address)
vm_name=vm$1
mac_seed=${mac:9:8}-${vm_name}
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep -w "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#logger_setting, format: logger_name,level; like following
logger_setting="--logger_setting console,level=4;kmsg,level=3;disk,level=5"
#for pm by vuart setting
pm_channel="--pm_notify_channel uart "
pm_by_vuart="--pm_by_vuart pty,/run/acrn/life_mngr_"$vm_name
pm_vuart_node=" -s 1:0,lpc -l com2,/run/acrn/life_mngr_"$vm_name
#for memsize setting
mem_size=2048M
acrn-dm -A -m $mem_size -s 0:0,hostbridge \
-s 2,pci-gvt -G "$2" \
-s 5,virtio-console,@stdio:stdio_port \
-s 6,virtio-hyper_dmabuf \
-s 3,virtio-blk,/home/clear/uos/uos.img \
-s 4,virtio-net,tap0 \
-s 7,virtio-rnd \
--ovmf /usr/share/acrn/bios/OVMF.fd \
$pm_channel $pm_by_vuart $pm_vuart_node \
$logger_setting \
--mac_seed $mac_seed \
$vm_name
}
#add following cmdline to grub.cfg and update kernel
#when launching LaaG by OVMF
#rw rootwait maxcpus=1 nohpet console=tty0 console=hvc0
#console=ttyS0 no_timer_check ignore_loglevel
#log_buf_len=16M consoleblank=0
#tsc=reliable i915.avail_planes_per_pipe="64 448 8"
#i915.enable_hangcheck=0 i915.nuclear_pageflip=1
#i915.enable_guc_loading=0
#i915.enable_guc_submission=0 i915.enable_guc=0
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
# during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod
while [ "$online" = "1" ]; do
sleep 1
echo 0 > $i/online
online=`cat $i/online`
done
echo $idx > ${offline_path}/offline_cpu
fi
done
if [ "$1" = "-C" ];then
echo "runc_container"
run_container
else
launch_clear 1 "64 448 8" 0x070F00
fi

View File

@@ -1,52 +0,0 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
function launch_vxworks()
{
vm_name=vxworks_vm$1
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep -w "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#for memsize setting
mem_size=2048M
# Note:
# For RTVM with lapic_pt, we only support virtio devices with polling mode enabled for both
# front-end and back-end. The virtio devices with polling mode are not supported by VxWorks
# offically now and we are working on upstream the front-end drivers.
# OVMF console is not available with default parameters.
acrn-dm -A -m $mem_size -s 0:0,hostbridge \
-s 5,virtio-console,@stdio:stdio_port \
-s 3,virtio-blk,./VxWorks.img \
--virtio_poll 1000000 \
--ovmf /usr/share/acrn/bios/OVMF.fd \
--lapic_pt \
$vm_name
}
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
# during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod
while [ "$online" = "1" ]; do
sleep 1
echo 0 > $i/online
online=`cat $i/online`
done
echo $idx > /sys/class/vhm/acrn_vhm/offline_cpu
fi
done
launch_vxworks 1

View File

@@ -1,46 +0,0 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
function launch_win()
{
vm_name=win_vm$1
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#for memsize setting
mem_size=4096M
acrn-dm -A -m $mem_size -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \
-s 2,pci-gvt -G "$2" \
-s 3,virtio-blk,./win10-ltsc.img \
-s 4,virtio-net,tap0 \
--ovmf /usr/share/acrn/bios/OVMF.fd \
--windows \
$vm_name
}
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
# during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod
while [ "$online" = "1" ]; do
sleep 1
echo 0 > $i/online
online=`cat $i/online`
done
echo $idx > /sys/class/vhm/acrn_vhm/offline_cpu
fi
done
launch_win 1 "64 448 8"

View File

@@ -1,227 +0,0 @@
#!/bin/bash
# Copyright (C) 2020 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
# set -x
usage()
{
echo "$0 [-b disk | -f img] [-k kernel.tar.gz] {-n ethernet} {-B mem_size} {-r}"
echo " example:"
echo " $0 -b /dev/sdb3 -k ~/linux-4.19.tar.gz -n eth0"
echo " $0 -f clearlinux.img -k ../linux-5.2.tar -n eth0 -B 512M"
echo " $0 -f clearlinux.img -k ../linux-5.2.tar -n eth0 -r # restore passthroughed eth0 when script returns"
exit
}
function get_bdf()
{
IFS=/
for dir in $1; do
case $dir in 0000:??:??.?)
bdf=$dir;;
esac
done
unset IFS
echo $bdf
}
modprobe pci_stub
# pci devices for passthru
dev_opts=
declare -A passthru_devs
guest_pci_nr=2
function passthru_pci_devs()
{
for dev in "${passthrus[@]}"
do
dev_info=$(find /sys/devices/pci* -name $(basename $dev))
dev_bdf=$(get_bdf $dev_info)
dev_path=$(echo $dev_info | sed "s/$dev_bdf\(.*\)//g")$dev_bdf
dev_vendor_id=$(cat $dev_path/vendor | sed 's/0x//g')
dev_device_id=$(cat $dev_path/device | sed 's/0x//g')
dev_bus=$(echo ${dev_bdf#0000:}|sed "s/:.*//g")
dev_dev=$(echo $dev_bdf|sed "s/.*://g"|sed "s/\..*//g")
dev_fun=$(echo $dev_bdf|sed "s/.*\.//g")
dev_drv=$(lspci -k -s $dev_bdf | grep "Kernel driver in use"|sed "s/.*: //g")
dev_passthru_opt="-s $guest_pci_nr,passthru,$dev_bus/$dev_dev/$dev_fun"
echo "passthrough a pci device:"
echo dev_info:$dev_info
echo dev_path:$dev_path
echo dev_vendor_id:$dev_vendor_id
echo dev_device_id:$dev_device_id
echo dev_bus:$dev_bus
echo dev_dev:$dev_dev
echo dev_fun:$dev_fun
echo dev_drv:$dev_drv
echo dev_passthru_opt:$dev_passthru_opt
# replace its driver with pci-stub
echo "$dev_vendor_id $dev_device_id" > /sys/bus/pci/drivers/pci-stub/new_id
echo $dev_bdf > $dev_path/driver/unbind
echo $dev_bdf > /sys/bus/pci/drivers/pci-stub/bind
# add to global options
dev_opts="$dev_opts $dev_passthru_opt"
# register for de-passthrough later
passthru_devs[$dev_bdf]=$dev_drv
# increase virtual pci slot number
guest_pci_nr=$(expr $guest_pci_nr + 1)
done
}
function de_passthru_pci_devs()
{
for dev_bdf in "${!passthru_devs[@]}"
do
echo $dev_bdf > /sys/bus/pci/drivers/pci-stub/unbind
echo $dev_bdf > /sys/bus/pci/drivers/${passthru_devs[$dev_bdf]}/bind
done
}
mem_size=1024M
eth=
disk=
img=
kernel=
passthrus=()
while getopts hn:b:f:k:B:r opt
do
case "${opt}" in
h)
usage;
;;
r)
# restore pci device driver on exit
trap de_passthru_pci_devs EXIT
;;
n)
eth=${OPTARG}
passthrus+=($eth)
;;
b)
disk="${OPTARG}"
passthrus+=($disk)
;;
f)
img="${OPTARG}"
;;
k)
kernel="${OPTARG}"
;;
B)
mem_size="${OPTARG}"
;;
?)
echo "{OPTARG}"
;;
esac
done
if [[ ( -z "${kernel}") || (( -z "${disk}") && ( -z "${img}" )) ]]; then
usage; exit 1
fi
# create a unique tap device for each VM
if [ -z $eth ];then
tap=tap_rtvm
tap_exist=$(ip a | grep "$tap" | awk '{print $1}')
if [ "$tap_exist"x != "x" ]; then
echo "tap device existed, reuse $tap"
else
ip tuntap add dev $tap mode tap
ip link set "$tap" master acrn-br0
ip link set dev "$tap" down
ip link set dev "$tap" up
fi
dev_opts="$dev_opts -s $guest_pci_nr,virtio-net,$tap"
guest_pci_nr=$(expr $guest_pci_nr + 1)
fi
function launch_hard_rt_vm()
{
mkdir -p /mnt
if [ ! -z $img ]; then
# mount virtual disk (assuming the last partition is root)
vdisk=$(losetup -f -P --show $img)
vdisk_root=$(ls -1 ${vdisk}p* | tail -1)
mount $vdisk_root /mnt
# extract the kernel and install kernel modules
bzImage=/mnt/$(tar xzvf $kernel -C /mnt --dereference --exclude=vmlinux* | grep vmlinuz)
cp $bzImage /tmp/bzImage.xenomai
# umount disk
umount /mnt
losetup -d $vdisk
# find appropriate root partition information
disk_part_nr=$(basename $vdisk_root| sed 's/.*p\([0-9]$\)/\1/')
vdisk=/dev/vda$disk_part_nr
dev_opts="$dev_opts -s $guest_pci_nr,virtio-blk,$img"
guest_pci_nr=$(expr $guest_pci_nr + 1)
elif [ ! -z $disk ];then
# mount the physical disk
mount $disk /mnt
# extract the kernel and install kernel modules
bzImage=/mnt/$(tar xzvf $kernel -C /mnt --dereference --exclude=vmlinux* | grep vmlinuz)
cp $bzImage /tmp/bzImage.xenomai
# umount disk
umount /mnt
# detect partition information
disk_part_nr=$(basename $disk| sed 's/.*\([0-9]$\)/\1/')
if grep -q "nvme" "$disk"; then
vdisk=/dev/nvme0n1p$disk_part_nr
else
vdisk=/dev/sda$disk_part_nr
fi
fi
passthru_pci_devs
#logger_setting, format: logger_name,level; like following
logger_setting="--logger_setting console,level=4;kmsg,level=3;disk,level=5"
/usr/bin/acrn-dm -A -m $mem_size -s 0:0,hostbridge \
-k /tmp/bzImage.xenomai \
-U 495ae2e5-2603-4d64-af76-d4bc5a8ec0e5 \
--lapic_pt \
--rtvm \
--virtio_poll 1000000 \
-s 1,virtio-console,@stdio:stdio_port \
$dev_opts \
$logger_setting \
-B "root=$vdisk rw rootwait nohpet console=hvc0 consoleblank=0 \
no_timer_check ignore_loglevel log_buf_len=16M nmi_watchdog=0 nosoftlockup \
processor.max_cstate=0 intel_idle.max_cstate=0 intel_pstate=disable idle=poll \
rcu_nocb_poll isolcpus=1 nohz_full=1 rcu_nocbs=1 \
tsc=reliable x2apic_phys xenomai.supported_cpus=2 irqaffinity=0 mce=off" hard_rtvm
}
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
echo $idx > /sys/class/vhm/acrn_vhm/offline_cpu
fi
done
echo 3 > /sys/kernel/debug/dri/0/i915_cache_sharing
echo 300 > /sys/class/drm/card0/gt_max_freq_mhz
echo 300 > /sys/class/drm/card0/gt_min_freq_mhz
echo 300 > /sys/class/drm/card0/gt_boost_freq_mhz
launch_hard_rt_vm

View File

@@ -1,44 +0,0 @@
#!/bin/bash
# Copyright (C) 2019 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
function launch_zephyr()
{
vm_name=zephyr_vm$1
#check if the vm is running or not
vm_ps=$(pgrep -a -f acrn-dm)
result=$(echo $vm_ps | grep -w "${vm_name}")
if [[ "$result" != "" ]]; then
echo "$vm_name is running, can't create twice!"
exit
fi
#for memsize setting
mem_size=128M
acrn-dm -A -m $mem_size -s 0:0,hostbridge -s 1:0,lpc -l com1,stdio \
-s 5,virtio-console,@pty:pty_port \
-s 3,virtio-blk,./zephyr.img \
--ovmf /usr/share/acrn/bios/OVMF.fd \
$vm_name
}
# offline SOS CPUs except BSP before launch UOS
for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
online=`cat $i/online`
idx=`echo $i | tr -cd "[1-99]"`
echo cpu$idx online=$online
if [ "$online" = "1" ]; then
echo 0 > $i/online
# during boot time, cpu hotplug may be disabled by pci_device_probe during a pci module insmod
while [ "$online" = "1" ]; do
sleep 1
echo 0 > $i/online
online=`cat $i/online`
done
echo $idx > /sys/class/vhm/acrn_vhm/offline_cpu
fi
done
launch_zephyr 1

View File

@@ -1,274 +0,0 @@
{
"ociVersion": "1.0.1-dev",
"process": {
"terminal": false,
"user": {
"uid": 0,
"gid": 0
},
"args": [
"sh"
],
"env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"TERM=xterm"
],
"cwd": "/",
"capabilities": {
"bounding": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
],
"effective": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
],
"inheritable": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
],
"permitted": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
],
"ambient": [
"CAP_AUDIT_WRITE",
"CAP_CHOWN",
"CAP_DAC_OVERRIDE",
"CAP_DAC_READ_SEARCH",
"CAP_FOWNER",
"CAP_FSETID",
"CAP_KILL",
"CAP_SETGID",
"CAP_SETUID",
"CAP_SETPCAP",
"CAP_LINUX_IMMUTABLE",
"CAP_NET_BIND_SERVICE",
"CAP_NET_BROADCAST",
"CAP_NET_ADMIN",
"CAP_NET_RAW",
"CAP_IPC_LOCK",
"CAP_IPC_OWNER",
"CAP_SYS_MODULE",
"CAP_SYS_RAWIO",
"CAP_SYS_CHROOT",
"CAP_SYS_PTRACE",
"CAP_SYS_PACCT",
"CAP_SYS_ADMIN",
"CAP_SYS_BOOT",
"CAP_SYS_NICE",
"CAP_SYS_RESOURCE",
"CAP_SYS_TIME",
"CAP_SYS_TTY_CONFIG",
"CAP_MKNOD",
"CAP_LEASE",
"CAP_AUDIT_WRITE",
"CAP_AUDIT_CONTROL",
"CAP_SETFCAP",
"CAP_MAC_OVERRIDE",
"CAP_MAC_ADMIN",
"CAP_SYSLOG",
"CAP_WAKE_ALARM",
"CAP_BLOCK_SUSPEND",
"CAP_AUDIT_READ"
]
}
},
"root": {
"path": "../rootfs",
"readonly": false
},
"hostname": "runc",
"mounts": [
{
"destination": "/",
"type": "none",
"source": "/",
"options": ["rbind","rw"]
}
],
"linux": {
"resources": {
"devices": [
{
"allow": true,
"access": "rwm"
}
]
},
"uidMappings": [
{
"hostID": 0,
"containerID": 0,
"size": 1
}
],
"gidMappings": [
{
"hostID": 0,
"containerID": 0,
"size": 1
}
],
"namespaces": [
{
"type": "pid"
},
{
"type": "uts"
},
{
"type": "mount"
}
]
}
}