Subject: [patch] uml core on panic From: Gerd Knorr allow the uml kernel throw cores for crash analysis later on. Index: linux-2.6.11/arch/um/kernel/Makefile =================================================================== --- linux-2.6.11.orig/arch/um/kernel/Makefile 2005-04-19 14:37:57.000000000 +0200 +++ linux-2.6.11/arch/um/kernel/Makefile 2005-04-19 14:39:02.000000000 +0200 @@ -12,7 +12,7 @@ obj-y = checksum.o config.o exec_kern.o sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \ syscall_kern.o syscall_user.o sysrq.o sys_call_table.o tempfile.o \ time.o time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o \ - um_arch.o umid.o user_util.o + um_arch.o umid.o user_util.o core-on-panic.o obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o obj-$(CONFIG_GPROF) += gprof_syms.o Index: linux-2.6.11/arch/um/kernel/core-on-panic.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.11/arch/um/kernel/core-on-panic.c 2005-04-19 14:39:02.000000000 +0200 @@ -0,0 +1,64 @@ +/* + * allow user mode linux kernels dump core on kernel panics, + * for later analysis of the crash. + * + * (c) 2004 Gerd Knorr + D. Bahi + */ +#include +#include +#include + +#include "init.h" +#include "os.h" + +static int core_on_panic_func(struct notifier_block *self, unsigned long unused1, + void *unused2) +{ + static int recurse = 0; + + /* cleanup so we have less to cleanup [linux] on the host */ + /* could panic in uml_cleanup though so we need a check */ + if (0 == recurse++) + uml_cleanup(); + + /* to prevent keyboard from causing terminal to spew during dump */ + block_signals(); + + /* actually dump ... */ + abort(); + + /* not reached */ + return 0; +} + +static struct notifier_block core_on_panic_notifier = { + .notifier_call = core_on_panic_func, + .priority = 1, +}; + +static int core_on_panic = 0; + +static int __init core_on_panic_setup(char *str) +{ + core_on_panic = 1; + return 0; +} + +static int __init core_on_panic_init(void) +{ + if (core_on_panic) + notifier_chain_register(&panic_notifier_list, &core_on_panic_notifier); + return 0; +} + +__initcall(core_on_panic_init); +__setup("coreonpanic", core_on_panic_setup); +__uml_help(core_on_panic_setup, + "coreonpanic\n" + " This flag make it so that UML will dump core on a kernel panic or segfault.\n" + " Shell environment restrictions on cores (limit or ulimit) still apply.\n" + "\n" + " Beware that your UML will not reboot with this flag.\n" + "\n" +); +