mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 20:53:46 +00:00
tools: acrn-crashlog: add service/config files and scripts
This patch adds the service files, config files and script to run automatically at boot. And it adds install/uninstall part in Makefile. Compatiblity code for libsystemd.so and libsystemd-journal.so is added in Makefile also. Signed-off-by: Jin Zhi <zhi.jin@intel.com> Signed-off-by: CHEN Gang <gang.c.chen@intel.com> Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com> Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com> Acked-by: Eddie Dong <Eddie.dong@intel.com>
This commit is contained in:
parent
df6019aa26
commit
a9e36bdb4e
5
Makefile
5
Makefile
@ -26,11 +26,12 @@ tools:
|
||||
make -C $(T)/tools/acrnlog OUT_DIR=$(TOOLS_OUT)
|
||||
make -C $(T)/tools/acrn-manager OUT_DIR=$(TOOLS_OUT)
|
||||
make -C $(T)/tools/acrntrace OUT_DIR=$(TOOLS_OUT)
|
||||
make -C $(T)/tools/acrn-crashlog OUT_DIR=$(TOOLS_OUT) RELEASE=$(RELEASE)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(ROOT_OUT)
|
||||
|
||||
|
||||
.PHONY: install
|
||||
install: hypervisor-install devicemodel-install tools-install
|
||||
|
||||
@ -44,4 +45,4 @@ tools-install:
|
||||
make -C $(T)/tools/acrnlog OUT_DIR=$(TOOLS_OUT) install
|
||||
make -C $(T)/tools/acrn-manager OUT_DIR=$(TOOLS_OUT) install
|
||||
make -C $(T)/tools/acrntrace OUT_DIR=$(TOOLS_OUT) install
|
||||
|
||||
make -C $(T)/tools/acrn-crashlog OUT_DIR=$(TOOLS_OUT) install
|
||||
|
@ -7,12 +7,27 @@ OUT_DIR ?= $(BASEDIR)
|
||||
BUILDDIR := $(OUT_DIR)/acrn-crashlog
|
||||
CC := gcc
|
||||
RM = rm
|
||||
RELEASE ?= 0
|
||||
|
||||
CFLAGS := -Wall -Wextra -pedantic
|
||||
CFLAGS += -m64 -D_GNU_SOURCE -DDEBUG_ACRN_CRASHLOG
|
||||
CFLAGS += -m64 -D_GNU_SOURCE
|
||||
ifeq ($(RELEASE),0)
|
||||
CFLAGS += -DDEBUG_ACRN_CRASHLOG
|
||||
endif
|
||||
INCLUDE := -I $(BASEDIR)/common/include
|
||||
export INCLUDE
|
||||
export BUILDDIR
|
||||
export CC
|
||||
export RM
|
||||
export CFLAGS
|
||||
|
||||
SYSTEMD_LIBS = -lsystemd
|
||||
LDCNF := $(shell ldconfig -p)
|
||||
LIB_EXIST = $(findstring libsystemd-journal.so, $(LDCNF))
|
||||
ifeq ($(strip $(LIB_EXIST)),libsystemd-journal.so)
|
||||
SYSTEMD_LIBS = -lsystemd-journal
|
||||
endif
|
||||
export SYSTEMD_LIBS
|
||||
|
||||
.PHONY:all
|
||||
all:
|
||||
@ -28,3 +43,53 @@ clean:
|
||||
@if [ -d "$(BUILDDIR)" ]; then \
|
||||
$(RM) -rf $(BUILDDIR); \
|
||||
fi
|
||||
|
||||
.PHONY:install
|
||||
install:
|
||||
@install -d $(DESTDIR)/usr/bin/
|
||||
@install -p -D -m 0755 $(BUILDDIR)/acrnprobe/bin/acrnprobe $(DESTDIR)/usr/bin/
|
||||
@install -p -D -m 0755 $(BUILDDIR)/usercrash/bin/debugger $(DESTDIR)/usr/bin/
|
||||
@install -p -D -m 0755 $(BUILDDIR)/usercrash/bin/usercrash_c $(DESTDIR)/usr/bin/
|
||||
@install -p -D -m 0755 $(BUILDDIR)/usercrash/bin/usercrash_s $(DESTDIR)/usr/bin/
|
||||
@install -p -D -m 0755 data/acrnprobe_prepare.sh $(DESTDIR)/usr/bin/
|
||||
@install -d $(DESTDIR)/usr/lib/systemd/system.conf.d/
|
||||
@install -p -D -m 0644 data/40-watchdog.conf $(DESTDIR)/usr/lib/systemd/system.conf.d/
|
||||
@install -d $(DESTDIR)/usr/share/defaults/telemetrics/
|
||||
@install -p -D -m 0644 data/acrnprobe.xml $(DESTDIR)/usr/share/defaults/telemetrics/
|
||||
@install -d $(DESTDIR)/usr/lib/systemd/system/
|
||||
@install -p -D -m 0644 data/acrnprobe.service $(DESTDIR)/usr/lib/systemd/system/
|
||||
@install -p -D -m 0644 data/prepare.service $(DESTDIR)/usr/lib/systemd/system/
|
||||
@install -p -D -m 0644 data/usercrash.service $(DESTDIR)/usr/lib/systemd/system/
|
||||
|
||||
.PHONY:uninstall
|
||||
uninstall:
|
||||
@if [ -e "$(DESTDIR)/usr/bin/acrnprobe" ];then \
|
||||
$(RM) $(DESTDIR)/usr/bin/acrnprobe; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/bin/acrnprobe_prepare.sh" ];then \
|
||||
$(RM) $(DESTDIR)/usr/bin/acrnprobe_prepare.sh; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/bin/debugger" ];then \
|
||||
$(RM) $(DESTDIR)/usr/bin/debugger; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/bin/usercrash_c" ];then \
|
||||
$(RM) $(DESTDIR)/usr/bin/usercrash_c; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/bin/usercrash_s" ];then \
|
||||
$(RM) $(DESTDIR)/usr/bin/usercrash_s; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/lib/systemd/system.conf.d/40-watchdog.conf" ];then \
|
||||
$(RM) $(DESTDIR)/usr/lib/systemd/system.conf.d/40-watchdog.conf; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/share/defaults/telemetrics/acrnprobe.xml" ];then \
|
||||
$(RM) $(DESTDIR)/usr/share/defaults/telemetrics/acrnprobe.xml; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/lib/systemd/system/acrnprobe.service" ];then \
|
||||
$(RM) $(DESTDIR)/usr/lib/systemd/system/acrnprobe.service; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/lib/systemd/system/prepare.service" ];then \
|
||||
$(RM) $(DESTDIR)/usr/lib/systemd/system/prepare.service; \
|
||||
fi
|
||||
@if [ -e "$(DESTDIR)/usr/lib/systemd/system/usercrash.service" ];then \
|
||||
$(RM) $(DESTDIR)/usr/lib/systemd/system/usercrash.service; \
|
||||
fi
|
||||
|
@ -3,7 +3,7 @@ MINOR_VERSION=0
|
||||
|
||||
BASEDIR := $(shell pwd)
|
||||
|
||||
LIBS = -lpthread -lxml2 -lcrypto -lrt -lsystemd -ltelemetry
|
||||
LIBS = -lpthread -lxml2 -lcrypto -lrt $(SYSTEMD_LIBS) -ltelemetry
|
||||
INCLUDE += -I $(BASEDIR)/include -I /usr/include/libxml2
|
||||
CFLAGS += $(INCLUDE)
|
||||
CFLAGS += -g -O0 -std=gnu11
|
||||
|
14
tools/acrn-crashlog/data/acrnprobe.service
Normal file
14
tools/acrn-crashlog/data/acrnprobe.service
Normal file
@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=ACRN crashlog probe
|
||||
Requires=telemd.socket
|
||||
Requires=usercrash_s
|
||||
After=usercrash.service
|
||||
After=prepare.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/acrnprobe
|
||||
ExecStop=/usr/bin/killall -s TERM acrnprobe
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
42
tools/acrn-crashlog/data/acrnprobe_prepare.sh
Executable file
42
tools/acrn-crashlog/data/acrnprobe_prepare.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) <2018> Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
# modify the core_pattern
|
||||
echo "|/usr/bin/usercrash_c %p %e %s" > /proc/sys/kernel/core_pattern
|
||||
|
||||
conf="/usr/share/defaults/telemetrics/telemetrics.conf"
|
||||
|
||||
grep -q "record_server_delivery_enabled=false" $conf
|
||||
if [ "$?" -eq "0" ];then
|
||||
exit;
|
||||
fi
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
for ((i=0;i<${#telemd_services[*]};i++))
|
||||
do
|
||||
if [ ! -L "/etc/systemd/system/${telemd_services[$i]}" ];then
|
||||
systemctl mask ${telemd_services[$i]} --now
|
||||
fi
|
||||
done
|
||||
|
||||
# modify the configure file
|
||||
|
||||
sed -i "s/server_delivery_enabled=true/server_delivery_enabled=false/g" $conf
|
||||
sed -i "s/record_retention_enabled=false/record_retention_enabled=true/g" $conf
|
||||
|
||||
# restart telemd
|
||||
sleep 3
|
||||
systemctl restart telemd.service
|
12
tools/acrn-crashlog/data/prepare.service
Normal file
12
tools/acrn-crashlog/data/prepare.service
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=ACRN probe prepare
|
||||
Requires=telemd.service
|
||||
After=telemd.service
|
||||
Before=acrnprobe.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/sh /usr/bin/acrnprobe_prepare.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
13
tools/acrn-crashlog/data/usercrash.service
Normal file
13
tools/acrn-crashlog/data/usercrash.service
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=ACRN usercrash Demon
|
||||
Requires=telemd.socket
|
||||
After=telemd.service
|
||||
Before=acrnprobe.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/usercrash_s
|
||||
ExecStop=/usr/bin/killall -s TERM usercrash_s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -6,12 +6,12 @@ all: include/version.h check_obj usercrash_s usercrash_c debugger
|
||||
CURRDIR := $(shell pwd)
|
||||
INCLUDE += -I $(CURRDIR)/include/
|
||||
|
||||
LIBS = -levent -lpthread
|
||||
LIBS = -levent -lpthread $(SYSTEMD_LIBS)
|
||||
|
||||
usercrash_s: $(BUILDDIR)/usercrash/obj/protocol.o \
|
||||
$(BUILDDIR)/usercrash/obj/server.o \
|
||||
$(BUILDDIR)/common/obj/log_sys.o
|
||||
$(CC) -g $(CFLAGS) $(LIBS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ -lsystemd
|
||||
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ $(LIBS)
|
||||
|
||||
usercrash_c: $(BUILDDIR)/usercrash/obj/protocol.o \
|
||||
$(BUILDDIR)/usercrash/obj/client.o \
|
||||
@ -20,7 +20,7 @@ usercrash_c: $(BUILDDIR)/usercrash/obj/protocol.o \
|
||||
$(BUILDDIR)/common/obj/cmdutils.o \
|
||||
$(BUILDDIR)/common/obj/fsutils.o \
|
||||
$(BUILDDIR)/common/obj/strutils.o
|
||||
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ -lsystemd
|
||||
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ $(LIBS)
|
||||
|
||||
debugger: $(BUILDDIR)/usercrash/obj/debugger.o \
|
||||
$(BUILDDIR)/usercrash/obj/crash_dump.o \
|
||||
@ -28,7 +28,7 @@ debugger: $(BUILDDIR)/usercrash/obj/debugger.o \
|
||||
$(BUILDDIR)/common/obj/cmdutils.o \
|
||||
$(BUILDDIR)/common/obj/fsutils.o \
|
||||
$(BUILDDIR)/common/obj/strutils.o
|
||||
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ -lsystemd
|
||||
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ $(LIBS)
|
||||
|
||||
$(BUILDDIR)/usercrash/obj/%.o:%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
|
||||
|
Loading…
Reference in New Issue
Block a user