mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-19 07:14:22 +01:00
runtime-rs: support dragonball and runtime-binary
Fixes: #3785 Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com> Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
committed by
quanwei.zqw
parent
3f6123b4dd
commit
3d6156f6ec
@@ -22,8 +22,8 @@ log = "0.4.14"
|
||||
nix = "0.23.1"
|
||||
protobuf = "2.27.0"
|
||||
sha2 = "=0.9.3"
|
||||
slog = {version = "2.7.0", features = ["std", "release_max_level_trace", "max_level_trace"]}
|
||||
slog-async = "2.7.0"
|
||||
slog = {version = "2.5.2", features = ["std", "release_max_level_trace", "max_level_trace"]}
|
||||
slog-async = "2.5.2"
|
||||
slog-scope = "4.4.0"
|
||||
slog-stdlog = "4.1.0"
|
||||
thiserror = "1.0.30"
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use std::{boxed::Box, ops::Deref};
|
||||
use std::{boxed::Box, fs::OpenOptions, io::Write, ops::Deref};
|
||||
|
||||
use backtrace::Backtrace;
|
||||
|
||||
const KMESG_DEVICE: &str = "/dev/kmsg";
|
||||
|
||||
// TODO: the Kata 1.x runtime had a SIGUSR1 handler that would log a formatted backtrace on
|
||||
// receiving that signal. It could be useful to re-add that feature.
|
||||
pub(crate) fn set_panic_hook() {
|
||||
@@ -36,6 +38,20 @@ pub(crate) fn set_panic_hook() {
|
||||
"A panic occurred at {}:{}: {}\r\n{:?}", filename, line, cause, bt_data
|
||||
);
|
||||
|
||||
// print panic log to dmesg
|
||||
// The panic log size is too large to /dev/kmsg, so write by line.
|
||||
if let Ok(mut file) = OpenOptions::new().write(true).open(KMESG_DEVICE) {
|
||||
file.write_all(
|
||||
format!("A panic occurred at {}:{}: {}", filename, line, cause).as_bytes(),
|
||||
)
|
||||
.ok();
|
||||
let lines: Vec<&str> = bt_data.split('\n').collect();
|
||||
for line in lines {
|
||||
file.write_all(line.as_bytes()).ok();
|
||||
}
|
||||
|
||||
file.flush().ok();
|
||||
}
|
||||
std::process::abort();
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user