sound: fix panic on I/O to a stopped stream

process_io() would unwrap() the result of b.write()/b.read(), panicking
if the stream was in any state other than Start or Prepare. This could
happen when the guest queued Tx buffers and then sent PcmStop before
they were all consumed — a normal race between the control and I/O
queues.

Replace the unwrap() calls with a logged warning. Queued requests in
stream.requests are harmless and will be cleared on PcmRelease.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Davíð Steinn Geirsson 2026-03-17 21:31:34 +00:00
parent 323a66d430
commit 15f812953e

View file

@ -468,12 +468,16 @@ impl VhostUserSoundThread {
match direction {
Direction::Output => {
for id in stream_ids {
b.write(id).unwrap();
if let Err(e) = b.write(id) {
log::warn!("Stream {id} write error in non-started state: {e}");
}
}
}
Direction::Input => {
for id in stream_ids {
b.read(id).unwrap();
if let Err(e) = b.read(id) {
log::warn!("Stream {id} read error in non-started state: {e}");
}
}
}
}