From ef80ad8cb6c19ef47510d00542259ba112e7303e Mon Sep 17 00:00:00 2001 From: Stanislaw Grams Date: Fri, 12 Jun 2026 13:32:59 +0200 Subject: [PATCH] fix(migtd): resolve compiler warnings across crates Fix all warnings emitted during a default feature build: - attestation: replace `use super::*` with a cfg-gated `use super::QveCollateral` in attest_lib_binding, since QveCollateral is only referenced under the attest-lib-ext feature. - migtd/servtd_ext: add missing `#[cfg(test)]` attribute to the `mod test` block, consistent with every other test module in the codebase, silencing the unused-import lint on `ServtdExt`. - migtd/session: gate the `log_request_error!` macro definition behind `#[cfg(feature = "vmcall-raw")]` since all call-sites live inside vmcall-raw-only functions; remove spurious `mut` from the `transport` binding (value is consumed by-move, never reassigned). - migtd/transport: prefix both `mig_request_id` parameters with `_` (`_mig_request_id`) in `setup_transport` and `shutdown_transport`; the parameter is only read inside cfg-gated blocks so it appears unused when those features are disabled. - migtd/main: rename `data` / `mut data` to `mut _data` and update all references; the buffer is only passed into vmcall-raw and policy_v2 code paths, making it appear unused in other configurations. Signed-off-by: Stanislaw Grams --- src/attestation/src/binding.rs | 3 ++- src/migtd/src/bin/migtd/main.rs | 3 +-- src/migtd/src/migration/servtd_ext.rs | 1 + src/migtd/src/migration/session.rs | 2 ++ src/migtd/src/migration/transport.rs | 14 +++++++------- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/attestation/src/binding.rs b/src/attestation/src/binding.rs index 018113b8d..84c6e77f0 100644 --- a/src/attestation/src/binding.rs +++ b/src/attestation/src/binding.rs @@ -61,7 +61,8 @@ pub struct QveCollateral { #[cfg(not(feature = "test"))] mod attest_lib_binding { - use super::*; + #[cfg(feature = "attest-lib-ext")] + use super::QveCollateral; extern "C" { /// Get MigTD's Quote by passing tdx_report. diff --git a/src/migtd/src/bin/migtd/main.rs b/src/migtd/src/bin/migtd/main.rs index a44a99e5f..c4660aaa9 100644 --- a/src/migtd/src/bin/migtd/main.rs +++ b/src/migtd/src/bin/migtd/main.rs @@ -455,8 +455,6 @@ fn handle_pre_mig() { loop { // Poll the async runtime to execute tasks let _ = async_runtime::poll_tasks(); - let mut data: Vec = Vec::new(); - // The async task waiting for VMM response is always in the queue let new_request = PENDING_REQUEST.lock().take(); @@ -481,6 +479,7 @@ fn handle_pre_mig() { } #[cfg(feature = "vmcall-raw")] { + let mut data: Vec = Vec::new(); match request { WaitForRequestResponse::StartMigration(wfr_info) => { log::trace!(migration_request_id = wfr_info.mig_info.mig_request_id; "Processing StartMigration request\n"); diff --git a/src/migtd/src/migration/servtd_ext.rs b/src/migtd/src/migration/servtd_ext.rs index 0f4780b54..b7c3ead78 100644 --- a/src/migtd/src/migration/servtd_ext.rs +++ b/src/migtd/src/migration/servtd_ext.rs @@ -183,6 +183,7 @@ pub fn write_approved_servtd_ext_hash(servtd_ext_hash: &[u8]) -> Result<(), Migr Ok(()) } +#[cfg(test)] mod test { use super::ServtdExt; diff --git a/src/migtd/src/migration/session.rs b/src/migtd/src/migration/session.rs index 0a672e31a..c7629f73e 100644 --- a/src/migtd/src/migration/session.rs +++ b/src/migtd/src/migration/session.rs @@ -295,6 +295,7 @@ fn reject_request( } /// Log an error with an optional `migration_request_id` structured field. +#[cfg(feature = "vmcall-raw")] macro_rules! log_request_error { ($request_id:expr, $($arg:tt)*) => { if let Some(mig_request_id) = $request_id { @@ -1032,6 +1033,7 @@ pub async fn exchange_msk(info: &MigrationInformation) -> Result<()> { })?; } + #[allow(unused_mut)] let mut transport = setup_transport( info.mig_info.mig_request_id, #[cfg(any(feature = "vmcall-vsock", feature = "virtio-vsock"))] diff --git a/src/migtd/src/migration/transport.rs b/src/migtd/src/migration/transport.rs index 35f689dba..0615ed5cb 100644 --- a/src/migtd/src/migration/transport.rs +++ b/src/migtd/src/migration/transport.rs @@ -16,21 +16,21 @@ pub(super) type TransportType = virtio_serial::VirtioSerialPort; pub(super) type TransportType = vsock::stream::VsockStream; pub(super) async fn setup_transport( - mig_request_id: u64, + _mig_request_id: u64, #[cfg(any(feature = "vmcall-vsock", feature = "virtio-vsock"))] migtd_cid: u64, #[cfg(any(feature = "vmcall-vsock", feature = "virtio-vsock"))] mig_channel_port: u32, ) -> Result { #[cfg(feature = "vmcall-raw")] { use vmcall_raw::stream::VmcallRaw; - let mut vmcall_raw_instance = VmcallRaw::new_with_mid(mig_request_id).map_err(|e| { - log::error!(migration_request_id = mig_request_id; + let mut vmcall_raw_instance = VmcallRaw::new_with_mid(_mig_request_id).map_err(|e| { + log::error!(migration_request_id = _mig_request_id; "exchange_msk: Failed to create vmcall_raw_instance errorcode: {:?}\n", e); MigrationResult::InvalidParameter })?; vmcall_raw_instance.connect().await.map_err(|e| { - log::error!(migration_request_id = mig_request_id; + log::error!(migration_request_id = _mig_request_id; "exchange_msk: Failed to connect vmcall_raw_instance errorcode: {:?}\n", e); MigrationResult::InvalidParameter })?; @@ -55,7 +55,7 @@ pub(super) async fn setup_transport( let mut vsock = VsockStream::new()?; #[cfg(feature = "vmcall-vsock")] - let mut vsock = VsockStream::new_with_cid(migtd_cid, mig_request_id)?; + let mut vsock = VsockStream::new_with_cid(migtd_cid, _mig_request_id)?; // Establish the vsock connection with host vsock @@ -67,11 +67,11 @@ pub(super) async fn setup_transport( pub(super) async fn shutdown_transport( transport: &mut TransportType, - mig_request_id: u64, + _mig_request_id: u64, ) -> Result<()> { #[cfg(feature = "vmcall-raw")] transport.shutdown().await.map_err(|e| { - log::error!(migration_request_id = mig_request_id; + log::error!(migration_request_id = _mig_request_id; "shutdown_transport: Failed to shutdown vmcall_raw_instance errorcode: {:?}\n", e); MigrationResult::InvalidParameter })?;