diff --git a/src/migtd/src/bin/migtd/cvmemu.rs b/src/migtd/src/bin/migtd/cvmemu.rs index 475c34a8a..62f624bc2 100644 --- a/src/migtd/src/bin/migtd/cvmemu.rs +++ b/src/migtd/src/bin/migtd/cvmemu.rs @@ -14,9 +14,7 @@ use alloc::vec::Vec; use migtd; use migtd::driver::vmcall_raw::panic_with_guest_crash_reg_report; use migtd::migration::event; -use migtd::migration::logging::{ - create_logarea, enable_logarea, init_vmm_logger, u8_to_levelfilter, -}; +use migtd::migration::logging::{create_logarea, enable_logarea, init_vmm_logger}; use migtd::migration::session::{exchange_msk, report_status}; use migtd::migration::MigrationResult; @@ -480,12 +478,6 @@ fn handle_pre_mig_emu() -> i32 { .map(|_| MigrationResult::Success) .unwrap_or_else(|e| e); - log::info!(migration_request_id = wfr_info.mig_request_id; - "Setting log level to {}\n", - wfr_info.log_max_level - ); - log::set_max_level(u8_to_levelfilter(wfr_info.log_max_level)); - if status == MigrationResult::Success { log::trace!(migration_request_id = wfr_info.mig_request_id; "Successfully completed Enable LogArea\n"); } else { diff --git a/src/migtd/src/bin/migtd/main.rs b/src/migtd/src/bin/migtd/main.rs index c491e71e7..a44a99e5f 100644 --- a/src/migtd/src/bin/migtd/main.rs +++ b/src/migtd/src/bin/migtd/main.rs @@ -573,12 +573,6 @@ fn handle_pre_mig() { .map(|_| MigrationResult::Success) .unwrap_or_else(|e| e); - log::info!( migration_request_id = wfr_info.mig_request_id; - "Setting log level to {}\n", - wfr_info.log_max_level - ); - log::set_max_level(u8_to_levelfilter(wfr_info.log_max_level)); - if status == MigrationResult::Success { log::trace!(migration_request_id = wfr_info.mig_request_id; "Successfully completed Enable LogArea\n"); } else { diff --git a/src/migtd/src/migration/logging.rs b/src/migtd/src/migration/logging.rs index 89e36939a..be45b8322 100644 --- a/src/migtd/src/migration/logging.rs +++ b/src/migtd/src/migration/logging.rs @@ -307,6 +307,9 @@ pub async fn enable_logarea(log_max_level: u8, request_id: u64, data: &mut Vec()` -/// and rejects payloads with trailing bytes. -#[cfg(feature = "vmcall-raw")] -macro_rules! impl_read_from_bytes { - ($t:ty) => { - #[cfg(feature = "vmcall-raw")] - impl $t { - pub fn read_from_bytes( - data_length: u32, - payload: &[u8], - ) -> core::result::Result { - if data_length != core::mem::size_of::() as u32 { - return Err(MigrationResult::InvalidParameter); - } - payload - .pread(0) - .map_err(|_| MigrationResult::InvalidParameter) - } - } - }; -} - /// Implement `read_from_bytes(data_length, payload)` for a struct whose layout /// starts with `mig_request_id: u64` followed by optional data bytes. /// Accepts either the full struct or just the `mig_request_id` (with the @@ -239,7 +216,24 @@ pub struct EnableLogAreaInfo { } #[cfg(feature = "vmcall-raw")] -impl_read_from_bytes!(EnableLogAreaInfo); +impl EnableLogAreaInfo { + pub fn read_from_bytes( + data_length: u32, + payload: &[u8], + ) -> core::result::Result { + if data_length != core::mem::size_of::() as u32 { + return Err(MigrationResult::InvalidParameter); + } + let info: Self = payload + .pread(0) + .map_err(|_| MigrationResult::InvalidParameter)?; + // GHCI 1.5 v6 Table 3-50: reserved bytes MUST be zero. + if info.reserved.iter().any(|&b| b != 0) { + return Err(MigrationResult::InvalidParameter); + } + Ok(info) + } +} #[repr(C)] #[derive(Debug, Pread, Pwrite)]