From 156ea70821bc5ae04bf57c1dd99aae68f53ac223 Mon Sep 17 00:00:00 2001 From: "Liu, Xinwu" Date: Mon, 7 Jan 2019 16:04:09 +0800 Subject: [PATCH] tools: acrn-crashlog: Reboot system to cold after collecting reserve log After panic, kernel will do warm boot to reserve memory for log collecting. Need to cold reboot system as the original behaviour. Tracked-On:#1024 Signed-off-by: Liu, Xinwu Acked-by: Chen, Gang --- tools/acrn-crashlog/acrnprobe/channels.c | 8 ++++---- tools/acrn-crashlog/acrnprobe/event_handler.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/acrn-crashlog/acrnprobe/channels.c b/tools/acrn-crashlog/acrnprobe/channels.c index 8b6d48858..98dc79571 100644 --- a/tools/acrn-crashlog/acrnprobe/channels.c +++ b/tools/acrn-crashlog/acrnprobe/channels.c @@ -111,10 +111,6 @@ static void channel_oneshot(struct channel_t *cnl) if (!is_boot_id_changed()) return; - e = create_event(REBOOT, cname, NULL, 0, NULL, 0); - if (e) - event_enqueue(e); - for_each_crash(id, crash, conf) { if (!crash || !is_root_crash(crash)) continue; @@ -147,6 +143,10 @@ static void channel_oneshot(struct channel_t *cnl) } } + e = create_event(REBOOT, cname, NULL, 0, NULL, 0); + if (e) + event_enqueue(e); + for_each_info(id, info, conf) { if (!info) continue; diff --git a/tools/acrn-crashlog/acrnprobe/event_handler.c b/tools/acrn-crashlog/acrnprobe/event_handler.c index 4aa9d54da..2c21eb5db 100644 --- a/tools/acrn-crashlog/acrnprobe/event_handler.c +++ b/tools/acrn-crashlog/acrnprobe/event_handler.c @@ -13,8 +13,10 @@ #include "load_conf.h" #include "channels.h" #include "fsutils.h" +#include "cmdutils.h" #include "log_sys.h" #include "event_handler.h" +#include "startupreason.h" /* Watchdog timeout in second*/ #define WDT_TIMEOUT 300 @@ -196,14 +198,25 @@ static void *event_handle(void *unused __attribute__((unused))) sender->send(e); } + if (e->event_type == REBOOT) { + char reason[REBOOT_REASON_SIZE]; + + read_startupreason(reason, sizeof(reason)); + if (!strcmp(reason, "WARM") || + !strcmp(reason, "WATCHDOG")) + if (exec_out2file(NULL, "reboot") == -1) + break; + } + if ((e->dir)) free(e->dir); free(e); event_processing = 0; free(last_e); + } - LOGE("something goes error, %s exit\n", __func__); + LOGE("failed to reboot system, %s exit\n", __func__); return NULL; }