tools:acrn-crashlog: Detect and classify the crash in ACRN and kernel

Since ACRN has the capability to reboot and reboot reason is available
in SOS, acrnprobe could detect the crash of acrn and SOS kernel.

List of added crash types:

1. ACRNCRASH            - crashed in hypervisor, this detection depends on
                          files in /tmp/acrnlog_last(provided by acrnlog).
2. IPANIC               - crashed in SOS kernel, this detection depends on
                          pstore.
3. SWWDT_IPANIC         - crashed in SOS kernel and reboot reason is wdt.
4. HWWDT_UNHANDLE       - only recognize reboot reason is global, there is no
                          further clues that it's a SOS kernel crash or a
                          hypervisor crash.
5. SWWDT_UNHANDLE       - only recognize reboot reason is wdt, there is no
                          further clues that it's a SOS kernel crash or a
                          hypervisor crash.
6. UNKNOWN              - only recognize reboot reason is warm, there is no
                          further clues that it's a SOS kernel crash or a
                          hypervisor crash.

Signed-off-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: Chen Gang <gang.c.chen@intel.com>
This commit is contained in:
Liu, Xinwu
2018-07-03 10:51:45 +08:00
committed by Jack Ren
parent a5853d6d8a
commit b30ba3db15
5 changed files with 138 additions and 33 deletions

View File

@@ -38,14 +38,21 @@
#define STATS_CURRENT_LOG "currentstatslog"
#define VM_CURRENT_LOG "currentvmlog"
#define BOOTID_NODE "/proc/sys/kernel/random/boot_id"
#define BOOTID_LOG "currentbootid"
unsigned long long get_uptime(void)
{
static long long time_ns = -1;
struct timespec ts;
long long time_ns;
struct timespec ts;
int res;
clock_gettime(CLOCK_BOOTTIME, &ts);
time_ns = (long long)ts.tv_sec * 1000000000LL +
(long long)ts.tv_nsec;
res = clock_gettime(CLOCK_BOOTTIME, &ts);
if (res == -1)
return res;
time_ns = (long long)ts.tv_sec * 1000000000LL +
(long long)ts.tv_nsec;
return time_ns;
}
@@ -56,6 +63,8 @@ int get_uptime_string(char *newuptime, int *hours)
int seconds, minutes;
tm = get_uptime();
if (tm == -1)
return -1;
/* seconds */
*hours = (int)(tm / 1000000000LL);
@@ -444,3 +453,41 @@ char *generate_log_dir(enum e_dir_mode mode, char *hashkey)
return strdup(path);
}
int is_boot_id_changed(void)
{
void *boot_id;
void *logged_boot_id;
char logged_boot_id_path[PATH_MAX];
unsigned long size;
struct sender_t *crashlog;
int res;
int result = 1; /* returns changed by default */
crashlog = get_sender_by_name("crashlog");
if (!crashlog)
return result;
res = read_file(BOOTID_NODE, &size, &boot_id);
if (res == -1)
return result;
snprintf(logged_boot_id_path, sizeof(logged_boot_id_path), "%s/%s",
crashlog->outdir, BOOTID_LOG);
if (file_exists(logged_boot_id_path)) {
res = read_file(logged_boot_id_path, &size, &logged_boot_id);
if (res == -1)
goto out;
if (!strcmp((char *)logged_boot_id, (char *)boot_id))
result = 0;
free(logged_boot_id);
}
if (result)
overwrite_file(logged_boot_id_path, boot_id);
out:
free(boot_id);
return result;
}