Skip to content

Commit 1b3e900

Browse files
authored
Merge pull request #1477 from m-1-k-3/s115_#1476
S115 #1476
2 parents 732574a + a1de354 commit 1b3e900

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

helpers/helpers_emba_defaults.sh

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ set_defaults() {
7373
export L10_DEBUG_MODE=0
7474
export FULL_EMULATION=0 # full system emulation - set it via command line parameter -Q
7575
export QEMULATION=0 # user-mode emulation - set it via command line parameter -E
76+
# some processes are running long and logging a lot
77+
# to protect the host we are going to kill them on a QEMU_KILL_SIZE limit
78+
export QEMU_KILL_SIZE="10M"
7679
# export L10_KERNEL_V_LONG="4.1.17"
7780
export L10_KERNEL_V_LONG="4.1.52"
7881
export L10_BB_VER="1.36.1"

modules/S115_usermode_emulator.sh

+10-11
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ S115_usermode_emulator() {
6262
# ensure that the emulator does not reconfigure the interface
6363
get_local_ip
6464

65-
# some processes are running long and logging a lot
66-
# to protect the host we are going to kill them on a KILL_SIZE limit
67-
export KILL_SIZE="50M"
68-
6965
# load blacklist of binaries that could cause troubles during emulation:
7066
readarray -t lBIN_BLACKLIST_ARR < "${CONFIG_DIR}"/emulation_blacklist.cfg
7167

@@ -720,14 +716,17 @@ emulate_binary() {
720716
check_disk_space_emu() {
721717
local lEMULATOR="${1:-}"
722718
local lCRITICAL_FILES_ARR=()
723-
local lKILLER=""
724-
725-
mapfile -t lCRITICAL_FILES_ARR < <(find "${LOG_PATH_MODULE}"/ -xdev -type f -size +"${KILL_SIZE}" -print0 2>/dev/null |xargs -r -0 -P 16 -I % sh -c 'basename % 2>/dev/null| cut -d\. -f1 | cut -d_ -f2' || true)
726-
for lKILLER in "${lCRITICAL_FILES_ARR[@]}"; do
727-
if pgrep -f "${lEMULATOR}.*${lKILLER}" > /dev/null; then
719+
local lKILL_PROC_NAME=""
720+
721+
mapfile -t lCRITICAL_FILES_ARR < <(find "${LOG_PATH_MODULE}"/ -xdev -maxdepth 1 -type f -size +"${QEMU_KILL_SIZE}" -print0 2>/dev/null |xargs -r -0 -P 16 -I % sh -c 'basename -s .txt % 2>/dev/null' || true)
722+
for lKILL_PROC_NAME in "${lCRITICAL_FILES_ARR[@]}"; do
723+
lKILL_PROC_NAME="${lKILL_PROC_NAME/qemu_tmp_}"
724+
lKILL_PROC_NAME="${lKILL_PROC_NAME/qemu_initx_}"
725+
lKILL_PROC_NAME="${lKILL_PROC_NAME/stracer_}"
726+
if pgrep -f "${lEMULATOR}.*${lKILL_PROC_NAME}" > /dev/null; then
728727
print_output "[!] Qemu processes are wasting disk space ... we try to kill it" "no_log"
729-
print_output "[*] Killing process ${ORANGE}${lEMULATOR}.*${lKILLER}.*${NC}" "no_log"
730-
pkill -f "${lEMULATOR}.*${lKILLER}.*" >/dev/null|| true
728+
print_output "[*] Killing process ${ORANGE}${lEMULATOR}.*${lKILL_PROC_NAME}.*${NC}" "no_log"
729+
pkill -f "${lEMULATOR}.*${lKILL_PROC_NAME}.*" >/dev/null|| true
731730
# rm "${LOG_DIR}"/qemu_emulator/*"${lKILLER}"*
732731
fi
733732
done

0 commit comments

Comments
 (0)