Skip to content

Commit 66e6161

Browse files
feat(migtd): route warn/error/fatal logs to COM1 serial port
MigTD debugging has historically required ad-hoc TDVMCALL.IO writes inserted by hand, because failure paths often did not call any of the `log::*` macros and there was no guarantee that fatal exits reached the host console. td-logger is already initialised with `LevelFilter::Trace` and, with the `tdx` feature, writes each byte to COM1 (0x3F8) via TDVMCALL.IO, which QEMU forwards through `-serial mon:stdio`. This change makes that serial path the canonical debugging channel: * Add `release_max_level_info` to the `log` dependency so release builds compile out `debug!`/`trace!` while keeping `info!`, `warn!` and `error!` on the serial line. No VMM changes, no shared buffer and no extra TDVMCALL are required. * Emit `log::error!` from `panic_with_guest_crash_reg_report` with the error code, message and caller `file:line` so every fatal exit is visible on the serial port even when the surrounding code forgot to log. Signed-off-by: Michal Tarnacki <michal.tarnacki@intel.com> Co-authored-by: GitHub Copilot <noreply@github.com>
1 parent de248d6 commit 66e6161

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/migtd/src/driver/vmcall_raw.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ pub fn vmcall_raw_device_init() {
1616

1717
#[track_caller]
1818
pub fn panic_with_guest_crash_reg_report(errorcode: u64, msg: &[u8]) -> ! {
19-
#[cfg(not(feature = "vmcall-raw"))]
20-
let _ = errorcode;
2119
let location = core::panic::Location::caller();
2220
let file = location.file();
2321
let line = location.line();
@@ -27,6 +25,16 @@ pub fn panic_with_guest_crash_reg_report(errorcode: u64, msg: &[u8]) -> ! {
2725
" non-UTF8 message".to_string()
2826
};
2927

28+
// Always surface the fatal condition on the serial port via td-logger,
29+
// independent of any surrounding logging that the caller may have done.
30+
log::error!(
31+
"MigTD fatal (code=0x{:x}): {} at {}:{}\n",
32+
errorcode,
33+
panic_message,
34+
file,
35+
line
36+
);
37+
3038
#[cfg(feature = "vmcall-raw")]
3139
{
3240
let crash_message = format!(

0 commit comments

Comments
 (0)