aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-02 02:11:52 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-02 02:45:53 +0200
commitdbd1fe39f92e9b8f2ba2c6cf34c6850c4d2ea4b2 (patch)
tree4293fbdbbbf3b963c4e966756feb95af5beb5104
parentmessages: reduce maximum staged packets per peer (diff)
downloadwireguard-monolithic-historical-dbd1fe39f92e9b8f2ba2c6cf34c6850c4d2ea4b2.tar.xz
wireguard-monolithic-historical-dbd1fe39f92e9b8f2ba2c6cf34c6850c4d2ea4b2.zip
qemu: add watchdog for not hanging on oops
-rw-r--r--src/tests/qemu/Makefile1
-rw-r--r--src/tests/qemu/init.c23
-rw-r--r--src/tests/qemu/kernel.config1
3 files changed, 24 insertions, 1 deletions
diff --git a/src/tests/qemu/Makefile b/src/tests/qemu/Makefile
index 225bb1c..24952bd 100644
--- a/src/tests/qemu/Makefile
+++ b/src/tests/qemu/Makefile
@@ -81,6 +81,7 @@ qemu: $(KERNEL_BZIMAGE)
-device virtconsole,chardev=stdio \
-chardev file,id=status,path=$(BUILD_PATH)/result \
-device virtserialport,chardev=status \
+ -watchdog ib700 -watchdog-action poweroff \
-monitor none \
-kernel $< \
-append "console=hvc0"
diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c
index ea578c1..130fd0e 100644
--- a/src/tests/qemu/init.c
+++ b/src/tests/qemu/init.c
@@ -20,7 +20,7 @@
#include <linux/random.h>
#include <linux/version.h>
- __attribute__((noreturn)) static void poweroff(void)
+__attribute__((noreturn)) static void poweroff(void)
{
fflush(stdout);
fflush(stderr);
@@ -112,6 +112,26 @@ static void enable_logging(void)
close(fd);
}
+static void watchdog(void)
+{
+ pretty_message("[+] Enabling watchdog timer...");
+
+ ioperm(0x443, 1, 1);
+ outb(14, 0x443);
+
+ if (fork())
+ return;
+
+ setpriority(PRIO_PROCESS, 0, -20);
+
+ for (;;) {
+ outb(14, 0x443);
+ sleep(1);
+ }
+
+ _exit(0);
+}
+
static void kmod_selftests(void)
{
FILE *file;
@@ -191,6 +211,7 @@ int main(int argc, char *argv[])
if (uname(&utsname) < 0)
panic("uname");
print_banner(&utsname);
+ watchdog();
mount_filesystems();
kmod_selftests();
if (!linux_4_8_or_higher(&utsname))
diff --git a/src/tests/qemu/kernel.config b/src/tests/qemu/kernel.config
index e6016d0..10de485 100644
--- a/src/tests/qemu/kernel.config
+++ b/src/tests/qemu/kernel.config
@@ -70,5 +70,6 @@ CONFIG_PRINTK_TIME=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_LEGACY_VSYSCALL_NONE=y
CONFIG_KERNEL_GZIP=y
+CONFIG_PANIC_ON_OOPS=y
CONFIG_WIREGUARD=y
CONFIG_WIREGUARD_DEBUG=y