Skip to content

Commit a9e36bd

Browse files
chengangclijinxia
authored andcommitted
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>
1 parent df6019a commit a9e36bd

File tree

8 files changed

+155
-8
lines changed

8 files changed

+155
-8
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ tools:
2626
make -C $(T)/tools/acrnlog OUT_DIR=$(TOOLS_OUT)
2727
make -C $(T)/tools/acrn-manager OUT_DIR=$(TOOLS_OUT)
2828
make -C $(T)/tools/acrntrace OUT_DIR=$(TOOLS_OUT)
29+
make -C $(T)/tools/acrn-crashlog OUT_DIR=$(TOOLS_OUT) RELEASE=$(RELEASE)
2930

3031
.PHONY: clean
3132
clean:
3233
rm -rf $(ROOT_OUT)
33-
34+
3435
.PHONY: install
3536
install: hypervisor-install devicemodel-install tools-install
3637

@@ -44,4 +45,4 @@ tools-install:
4445
make -C $(T)/tools/acrnlog OUT_DIR=$(TOOLS_OUT) install
4546
make -C $(T)/tools/acrn-manager OUT_DIR=$(TOOLS_OUT) install
4647
make -C $(T)/tools/acrntrace OUT_DIR=$(TOOLS_OUT) install
47-
48+
make -C $(T)/tools/acrn-crashlog OUT_DIR=$(TOOLS_OUT) install

tools/acrn-crashlog/Makefile

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,27 @@ OUT_DIR ?= $(BASEDIR)
77
BUILDDIR := $(OUT_DIR)/acrn-crashlog
88
CC := gcc
99
RM = rm
10+
RELEASE ?= 0
1011

1112
CFLAGS := -Wall -Wextra -pedantic
12-
CFLAGS += -m64 -D_GNU_SOURCE -DDEBUG_ACRN_CRASHLOG
13+
CFLAGS += -m64 -D_GNU_SOURCE
14+
ifeq ($(RELEASE),0)
15+
CFLAGS += -DDEBUG_ACRN_CRASHLOG
16+
endif
1317
INCLUDE := -I $(BASEDIR)/common/include
1418
export INCLUDE
1519
export BUILDDIR
20+
export CC
21+
export RM
22+
export CFLAGS
23+
24+
SYSTEMD_LIBS = -lsystemd
25+
LDCNF := $(shell ldconfig -p)
26+
LIB_EXIST = $(findstring libsystemd-journal.so, $(LDCNF))
27+
ifeq ($(strip $(LIB_EXIST)),libsystemd-journal.so)
28+
SYSTEMD_LIBS = -lsystemd-journal
29+
endif
30+
export SYSTEMD_LIBS
1631

1732
.PHONY:all
1833
all:
@@ -28,3 +43,53 @@ clean:
2843
@if [ -d "$(BUILDDIR)" ]; then \
2944
$(RM) -rf $(BUILDDIR); \
3045
fi
46+
47+
.PHONY:install
48+
install:
49+
@install -d $(DESTDIR)/usr/bin/
50+
@install -p -D -m 0755 $(BUILDDIR)/acrnprobe/bin/acrnprobe $(DESTDIR)/usr/bin/
51+
@install -p -D -m 0755 $(BUILDDIR)/usercrash/bin/debugger $(DESTDIR)/usr/bin/
52+
@install -p -D -m 0755 $(BUILDDIR)/usercrash/bin/usercrash_c $(DESTDIR)/usr/bin/
53+
@install -p -D -m 0755 $(BUILDDIR)/usercrash/bin/usercrash_s $(DESTDIR)/usr/bin/
54+
@install -p -D -m 0755 data/acrnprobe_prepare.sh $(DESTDIR)/usr/bin/
55+
@install -d $(DESTDIR)/usr/lib/systemd/system.conf.d/
56+
@install -p -D -m 0644 data/40-watchdog.conf $(DESTDIR)/usr/lib/systemd/system.conf.d/
57+
@install -d $(DESTDIR)/usr/share/defaults/telemetrics/
58+
@install -p -D -m 0644 data/acrnprobe.xml $(DESTDIR)/usr/share/defaults/telemetrics/
59+
@install -d $(DESTDIR)/usr/lib/systemd/system/
60+
@install -p -D -m 0644 data/acrnprobe.service $(DESTDIR)/usr/lib/systemd/system/
61+
@install -p -D -m 0644 data/prepare.service $(DESTDIR)/usr/lib/systemd/system/
62+
@install -p -D -m 0644 data/usercrash.service $(DESTDIR)/usr/lib/systemd/system/
63+
64+
.PHONY:uninstall
65+
uninstall:
66+
@if [ -e "$(DESTDIR)/usr/bin/acrnprobe" ];then \
67+
$(RM) $(DESTDIR)/usr/bin/acrnprobe; \
68+
fi
69+
@if [ -e "$(DESTDIR)/usr/bin/acrnprobe_prepare.sh" ];then \
70+
$(RM) $(DESTDIR)/usr/bin/acrnprobe_prepare.sh; \
71+
fi
72+
@if [ -e "$(DESTDIR)/usr/bin/debugger" ];then \
73+
$(RM) $(DESTDIR)/usr/bin/debugger; \
74+
fi
75+
@if [ -e "$(DESTDIR)/usr/bin/usercrash_c" ];then \
76+
$(RM) $(DESTDIR)/usr/bin/usercrash_c; \
77+
fi
78+
@if [ -e "$(DESTDIR)/usr/bin/usercrash_s" ];then \
79+
$(RM) $(DESTDIR)/usr/bin/usercrash_s; \
80+
fi
81+
@if [ -e "$(DESTDIR)/usr/lib/systemd/system.conf.d/40-watchdog.conf" ];then \
82+
$(RM) $(DESTDIR)/usr/lib/systemd/system.conf.d/40-watchdog.conf; \
83+
fi
84+
@if [ -e "$(DESTDIR)/usr/share/defaults/telemetrics/acrnprobe.xml" ];then \
85+
$(RM) $(DESTDIR)/usr/share/defaults/telemetrics/acrnprobe.xml; \
86+
fi
87+
@if [ -e "$(DESTDIR)/usr/lib/systemd/system/acrnprobe.service" ];then \
88+
$(RM) $(DESTDIR)/usr/lib/systemd/system/acrnprobe.service; \
89+
fi
90+
@if [ -e "$(DESTDIR)/usr/lib/systemd/system/prepare.service" ];then \
91+
$(RM) $(DESTDIR)/usr/lib/systemd/system/prepare.service; \
92+
fi
93+
@if [ -e "$(DESTDIR)/usr/lib/systemd/system/usercrash.service" ];then \
94+
$(RM) $(DESTDIR)/usr/lib/systemd/system/usercrash.service; \
95+
fi

tools/acrn-crashlog/acrnprobe/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MINOR_VERSION=0
33

44
BASEDIR := $(shell pwd)
55

6-
LIBS = -lpthread -lxml2 -lcrypto -lrt -lsystemd -ltelemetry
6+
LIBS = -lpthread -lxml2 -lcrypto -lrt $(SYSTEMD_LIBS) -ltelemetry
77
INCLUDE += -I $(BASEDIR)/include -I /usr/include/libxml2
88
CFLAGS += $(INCLUDE)
99
CFLAGS += -g -O0 -std=gnu11
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=ACRN crashlog probe
3+
Requires=telemd.socket
4+
Requires=usercrash_s
5+
After=usercrash.service
6+
After=prepare.service
7+
8+
[Service]
9+
Type=simple
10+
ExecStart=/usr/bin/acrnprobe
11+
ExecStop=/usr/bin/killall -s TERM acrnprobe
12+
13+
[Install]
14+
WantedBy=multi-user.target
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (C) <2018> Intel Corporation
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
7+
# modify the core_pattern
8+
echo "|/usr/bin/usercrash_c %p %e %s" > /proc/sys/kernel/core_pattern
9+
10+
conf="/usr/share/defaults/telemetrics/telemetrics.conf"
11+
12+
grep -q "record_server_delivery_enabled=false" $conf
13+
if [ "$?" -eq "0" ];then
14+
exit;
15+
fi
16+
17+
telemd_services=(
18+
hprobe.timer
19+
telemd-update-trigger.service
20+
pstore-clean.service
21+
pstore-probe.service
22+
oops-probe.service
23+
klogscanner.service
24+
journal-probe.service
25+
bert-probe.service
26+
)
27+
28+
for ((i=0;i<${#telemd_services[*]};i++))
29+
do
30+
if [ ! -L "/etc/systemd/system/${telemd_services[$i]}" ];then
31+
systemctl mask ${telemd_services[$i]} --now
32+
fi
33+
done
34+
35+
# modify the configure file
36+
37+
sed -i "s/server_delivery_enabled=true/server_delivery_enabled=false/g" $conf
38+
sed -i "s/record_retention_enabled=false/record_retention_enabled=true/g" $conf
39+
40+
# restart telemd
41+
sleep 3
42+
systemctl restart telemd.service
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=ACRN probe prepare
3+
Requires=telemd.service
4+
After=telemd.service
5+
Before=acrnprobe.service
6+
7+
[Service]
8+
Type=oneshot
9+
ExecStart=/bin/sh /usr/bin/acrnprobe_prepare.sh
10+
11+
[Install]
12+
WantedBy=multi-user.target
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=ACRN usercrash Demon
3+
Requires=telemd.socket
4+
After=telemd.service
5+
Before=acrnprobe.service
6+
7+
[Service]
8+
Type=simple
9+
ExecStart=/usr/bin/usercrash_s
10+
ExecStop=/usr/bin/killall -s TERM usercrash_s
11+
12+
[Install]
13+
WantedBy=multi-user.target

tools/acrn-crashlog/usercrash/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ all: include/version.h check_obj usercrash_s usercrash_c debugger
66
CURRDIR := $(shell pwd)
77
INCLUDE += -I $(CURRDIR)/include/
88

9-
LIBS = -levent -lpthread
9+
LIBS = -levent -lpthread $(SYSTEMD_LIBS)
1010

1111
usercrash_s: $(BUILDDIR)/usercrash/obj/protocol.o \
1212
$(BUILDDIR)/usercrash/obj/server.o \
1313
$(BUILDDIR)/common/obj/log_sys.o
14-
$(CC) -g $(CFLAGS) $(LIBS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ -lsystemd
14+
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ $(LIBS)
1515

1616
usercrash_c: $(BUILDDIR)/usercrash/obj/protocol.o \
1717
$(BUILDDIR)/usercrash/obj/client.o \
@@ -20,15 +20,15 @@ usercrash_c: $(BUILDDIR)/usercrash/obj/protocol.o \
2020
$(BUILDDIR)/common/obj/cmdutils.o \
2121
$(BUILDDIR)/common/obj/fsutils.o \
2222
$(BUILDDIR)/common/obj/strutils.o
23-
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ -lsystemd
23+
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ $(LIBS)
2424

2525
debugger: $(BUILDDIR)/usercrash/obj/debugger.o \
2626
$(BUILDDIR)/usercrash/obj/crash_dump.o \
2727
$(BUILDDIR)/common/obj/log_sys.o \
2828
$(BUILDDIR)/common/obj/cmdutils.o \
2929
$(BUILDDIR)/common/obj/fsutils.o \
3030
$(BUILDDIR)/common/obj/strutils.o
31-
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ -lsystemd
31+
$(CC) -g $(CFLAGS) $(INCLUDE) $^ -o $(BUILDDIR)/usercrash/bin/$@ $(LIBS)
3232

3333
$(BUILDDIR)/usercrash/obj/%.o:%.c
3434
$(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<

0 commit comments

Comments
 (0)