mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
vmm_vhost: Check for errors on vhost-user WAKE
Add analog of https://crrev.com/c/5247322 for WAKE. BUG=b:300501737 TEST=snapshotted downstream and resumed Change-Id: I4567867e14b9eb045c46df8394bb564a8eb2b800 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5252007 Reviewed-by: Noah Gold <nkgold@google.com> Commit-Queue: Idan Raiter <idanr@google.com>
This commit is contained in:
parent
48d18bb1f5
commit
b21b7d650b
3 changed files with 13 additions and 2 deletions
3
third_party/vmm_vhost/src/lib.rs
vendored
3
third_party/vmm_vhost/src/lib.rs
vendored
|
@ -155,6 +155,9 @@ pub enum Error {
|
|||
/// Error from invalid vring index.
|
||||
#[error("Vring index not found: {0}")]
|
||||
VringIndexNotFound(usize),
|
||||
/// Failure to run device specific wake.
|
||||
#[error("Failed to run device specific wake: {0}")]
|
||||
WakeError(anyhow::Error),
|
||||
}
|
||||
|
||||
impl From<base::TubeError> for Error {
|
||||
|
|
9
third_party/vmm_vhost/src/master.rs
vendored
9
third_party/vmm_vhost/src/master.rs
vendored
|
@ -264,7 +264,14 @@ impl Master {
|
|||
/// Wake the device up.
|
||||
pub fn wake(&self) -> Result<()> {
|
||||
let hdr = self.send_request_header(MasterReq::WAKE, None)?;
|
||||
self.wait_for_ack(&hdr)
|
||||
let reply = self.recv_reply::<VhostUserSuccess>(&hdr)?;
|
||||
if !reply.success() {
|
||||
Err(VhostUserError::WakeError(anyhow!(
|
||||
"Device process responded with a failure on WAKE."
|
||||
)))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Snapshot the device and receive serialized state of the device.
|
||||
|
|
|
@ -727,7 +727,8 @@ impl<S: VhostUserSlaveReqHandler> SlaveReqHandler<S> {
|
|||
}
|
||||
Ok(MasterReq::WAKE) => {
|
||||
let res = self.backend.wake();
|
||||
self.slave_req_helper.send_ack_message(&hdr, res.is_ok())?;
|
||||
let msg = VhostUserSuccess::new(res.is_ok());
|
||||
self.slave_req_helper.send_reply_message(&hdr, &msg)?;
|
||||
}
|
||||
Ok(MasterReq::SNAPSHOT) => {
|
||||
let (success_msg, payload) = match self.backend.snapshot() {
|
||||
|
|
Loading…
Reference in a new issue