Skip to content

Commit 707fe61

Browse files
authored
GET: Log the response type when we get an unexpected one (#1604) (#1632)
We're seeing this happen in an ICM right now, so let's be better in the future. Cherry-pick of #1604
1 parent cc2934f commit 707fe61

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

vm/devices/get/guest_emulation_transport/src/process_loop.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ pub(crate) enum FatalError {
8181
VersionNegotiationFailed,
8282
#[error("control receive failed")]
8383
VersionNegotiationTryRecvFailed(#[source] RecvError),
84-
#[error("received response with no pending request")]
85-
NoPendingRequest,
84+
#[error("received response id {0:?} with no pending request")]
85+
NoPendingRequest(HostRequests),
8686
#[error("failed to serialize VTL2 settings error info")]
8787
Vtl2SettingsErrorInfoJson(#[source] serde_json::error::Error),
8888
#[error("received too many guest notifications of kind {0:?} prior to downstream worker init")]
@@ -845,27 +845,25 @@ impl<T: RingMem> ProcessLoop<T> {
845845
.map(Event::Failure);
846846

847847
// Closure to share code between the primary and secondary host request queue.
848-
let run_host_request_queue = async | request_queue: &mut HostRequestQueue, response_recv: &ExclusiveHostRequestResponseReceiverAccess | {
849-
while let Some(request) = request_queue.front_mut() {
850-
if let Err(e) = request.as_mut().await {
851-
return e;
852-
}
848+
let run_host_request_queue =
849+
async |request_queue: &mut HostRequestQueue, response_recv: &ExclusiveHostRequestResponseReceiverAccess| {
850+
while let Some(request) = request_queue.front_mut() {
851+
if let Err(e) = request.as_mut().await {
852+
return e;
853+
}
853854

854-
request_queue.pop_front();
855-
856-
// Ensure there are no extra response messages that this request failed to pick up.
857-
if response_recv
858-
.lock()
859-
.as_mut()
860-
.unwrap()
861-
.try_recv()
862-
.is_ok()
863-
{
864-
return FatalError::NoPendingRequest;
855+
request_queue.pop_front();
856+
857+
// Ensure there are no extra response messages that this request failed to pick up.
858+
if let Ok(resp) = response_recv.lock().as_mut().unwrap().try_recv() {
859+
let id = get_protocol::HeaderRaw::read_from_prefix(&resp)
860+
.map(|head| HostRequests(head.0.message_id))
861+
.unwrap_or(HostRequests::INVALID);
862+
return FatalError::NoPendingRequest(id);
863+
}
865864
}
866-
}
867-
pending().await
868-
};
865+
pending().await
866+
};
869867

870868
// Run the next host request in the primary queue. These host
871869
// requests are expected to be generally fast and independent
@@ -1316,7 +1314,7 @@ impl<T: RingMem> ProcessLoop<T> {
13161314
buf: &[u8],
13171315
) -> Result<(), FatalError> {
13181316
if self.primary_host_requests.is_empty() && self.secondary_host_requests.is_empty() {
1319-
return Err(FatalError::NoPendingRequest);
1317+
return Err(FatalError::NoPendingRequest(header.message_id()));
13201318
}
13211319
validate_response(header)?;
13221320

0 commit comments

Comments
 (0)