From 032558790827a46cf57c579a970f5f85b039adaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dav=C3=AD=C3=B0=20Steinn=20Geirsson?= Date: Tue, 17 Mar 2026 20:16:44 +0000 Subject: [PATCH] sound: fix crash on guest connection by raising max queue size The Linux virtio-sound driver requests a queue size of 256 by default. The backend was capped at 64, causing set_vring_num to return InvalidParam which propagated as an unhandled panic. Also convert the terminal error panic to a logged error + exit(1) so future unexpected daemon errors produce a meaningful log message. Co-Authored-By: Claude Sonnet 4.6 --- vhost-device-sound/src/device.rs | 6 +----- vhost-device-sound/src/lib.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/vhost-device-sound/src/device.rs b/vhost-device-sound/src/device.rs index 788bd6d..72619f6 100644 --- a/vhost-device-sound/src/device.rs +++ b/vhost-device-sound/src/device.rs @@ -615,11 +615,7 @@ impl VhostUserBackend for VhostUserSoundBackend { } fn max_queue_size(&self) -> usize { - // The linux kernel driver does no checks for queue length and fails silently if - // a queue is filled up. In this case, adding an element to the queue - // returns ENOSPC and the element is not queued for a later attempt and - // is lost. `64` is a "good enough" value from our observations. - 64 + 256 } fn features(&self) -> u64 { diff --git a/vhost-device-sound/src/lib.rs b/vhost-device-sound/src/lib.rs index a2d8b5a..14f5c59 100644 --- a/vhost-device-sound/src/lib.rs +++ b/vhost-device-sound/src/lib.rs @@ -328,13 +328,15 @@ pub fn start_backend_server(listener: &mut Listener, config: SoundConfig) { backend.send_exit_event(); - if !matches!( - result, + match result { + Ok(()) => {} Err(vhost_user_backend::Error::HandleRequest( - vhost::vhost_user::Error::Disconnected | vhost::vhost_user::Error::PartialMessage - )) - ) { - result.unwrap(); + vhost::vhost_user::Error::Disconnected | vhost::vhost_user::Error::PartialMessage, + )) => {} + Err(e) => { + log::error!("Daemon exited with error: {e}"); + std::process::exit(1); + } } }