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:
CHEN Gang 2018-05-18 16:38:19 +08:00 committed by lijinxia
parent df6019aa26
commit a9e36bdb4e
8 changed files with 155 additions and 8 deletions

View File

@ -26,6 +26,7 @@ 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:
@ -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

View File

@ -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

View File

@ -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

View 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

View 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

View 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

View 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

View File

@ -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 $<