diff --git a/src/migtd/src/bin/migtd/main.rs b/src/migtd/src/bin/migtd/main.rs index c4660aaa9..69bf6c997 100644 --- a/src/migtd/src/bin/migtd/main.rs +++ b/src/migtd/src/bin/migtd/main.rs @@ -541,6 +541,7 @@ fn handle_pre_mig() { ); REQUESTS.lock().remove(&rebinding_info.mig_request_id); } + #[cfg(feature = "AzCVMEmu")] WaitForRequestResponse::GetTdReport(wfr_info) => { log::trace!(migration_request_id = wfr_info.mig_request_id; "Processing GetTdReport request\n"); let status = get_tdreport( diff --git a/src/migtd/src/migration/data.rs b/src/migtd/src/migration/data.rs index 61d2c5ca0..65b7ea4ad 100644 --- a/src/migtd/src/migration/data.rs +++ b/src/migtd/src/migration/data.rs @@ -256,6 +256,7 @@ pub enum WaitForRequestResponse { StartMigration(MigrationInformation), #[cfg(all(feature = "main", feature = "policy_v2"))] StartRebinding(MigtdMigrationInformation), + #[cfg(feature = "AzCVMEmu")] GetTdReport(ReportInfo), EnableLogArea(EnableLogAreaInfo), #[cfg(feature = "policy_v2")] diff --git a/src/migtd/src/migration/session.rs b/src/migtd/src/migration/session.rs index 6e2631f22..9e14be344 100644 --- a/src/migtd/src/migration/session.rs +++ b/src/migtd/src/migration/session.rs @@ -441,7 +441,22 @@ fn parse_request( } } DataStatusOperation::GetTDReport => { - decode_and_dispatch!(ReportInfo, |info| WaitForRequestResponse::GetTdReport(info)) + #[cfg(feature = "AzCVMEmu")] + { + decode_and_dispatch!(ReportInfo, |info| WaitForRequestResponse::GetTdReport(info)) + } + #[cfg(not(feature = "AzCVMEmu"))] + { + log_request_error!( + request_id, + "wait_for_request: GetTDReport is not supported in production builds\n" + ); + reject_request( + pending_error_report, + request_id, + MigrationResult::UnsupportedOperationError, + ) + } } DataStatusOperation::EnableLogArea => { decode_and_dispatch!(EnableLogAreaInfo, |info| { @@ -1529,14 +1544,22 @@ mod test { let buf = build_request_buffer(3, &payload); let mut pending = None; let result = parse_request(&buf, HDR_LEN, &mut pending); - match result { - Poll::Ready(Ok(WaitForRequestResponse::GetTdReport(info))) => { - assert_eq!(info.mig_request_id, request_id); - assert_eq!(info.reportdata[0], 0xCC); + #[cfg(feature = "AzCVMEmu")] + { + match result { + Poll::Ready(Ok(WaitForRequestResponse::GetTdReport(info))) => { + assert_eq!(info.mig_request_id, request_id); + assert_eq!(info.reportdata[0], 0xCC); + } + _ => panic!("Expected GetTdReport, got unexpected variant"), } - _ => panic!("Expected GetTdReport, got unexpected variant"), + cleanup_request(request_id); } - cleanup_request(request_id); + #[cfg(not(feature = "AzCVMEmu"))] + assert!(matches!( + result, + Poll::Ready(Err(MigrationResult::UnsupportedOperationError)) + )); } #[test] @@ -1546,26 +1569,44 @@ mod test { let buf = build_request_buffer(3, &payload); let mut pending = None; let result = parse_request(&buf, HDR_LEN, &mut pending); - match result { - Poll::Ready(Ok(WaitForRequestResponse::GetTdReport(info))) => { - assert_eq!(info.mig_request_id, request_id); - assert_eq!(info.reportdata, [0u8; 64]); + #[cfg(feature = "AzCVMEmu")] + { + match result { + Poll::Ready(Ok(WaitForRequestResponse::GetTdReport(info))) => { + assert_eq!(info.mig_request_id, request_id); + assert_eq!(info.reportdata, [0u8; 64]); + } + _ => { + panic!("Expected GetTdReport with zero reportdata, got unexpected variant") + } } - _ => panic!("Expected GetTdReport with zero reportdata, got unexpected variant"), + cleanup_request(request_id); } - cleanup_request(request_id); + #[cfg(not(feature = "AzCVMEmu"))] + assert!(matches!( + result, + Poll::Ready(Err(MigrationResult::UnsupportedOperationError)) + )); } #[test] fn test_parse_get_td_report_wrong_size_rejected() { - // 16 bytes is neither 8 nor 72 → read_from_bytes rejects + // 16 bytes is neither 8 nor 72. Under AzCVMEmu the payload is decoded + // and rejected for its size; production builds reject GetTDReport + // outright as unsupported before decoding. let buf = build_request_buffer(3, &[0u8; 16]); let mut pending = None; let result = parse_request(&buf, HDR_LEN, &mut pending); + #[cfg(feature = "AzCVMEmu")] assert!(matches!( result, Poll::Ready(Err(MigrationResult::InvalidParameter)) )); + #[cfg(not(feature = "AzCVMEmu"))] + assert!(matches!( + result, + Poll::Ready(Err(MigrationResult::UnsupportedOperationError)) + )); } #[test]