mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-07 11:50:30 +00:00
HV:Acrn-hypvervisor Root Directory Clean-up and create misc/ folder for Acrn daemons, services and tools.
This patch is to clean-up acrn-hypervisor root directory, targt only 5 folders under acrn-hypervisor:1.hypervisor,2.devicemodel,3.misc,4.doc,5.build Tracked-On: #3482 Signed-off-by: Terry Zou <terry.zou@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
2
misc/tools/acrn-crashlog/data/40-watchdog.conf
Normal file
2
misc/tools/acrn-crashlog/data/40-watchdog.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
[Manager]
|
||||
RuntimeWatchdogSec=40
|
7
misc/tools/acrn-crashlog/data/80-coredump.conf
Normal file
7
misc/tools/acrn-crashlog/data/80-coredump.conf
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is part of acrn-hypervisor.
|
||||
|
||||
# See sysctl.d(5) for the description of the files in this directory,
|
||||
# and systemd-coredump(8) and core(5) for the explanation of the
|
||||
# setting below.
|
||||
|
||||
kernel.core_pattern=|/usr/bin/usercrash-wrapper %E %P %u %g %s %t %c %h %e %p %i %I %d
|
2
misc/tools/acrn-crashlog/data/acrn-crashlog-dirs.conf
Normal file
2
misc/tools/acrn-crashlog/data/acrn-crashlog-dirs.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
#Type Path Mode UID GID Age Argument
|
||||
d /var/log/crashlog 0750 telemetry telemetry -
|
14
misc/tools/acrn-crashlog/data/acrnprobe.service
Normal file
14
misc/tools/acrn-crashlog/data/acrnprobe.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=ACRN crashlog probe
|
||||
Requires=telemd.socket
|
||||
Requires=usercrash_s
|
||||
After=acrnlog.service
|
||||
After=usercrash.service
|
||||
After=prepare.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/acrnprobe
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
189
misc/tools/acrn-crashlog/data/acrnprobe.xml
Normal file
189
misc/tools/acrn-crashlog/data/acrnprobe.xml
Normal file
@@ -0,0 +1,189 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<conf>
|
||||
<senders>
|
||||
<sender id="1" enable="true">
|
||||
<name>crashlog</name>
|
||||
<outdir>/var/log/crashlog</outdir>
|
||||
<maxcrashdirs>1000</maxcrashdirs>
|
||||
<maxlines>5000</maxlines>
|
||||
<spacequota>90</spacequota>
|
||||
<foldersize>200</foldersize>
|
||||
<uptime>
|
||||
<name>UPTIME</name>
|
||||
<frequency>5</frequency>
|
||||
<eventhours>6</eventhours>
|
||||
</uptime>
|
||||
</sender>
|
||||
<sender id="2" enable="true">
|
||||
<name>telemd</name>
|
||||
<outdir>/var/log/acrnprobe</outdir>
|
||||
<uptime>
|
||||
<name>UPTIME</name>
|
||||
<frequency>5</frequency>
|
||||
<eventhours>6</eventhours>
|
||||
</uptime>
|
||||
</sender>
|
||||
</senders>
|
||||
|
||||
<triggers>
|
||||
<trigger id="1" enable="true">
|
||||
<name>t_pstore</name>
|
||||
<type>node</type>
|
||||
<path>/sys/fs/pstore/[*]</path>
|
||||
</trigger>
|
||||
<trigger id="2" enable="true">
|
||||
<name>t_boot</name>
|
||||
<type>file</type>
|
||||
<path>/proc/cmdline</path>
|
||||
</trigger>
|
||||
<trigger id="3" enable="true">
|
||||
<name>t_usercrash</name>
|
||||
<type>dir</type>
|
||||
<path>/var/log/usercrashes</path>
|
||||
</trigger>
|
||||
<trigger id="4" enable="true">
|
||||
<name>t_rebootreason</name>
|
||||
<type>rebootreason</type>
|
||||
</trigger>
|
||||
<trigger id="5" enable="true">
|
||||
<name>t_acrnlog_last</name>
|
||||
<type>file</type>
|
||||
<path>/tmp/acrnlog/acrnlog_last.[*]</path>
|
||||
</trigger>
|
||||
</triggers>
|
||||
|
||||
<vms enable="true">
|
||||
<vm id="1" enable="true">
|
||||
<name>VM1</name>
|
||||
<channel>polling</channel>
|
||||
<interval>60</interval>
|
||||
<syncevent id="1">CRASH/UIWDT</syncevent>
|
||||
<syncevent id="2">CRASH/IPANIC</syncevent>
|
||||
<syncevent id="3">REBOOT</syncevent>
|
||||
</vm>
|
||||
</vms>
|
||||
|
||||
<logs>
|
||||
<log id="1" enable="true">
|
||||
<name>pstore</name>
|
||||
<type>node</type>
|
||||
<deletesource>true</deletesource>
|
||||
<path>/sys/fs/pstore/[*]</path>
|
||||
</log>
|
||||
<log id='2' enable='true'>
|
||||
<name>kmsg</name>
|
||||
<type>node</type>
|
||||
<path>/dev/kmsg</path>
|
||||
<sizelimit>2</sizelimit>
|
||||
</log>
|
||||
<log id='3' enable='true'>
|
||||
<name>cmdline</name>
|
||||
<type>node</type>
|
||||
<path>/proc/cmdline</path>
|
||||
</log>
|
||||
<log id='4' enable='true'>
|
||||
<name>syslog</name>
|
||||
<type>cmd</type>
|
||||
<path>journalctl -b -0 -n 300 --no-pager</path>
|
||||
</log>
|
||||
<log id='5' enable='true'>
|
||||
<name>acrnlog_cur</name>
|
||||
<type>file</type>
|
||||
<path>/tmp/acrnlog/acrnlog_cur.[-1]</path>
|
||||
<lines>500</lines>
|
||||
</log>
|
||||
<log id='6' enable='true'>
|
||||
<name>acrnlog_last</name>
|
||||
<type>file</type>
|
||||
<path>/tmp/acrnlog/acrnlog_last.[*]</path>
|
||||
</log>
|
||||
</logs>
|
||||
|
||||
<crashes>
|
||||
<crash id='1' inherit='0' enable='true'>
|
||||
<name>UNKNOWN</name>
|
||||
<trigger>t_rebootreason</trigger>
|
||||
<channel>oneshot</channel>
|
||||
<content id='1'>WARM</content>
|
||||
<log id='1'>pstore</log>
|
||||
<log id='2'>acrnlog_last</log>
|
||||
</crash>
|
||||
<crash id='2' inherit='0' enable='true'>
|
||||
<name>SWWDT_UNHANDLE</name>
|
||||
<trigger>t_rebootreason</trigger>
|
||||
<channel>oneshot</channel>
|
||||
<content id='1'>WATCHDOG</content>
|
||||
<log id='1'>pstore</log>
|
||||
<log id='2'>acrnlog_last</log>
|
||||
</crash>
|
||||
<crash id='3' inherit='0' enable='true'>
|
||||
<name>HWWDT_UNHANDLE</name>
|
||||
<trigger>t_rebootreason</trigger>
|
||||
<channel>oneshot</channel>
|
||||
<content id='1'>GLOBAL</content>
|
||||
<log id='1'>pstore</log>
|
||||
<log id='2'>acrnlog_last</log>
|
||||
</crash>
|
||||
<crash id='4' inherit='1' enable='true'>
|
||||
<name>ACRNCRASH</name>
|
||||
<trigger>t_acrnlog_last</trigger>
|
||||
<content id='1'>= Unhandled exception:</content>
|
||||
</crash>
|
||||
<crash id='5' inherit='1' enable='true'>
|
||||
<name>IPANIC</name>
|
||||
<trigger>t_pstore</trigger>
|
||||
<content id='1'> </content>
|
||||
<mightcontent expression='1' id='1'>Kernel panic - not syncing:</mightcontent>
|
||||
<mightcontent expression='1' id='2'>BUG: unable to handle kernel</mightcontent>
|
||||
<data id='1'>kernel BUG at</data>
|
||||
<data id='2'>EIP is at</data>
|
||||
<data id='3'>Comm:</data>
|
||||
</crash>
|
||||
<crash id='6' inherit='2' enable='true'>
|
||||
<name>ACRNCRASH</name>
|
||||
<trigger>t_acrnlog_last</trigger>
|
||||
<content id='1'>= Unhandled exception:</content>
|
||||
</crash>
|
||||
<crash id='7' inherit='2' enable='true'>
|
||||
<name>SWWDT_IPANIC</name>
|
||||
<trigger>t_pstore</trigger>
|
||||
<content id='1'> </content>
|
||||
<mightcontent expression='1' id='1'>Kernel panic - not syncing:</mightcontent>
|
||||
<mightcontent expression='1' id='2'>BUG: unable to handle kernel</mightcontent>
|
||||
<data id='1'>kernel BUG at</data>
|
||||
<data id='2'>EIP is at</data>
|
||||
<data id='3'>Comm:</data>
|
||||
</crash>
|
||||
<crash id='8' inherit='0' enable='true'>
|
||||
<name>USERCRASH</name>
|
||||
<trigger>t_usercrash</trigger>
|
||||
<channel>inotify</channel>
|
||||
<log id='1'>kmsg</log>
|
||||
<log id='2'>syslog</log>
|
||||
</crash>
|
||||
<crash id='9' inherit='0' enable='true'>
|
||||
<name>IPANIC</name>
|
||||
<trigger>t_pstore</trigger>
|
||||
<channel>oneshot</channel>
|
||||
<mightcontent expression='1' id='1'>Kernel panic - not syncing:</mightcontent>
|
||||
<mightcontent expression='1' id='2'>BUG: unable to handle kernel</mightcontent>
|
||||
<data id='1'>kernel BUG at</data>
|
||||
<data id='2'>EIP is at</data>
|
||||
<data id='3'>Comm:</data>
|
||||
<log id='1'>pstore</log>
|
||||
</crash>
|
||||
</crashes>
|
||||
|
||||
<infos>
|
||||
<info id='1' enable='true'>
|
||||
<name>BOOT_LOGS</name>
|
||||
<trigger>t_boot</trigger>
|
||||
<channel>oneshot</channel>
|
||||
<log id='1'>kmsg</log>
|
||||
<log id='2'>cmdline</log>
|
||||
<log id='3'>acrnlog_cur</log>
|
||||
<log id='4'>acrnlog_last</log>
|
||||
</info>
|
||||
</infos>
|
||||
|
||||
</conf>
|
194
misc/tools/acrn-crashlog/data/crashlogctl
Executable file
194
misc/tools/acrn-crashlog/data/crashlogctl
Executable file
@@ -0,0 +1,194 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) <2018> Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
# crashlogctl is part of acrn-hypervisor.
|
||||
#
|
||||
|
||||
declare -a CRASHLOG_SERVICES=(
|
||||
acrnprobe.service
|
||||
usercrash.service
|
||||
)
|
||||
|
||||
declare -a TELEMD_SERVICES=(
|
||||
hprobe.timer
|
||||
telemd-update-trigger.service
|
||||
pstore-clean.service
|
||||
pstore-probe.service
|
||||
oops-probe.service
|
||||
klogscanner.service
|
||||
journal-probe.service
|
||||
bert-probe.service
|
||||
)
|
||||
|
||||
SCRIPT="$0"
|
||||
TELEM_DIR=/etc/telemetrics
|
||||
OPT_OUT_FILE=${TELEM_DIR}/opt-out
|
||||
USER_CONF_FILE=${TELEM_DIR}/telemetrics.conf
|
||||
SYSTEM_CONF_FILE=/usr/share/defaults/telemetrics/telemetrics.conf
|
||||
CRASHLOG_SHARE_DIR=/usr/share/acrn/crashlog
|
||||
CRASHLOG_SYSTEM_CONF=${CRASHLOG_SHARE_DIR}/40-watchdog.conf
|
||||
CRASHLOG_SYSCTL_CONF=${CRASHLOG_SHARE_DIR}/80-coredump.conf
|
||||
CRASHLOG_VAR_DIR=/var/log/crashlog
|
||||
CRASHLOG_CORE_BACKUP=${CRASHLOG_VAR_DIR}/default_core_pattern
|
||||
CRASHLOG_S_D_BACKUP=${CRASHLOG_VAR_DIR}/server_delivery_enabled
|
||||
CRASHLOG_R_R_BACKUP=${CRASHLOG_VAR_DIR}/record_retention_enabled
|
||||
CRASHLOG_WRK_DIRS_CONF=/usr/lib/tmpfiles.d/acrn-crashlog-dirs.conf
|
||||
CORE_PATTERN_CONF="/proc/sys/kernel/core_pattern"
|
||||
|
||||
create_work_dirs() {
|
||||
# Creates dirs if missing, adjust ownership if exists
|
||||
systemd-tmpfiles --create ${CRASHLOG_WRK_DIRS_CONF}
|
||||
}
|
||||
|
||||
exit_ok() {
|
||||
echo "$1" > /dev/stderr
|
||||
exit 0
|
||||
}
|
||||
|
||||
exit_err() {
|
||||
echo "$1" > /dev/stderr
|
||||
exit 1
|
||||
}
|
||||
|
||||
notice() {
|
||||
echo "$1" > /dev/stderr
|
||||
}
|
||||
|
||||
for_each_service() {
|
||||
local action=$1 && shift
|
||||
local -a array=($*)
|
||||
for service in "${array[@]}"; do
|
||||
systemctl $action $service
|
||||
[ $? -ne 0 ] && notice "Failed to $action ${service}. Continuing..."
|
||||
done
|
||||
}
|
||||
|
||||
crashlog_enable() {
|
||||
[ -f $OPT_OUT_FILE ] && exit_err "Opt out is enabled. Cannot start services."
|
||||
# trigger systemd-tmpfiles work dirs creation
|
||||
create_work_dirs
|
||||
|
||||
# backup the default core_pattern
|
||||
if [ -f ${CRASHLOG_CORE_BACKUP} ]
|
||||
then
|
||||
notice "... ${CRASHLOG_CORE_BACKUP} already exist. Do not perform backup"
|
||||
else
|
||||
cat ${CORE_PATTERN_CONF} > ${CRASHLOG_CORE_BACKUP}
|
||||
notice "... Backup core pattern to ${CRASHLOG_CORE_BACKUP}"
|
||||
fi
|
||||
|
||||
# copy the configure file
|
||||
if [ ! -f ${USER_CONF_FILE} ]
|
||||
then
|
||||
mkdir -p ${TELEM_DIR}
|
||||
cp -v ${SYSTEM_CONF_FILE} ${USER_CONF_FILE}
|
||||
fi
|
||||
|
||||
# modify the telemetics configure file
|
||||
if grep --quiet server_delivery_enabled=true ${USER_CONF_FILE}
|
||||
then
|
||||
sed -i "s/server_delivery_enabled=true/server_delivery_enabled=false/g" ${USER_CONF_FILE}
|
||||
echo 1 > ${CRASHLOG_S_D_BACKUP}
|
||||
notice "... Set server_delivery_enabled=false in ${USER_CONF_FILE}"
|
||||
fi
|
||||
|
||||
if grep --quiet record_retention_enabled=false ${USER_CONF_FILE}
|
||||
then
|
||||
sed -i "s/record_retention_enabled=false/record_retention_enabled=true/g" ${USER_CONF_FILE}
|
||||
echo 1 > ${CRASHLOG_R_R_BACKUP}
|
||||
notice "... Set record_retention_enabled=true in ${USER_CONF_FILE}"
|
||||
fi
|
||||
|
||||
# Copy watchdog and coredump conf files
|
||||
mkdir -p /etc/systemd/system.conf.d
|
||||
cp -v ${CRASHLOG_SYSTEM_CONF} /etc/systemd/system.conf.d
|
||||
mkdir -p /etc/sysctl.d
|
||||
cp -v ${CRASHLOG_SYSCTL_CONF} /etc/sysctl.d
|
||||
|
||||
# Mask telemd services
|
||||
for_each_service "mask" ${TELEMD_SERVICES[@]}
|
||||
# Enable chrashlog services
|
||||
for_each_service "enable" ${CRASHLOG_SERVICES[@]}
|
||||
|
||||
exit_ok "*** Please reboot your system. ***"
|
||||
}
|
||||
|
||||
crashlog_disable() {
|
||||
# Disable chrashlog services
|
||||
for_each_service "disable" ${CRASHLOG_SERVICES[@]}
|
||||
# Unmask telemd services
|
||||
for_each_service "unmask" ${TELEMD_SERVICES[@]}
|
||||
|
||||
rm -v /etc/sysctl.d/${CRASHLOG_SYSCTL_CONF##*/}
|
||||
rm -v /etc/systemd/system.conf.d/${CRASHLOG_SYSTEM_CONF##*/}
|
||||
|
||||
# modify the telemetics configure file
|
||||
if [ -f ${CRASHLOG_S_D_BACKUP} ]
|
||||
then
|
||||
sed -i "s/server_delivery_enabled=false/server_delivery_enabled=true/g" ${USER_CONF_FILE}
|
||||
rm -f ${CRASHLOG_S_D_BACKUP}
|
||||
notice "... Set server_delivery_enabled=true in ${USER_CONF_FILE}"
|
||||
fi
|
||||
|
||||
if [ -f ${CRASHLOG_R_R_BACKUP} ]
|
||||
then
|
||||
sed -i "s/record_retention_enabled=true/record_retention_enabled=false/g" ${USER_CONF_FILE}
|
||||
rm -f ${CRASHLOG_R_R_BACKUP}
|
||||
notice "... Set record_retention_enabled=false in ${USER_CONF_FILE}"
|
||||
fi
|
||||
|
||||
rm -f ${CRASHLOG_CORE_BACKUP}
|
||||
|
||||
exit_ok "*** Please reboot your system. ***"
|
||||
}
|
||||
|
||||
crashlog_is_active() {
|
||||
# check only activation units
|
||||
echo "telemprobd :" $(systemctl is-active telemprobd.socket)
|
||||
echo "telempostd :" $(systemctl is-active telempostd.path)
|
||||
echo "acrnprobe :" $(systemctl is-active acrnprobe.service)
|
||||
echo "usercrash :" $(systemctl is-active usercrash.service)
|
||||
}
|
||||
|
||||
|
||||
usage() {
|
||||
format=' %-10s %s\n'
|
||||
printf "\n"
|
||||
printf "%s - Control actions for ACRN crashlog services\n" "$SCRIPT"
|
||||
printf "\n"
|
||||
printf "$format" "enable" "Enable the ACRN crashlog services"
|
||||
printf "$format" "disable" "Disable the ACRN crashlog services"
|
||||
printf "$format" "is-active" "Checks if ACRN crashlog is active"
|
||||
printf "\n"
|
||||
exit 2
|
||||
}
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ $EUID -ne 0 ]; then
|
||||
exit_err "Must be root to run this command. Exiting..."
|
||||
fi
|
||||
|
||||
SUBCOMMAND=$1
|
||||
|
||||
case $SUBCOMMAND in
|
||||
enable)
|
||||
crashlog_enable ;;
|
||||
disable)
|
||||
crashlog_disable ;;
|
||||
is-active)
|
||||
crashlog_is_active ;;
|
||||
--help | -h)
|
||||
usage ;;
|
||||
*)
|
||||
notice "Unknown command passed to $SCRIPT"
|
||||
usage ;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# vi: ts=8 sw=2 sts=2 et tw=80
|
53
misc/tools/acrn-crashlog/data/usercrash-wrapper
Executable file
53
misc/tools/acrn-crashlog/data/usercrash-wrapper
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) <2018> Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
if [ $# != 13 ]; then
|
||||
logger "Expected 13 arguments, got $#"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Error Handling
|
||||
default_core_pattern_file="/var/log/crashlog/default_core_pattern"
|
||||
|
||||
if [ ! -f $default_core_pattern_file ]; then
|
||||
logger "File default_core_pattern doesn't exist under /var/log/crashlog"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# We know the parameter order
|
||||
my_order=(%E %P %u %g %s %t %c %h %e %p %i %I %d)
|
||||
my_params=($*)
|
||||
|
||||
# An O(n^2) function to look up the value
|
||||
function get_params()
|
||||
{
|
||||
local ret=""
|
||||
for args in $*
|
||||
do
|
||||
for index in ${!my_order[@]}
|
||||
do
|
||||
if [ ${my_order[${index}]} = ${args} ]
|
||||
then
|
||||
ret="${ret} ${my_params[${index}]}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo ${ret}
|
||||
}
|
||||
|
||||
# get default core_pattern parameters list
|
||||
default_content=`cat $default_core_pattern_file`
|
||||
default_params=${default_content#* }
|
||||
|
||||
# abstract the application of the default core_pattern
|
||||
t_app=${default_content%% *}
|
||||
default_app=${t_app#*|}
|
||||
|
||||
usercrash_var=$(get_params "%p %e %s")
|
||||
default_var=$(get_params ${default_params})
|
||||
|
||||
tee >(/usr/bin/usercrash_c ${usercrash_var}) | ${default_app} ${default_var}
|
12
misc/tools/acrn-crashlog/data/usercrash.service
Normal file
12
misc/tools/acrn-crashlog/data/usercrash.service
Normal file
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=ACRN usercrash Demon
|
||||
Requires=telemd.socket
|
||||
After=telemd.service
|
||||
Before=acrnprobe.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/usercrash_s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Reference in New Issue
Block a user