vsock: deal with process_tx error gracefully

It's possible to receive backend events before the VMM contacts us to
activate the vrings. Trying to call process_tx in this state will
trigger a NoMemoryConfigured error which will end crashing the worker
thread.

As NoMemoryConfigured is a transitory error, deal with it gracefully
printing a warning but continuing the normal execution.

Signed-off-by: Sergio Lopez <slp@redhat.com>
This commit is contained in:
Sergio Lopez 2023-05-18 11:03:30 +02:00 committed by Alex Bennée
parent 0d5be1a439
commit b2fa8d91dd

View File

@ -6,6 +6,7 @@ use std::{
u16, u32, u64, u8,
};
use log::warn;
use thiserror::Error as ThisError;
use vhost::vhost_user::message::{VhostUserProtocolFeatures, VhostUserVirtioFeatures};
use vhost_user_backend::{VhostUserBackend, VringRwLock};
@ -289,7 +290,14 @@ impl VhostUserBackend<VringRwLock, ()> for VhostUserVsockBackend {
EVT_QUEUE_EVENT => {}
BACKEND_EVENT => {
thread.process_backend_evt(evset);
thread.process_tx(vring_tx, evt_idx)?;
if let Err(e) = thread.process_tx(vring_tx, evt_idx) {
match e {
Error::NoMemoryConfigured => {
warn!("Received a backend event before vring initialization")
}
_ => return Err(e.into()),
}
}
}
_ => {
return Err(Error::HandleUnknownEvent.into());