Skip to content

Commit 4887736

Browse files
liudlongEddie Dong
authored andcommitted
ACRN: DM: Add new options for NUC launch_uos script.
The patch adds new argument for launch_uos script for NUC. In the patch add "-C" parameter for launch_uos script. When launch the script with the parameter the ACRN-dm will be launched in the runC container. For more information about this please refer to ACRN-dm QoS document. Tracked-On: #2020 Signed-off-by: Long Liu <long.liu@intel.com> Reviewed-by: Binbin Wu binbin.wu@intel.com Reviewed-by: Geoffroy Van Cutsem geoffroy.vancutsem@intel.com
1 parent f7f2a6e commit 4887736

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

devicemodel/samples/nuc/launch_uos.sh

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,74 @@ if [ -e "/dev/acrn_hsm" ]; then
77
offline_path="/sys/class/acrn/acrn_hsm"
88
fi
99

10+
11+
function run_container()
12+
{
13+
vm_name=vm1
14+
config_src="/usr/share/acrn/samples/nuc/runC.json"
15+
shell="/usr/share/acrn/conf/add/$vm_name.sh"
16+
arg_file="/usr/share/acrn/conf/add/$vm_name.args"
17+
runc_bundle="/usr/share/acrn/conf/add/runc/$vm_name"
18+
rootfs_dir="/usr/share/acrn/conf/add/runc/rootfs"
19+
config_dst="$runc_bundle/config.json"
20+
21+
22+
input=$(runc list -f table | awk '{print $1}''{print $3}')
23+
arr=(${input// / })
24+
25+
for((i=0;i<${#arr[@]};i++))
26+
do
27+
if [ "$vm_name" = "${arr[$i]}" ]; then
28+
if [ "running" = "${arr[$i+1]}" ]; then
29+
echo "runC instance ${arr[$i]} is running"
30+
exit
31+
else
32+
runc kill ${arr[$i]}
33+
runc delete ${arr[$i]}
34+
fi
35+
fi
36+
done
37+
vmsts=$(acrnctl list)
38+
vms=(${vmsts// / })
39+
for((i=0;i<${#vms[@]};i++))
40+
do
41+
if [ "$vm_name" = "${vms[$i]}" ]; then
42+
if [ "stopped" != "${vms[$i+1]}" ]; then
43+
echo "Uos ${vms[$i]} ${vms[$i+1]}"
44+
acrnctl stop ${vms[$i]}
45+
fi
46+
fi
47+
done
48+
49+
50+
if [ ! -f "$shell" ]; then
51+
echo "Pls add the vm at first!"
52+
exit
53+
fi
54+
55+
if [ ! -f "$arg_file" ]; then
56+
echo "Pls add the vm args!"
57+
exit
58+
fi
59+
60+
61+
if [ ! -d "$rootfs_dir" ]; then
62+
mkdir -p "$rootfs_dir"
63+
fi
64+
if [ ! -d "$runc_bundle" ]; then
65+
mkdir -p "$runc_bundle"
66+
fi
67+
if [ ! -f "$config_dst" ]; then
68+
cp "$config_src" "$config_dst"
69+
args=$(sed '{s/-C//g;s/^[ \t]*//g;s/^/\"/;s/ /\",\"/g;s/$/\"/}' ${arg_file})
70+
sed -i "s|\"sh\"|\"$shell\", $args|" $config_dst
71+
fi
72+
runc run --bundle $runc_bundle -d $vm_name
73+
echo "The runC container is running in backgroud"
74+
echo "'#runc exec <vmname> bash' to login the container bash"
75+
exit
76+
}
77+
1078
function launch_clear()
1179
{
1280
mac=$(cat /sys/class/net/e*/address)
@@ -60,4 +128,10 @@ for i in `ls -d /sys/devices/system/cpu/cpu[1-99]`; do
60128
fi
61129
done
62130

63-
launch_clear 1 1 "64 448 8" 0x070F00
131+
132+
if [ "$1" = "-C" ];then
133+
echo "runc_container"
134+
run_container
135+
else
136+
launch_clear 1 1 "64 448 8" 0x070F00
137+
fi

0 commit comments

Comments
 (0)