当找不到内核日志缓冲区的时候,重试 (#491)

This commit is contained in:
LoGin 2024-01-14 17:00:42 +08:00 committed by GitHub
parent 45626c859f
commit dcf232f378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -53,7 +53,7 @@ impl AppBackend {
} }
#[derive(Debug)] #[derive(Debug)]
struct BackendData { pub(crate) struct BackendData {
kernel_metadata: Option<loader::KernelMetadata>, kernel_metadata: Option<loader::KernelMetadata>,
/// Path to the QEMU shm which contains the kernel memory. /// Path to the QEMU shm which contains the kernel memory.
kmem_path: Option<PathBuf>, kmem_path: Option<PathBuf>,

View File

@ -30,7 +30,7 @@ pub struct MMLogMonitor {
} }
impl MMLogMonitor { impl MMLogMonitor {
pub fn new(shared_data: Arc<Mutex<BackendData>>) -> Arc<Self> { pub(crate) fn new(shared_data: Arc<Mutex<BackendData>>) -> Arc<Self> {
let guard = shared_data.lock().unwrap(); let guard = shared_data.lock().unwrap();
let mm_log_buffer_symbol: Option<Symbol> = guard let mm_log_buffer_symbol: Option<Symbol> = guard
.kernel_metadata .kernel_metadata
@ -153,7 +153,20 @@ impl MMMonitorThread {
pub fn run(&mut self) { pub fn run(&mut self) {
info!("MMMonitorThread::run(): kmem_path: {:?}", self.kmem_path); info!("MMMonitorThread::run(): kmem_path: {:?}", self.kmem_path);
let mut kmem_file = self.open_kmem_file().expect("Failed to open kmem file."); let mut kmem_file = {
let mut file: File;
loop {
let f = self.open_kmem_file();
if f.is_ok() {
file = f.unwrap();
break;
} else {
log::error!("Failed to open kmem file, error: {:?}", f.unwrap_err());
std::thread::sleep(std::time::Duration::from_secs(1));
}
}
file
};
info!("Channel header loaded!"); info!("Channel header loaded!");