Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/migtd/src/bin/migtd/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/migtd/src/migration/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
69 changes: 55 additions & 14 deletions src/migtd/src/migration/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand Down
Loading