Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite wait loop in OpenHCL error handling path #677

Merged
merged 8 commits into from
Jan 16, 2025
15 changes: 13 additions & 2 deletions vm/devices/get/guest_emulation_transport/src/process_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,17 @@ impl HostRequestPipeAccess {
get_protocol::HeaderHostRequest::read_from_prefix(data.as_bytes()).unwrap();
self.recv_response_fixed_size(req_header.message_id).await
}

/// Sends a notification to the host.
///
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the extra line here, and i'd add a note that you probably don't want want this, as it does not wait for a response.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this needs more documentation on why you don't want to use this 99% of the time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should just name it based on the single case that it should be used for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have documented that in comments.

/// This function does not wait for a response.
async fn send_notification_fixed_size<T: AsBytes + ?Sized>(
&mut self,
data: &T,
) -> Result<(), FatalError> {
self.send_message(data.as_bytes().to_vec());
Ok(())
}
}

impl<T: RingMem> ProcessLoop<T> {
Expand Down Expand Up @@ -1678,9 +1689,9 @@ async fn request_send_servicing_state(
let saved_state_buf = match result {
Ok(saved_state_buf) => saved_state_buf,
Err(_err) => {
// TODO: send error to host.
// Sends a failure notification to host.
return access
.send_request_fixed_size(&get_protocol::SaveGuestVtl2StateRequest::new(
.send_notification_fixed_size(&get_protocol::SaveGuestVtl2StateRequest::new(
get_protocol::GuestVtl2SaveRestoreStatus::FAILURE,
))
.await
Expand Down
Loading