From 3b2c7056e82ff584ae5195e3badbfe9814a50642 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 21 Jul 2018 05:03:46 +0200 Subject: qemu: show log if process crashes Signed-off-by: Jason A. Donenfeld --- src/tests/qemu/init.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c index 8d783e9..7db1d4b 100644 --- a/src/tests/qemu/init.c +++ b/src/tests/qemu/init.c @@ -111,17 +111,23 @@ static void enable_logging(void) int fd; pretty_message("[+] Enabling logging..."); fd = open("/proc/sys/kernel/printk", O_WRONLY); - if (fd < 0) - panic("open(printk)"); - if (write(fd, "9\n", 2) != 2) - panic("write(printk)"); - close(fd); + if (fd >= 0) { + if (write(fd, "9\n", 2) != 2) + panic("write(printk)"); + close(fd); + } + fd = open("/proc/sys/debug/exception-trace", O_WRONLY); + if (fd >= 0) { + if (write(fd, "1\n", 2) != 2) + panic("write(exception-trace)"); + close(fd); + } fd = open("/proc/sys/kernel/panic_on_warn", O_WRONLY); - if (fd < 0) - return; /* < 3.18 doesn't have it */ - if (write(fd, "1\n", 2) != 2) - panic("write(panic_on_warn)"); - close(fd); + if (fd >= 0) { + if (write(fd, "1\n", 2) != 2) + panic("write(panic_on_warn)"); + close(fd); + } } static void kmod_selftests(void) -- cgit v1.2.3