diff options
-rw-r--r-- | src/vlib/main.c | 20 | ||||
-rw-r--r-- | src/vlib/main.h | 4 | ||||
-rw-r--r-- | src/vlib/unix/main.c | 8 | ||||
-rw-r--r-- | src/vpp/vnet/main.c | 9 |
4 files changed, 37 insertions, 4 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c index 422d3e2634b..8af1e7a93cc 100644 --- a/src/vlib/main.c +++ b/src/vlib/main.c @@ -707,6 +707,24 @@ elog_save_buffer (vlib_main_t * vm, return error; } +void +elog_post_mortem_dump (void) +{ + vlib_main_t *vm = &vlib_global_main; + elog_main_t *em = &vm->elog_main; + u8 *filename; + clib_error_t *error; + + if (!vm->elog_post_mortem_dump) + return; + + filename = format (0, "/tmp/elog_post_mortem.%d%c", getpid (), 0); + error = elog_write_file (em, (char *) filename, 1 /* flush ring */ ); + if (error) + clib_error_report (error); + vec_free (filename); +} + /* *INDENT-OFF* */ VLIB_CLI_COMMAND (elog_save_cli, static) = { .path = "event-logger save", @@ -1642,6 +1660,8 @@ vlib_main_configure (vlib_main_t * vm, unformat_input_t * input) else if (unformat (input, "elog-events %d", &vm->elog_main.event_ring_size)) ; + else if (unformat (input, "elog-post-mortem-dump")) + vm->elog_post_mortem_dump = 1; else return unformat_parse_error (input); } diff --git a/src/vlib/main.h b/src/vlib/main.h index 0e8026d17b0..bfa7ddbe6af 100644 --- a/src/vlib/main.h +++ b/src/vlib/main.h @@ -177,6 +177,10 @@ typedef struct vlib_main_t /* debugging */ volatile int parked_at_barrier; + + /* Attempt to do a post-mortem elog dump */ + int elog_post_mortem_dump; + } vlib_main_t; /* Global main structure. */ diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c index 103576db01c..e31ea81583e 100644 --- a/src/vlib/unix/main.c +++ b/src/vlib/unix/main.c @@ -409,12 +409,12 @@ unix_config (vlib_main_t * vm, unformat_input_t * input) format_unformat_error, input); } + error = setup_signal_handlers (um); + if (error) + return error; + if (!(um->flags & UNIX_FLAG_INTERACTIVE)) { - error = setup_signal_handlers (um); - if (error) - return error; - openlog (vm->name, LOG_CONS | LOG_PERROR | LOG_PID, LOG_DAEMON); clib_error_register_handler (unix_error_handler, um); diff --git a/src/vpp/vnet/main.c b/src/vpp/vnet/main.c index d6a1232515f..ade32aa1b78 100644 --- a/src/vpp/vnet/main.c +++ b/src/vpp/vnet/main.c @@ -253,11 +253,13 @@ plugin_path_config (vlib_main_t * vm, unformat_input_t * input) VLIB_CONFIG_FUNCTION (plugin_path_config, "plugin_path"); void vl_msg_api_post_mortem_dump (void); +void elog_post_mortem_dump (void); void os_panic (void) { vl_msg_api_post_mortem_dump (); + elog_post_mortem_dump (); abort (); } @@ -280,6 +282,7 @@ os_exit (int code) recursion_block = 1; vl_msg_api_post_mortem_dump (); + elog_post_mortem_dump (); vhost_user_unmap_all (); abort (); } @@ -320,6 +323,12 @@ test_crash_command_fn (vlib_main_t * vm, { u64 *p = (u64 *) 0xdefec8ed; + ELOG_TYPE_DECLARE (e) = + { + .format = "deliberate crash: touching %x",.format_args = "i4",}; + + elog (&vm->elog_main, &e, 0xdefec8ed); + *p = 0xdeadbeef; /* Not so much... */ |