mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-26 06:32:44 +00:00
vhost-device-sound: don't use daemon.serve()
VhostUserDaemon::serve unlinks and re-creates the topic every time it's called, so it's inherently racy to call it in a loop like we're doing here. Not using it will allow us (following further changes) to fix this race. Signed-off-by: Alyssa Ross <hi@alyssa.is>
This commit is contained in:
parent
f310f2c121
commit
242104d65c
@ -19,6 +19,7 @@ use std::{convert::TryFrom, io::Error as IoError, mem::size_of, path::PathBuf, s
|
||||
pub use args::BackendType;
|
||||
pub use stream::Stream;
|
||||
use thiserror::Error as ThisError;
|
||||
use vhost::vhost_user::Listener;
|
||||
use vhost_user_backend::{VhostUserDaemon, VringRwLock, VringT};
|
||||
use virtio_sound::*;
|
||||
use vm_memory::{ByteValued, GuestMemoryAtomic, GuestMemoryLoadGuard, GuestMemoryMmap, Le32};
|
||||
@ -314,13 +315,28 @@ pub fn start_backend_server(config: SoundConfig) {
|
||||
|
||||
let mut daemon = VhostUserDaemon::new(
|
||||
String::from("vhost-device-sound"),
|
||||
backend,
|
||||
Arc::clone(&backend),
|
||||
GuestMemoryAtomic::new(GuestMemoryMmap::new()),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
log::trace!("Starting daemon.");
|
||||
daemon.serve(socket).unwrap();
|
||||
|
||||
let mut listener = Listener::new(socket, true).unwrap();
|
||||
|
||||
daemon.start(&mut listener).unwrap();
|
||||
let result = daemon.wait();
|
||||
|
||||
backend.send_exit_event();
|
||||
|
||||
if !matches!(
|
||||
result,
|
||||
Err(vhost_user_backend::Error::HandleRequest(
|
||||
vhost::vhost_user::Error::Disconnected | vhost::vhost_user::Error::PartialMessage
|
||||
))
|
||||
) {
|
||||
result.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user