virtio-devices: vhost_user: Fix wrong naming regarding reconnection

Since the reconnection thread took on the responsibility to handle
backend initiated requests as well, the variable naming should reflect
this by avoiding the "reconnect" prefix.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2021-06-14 10:46:44 +02:00 committed by Bo Chen
parent 428c637506
commit 744e9d06e5
4 changed files with 28 additions and 28 deletions

View File

@ -47,7 +47,7 @@ pub struct Blk {
guest_memory: Option<GuestMemoryAtomic<GuestMemoryMmap>>, guest_memory: Option<GuestMemoryAtomic<GuestMemoryMmap>>,
acked_protocol_features: u64, acked_protocol_features: u64,
socket_path: String, socket_path: String,
reconnect_epoll_thread: Option<thread::JoinHandle<()>>, epoll_thread: Option<thread::JoinHandle<()>>,
} }
impl Blk { impl Blk {
@ -143,7 +143,7 @@ impl Blk {
guest_memory: None, guest_memory: None,
acked_protocol_features, acked_protocol_features,
socket_path: vu_cfg.socket, socket_path: vu_cfg.socket,
reconnect_epoll_thread: None, epoll_thread: None,
}) })
} }
} }
@ -248,7 +248,7 @@ impl VirtioDevice for Blk {
// the backend. // the backend.
let (kill_evt, pause_evt) = self.common.dup_eventfds(); let (kill_evt, pause_evt) = self.common.dup_eventfds();
let mut reconnect_handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler { let mut handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler {
vu: self.vhost_user_blk.clone(), vu: self.vhost_user_blk.clone(),
mem, mem,
kill_evt, kill_evt,
@ -270,11 +270,11 @@ impl VirtioDevice for Blk {
thread::Builder::new() thread::Builder::new()
.name(self.id.to_string()) .name(self.id.to_string())
.spawn(move || { .spawn(move || {
if let Err(e) = reconnect_handler.run(paused, paused_sync.unwrap()) { if let Err(e) = handler.run(paused, paused_sync.unwrap()) {
error!("Error running reconnection worker: {:?}", e); error!("Error running vhost-user-blk worker: {:?}", e);
} }
}) })
.map(|thread| self.reconnect_epoll_thread = Some(thread)) .map(|thread| self.epoll_thread = Some(thread))
.map_err(|e| { .map_err(|e| {
error!("failed to clone queue EventFd: {}", e); error!("failed to clone queue EventFd: {}", e);
ActivateError::BadActivate ActivateError::BadActivate
@ -340,8 +340,8 @@ impl Pausable for Blk {
fn resume(&mut self) -> result::Result<(), MigratableError> { fn resume(&mut self) -> result::Result<(), MigratableError> {
self.common.resume()?; self.common.resume()?;
if let Some(reconnect_epoll_thread) = &self.reconnect_epoll_thread { if let Some(epoll_thread) = &self.epoll_thread {
reconnect_epoll_thread.thread().unpark(); epoll_thread.thread().unpark();
} }
Ok(()) Ok(())
} }

View File

@ -282,7 +282,7 @@ pub struct Fs {
guest_memory: Option<GuestMemoryAtomic<GuestMemoryMmap>>, guest_memory: Option<GuestMemoryAtomic<GuestMemoryMmap>>,
acked_protocol_features: u64, acked_protocol_features: u64,
socket_path: String, socket_path: String,
reconnect_epoll_thread: Option<thread::JoinHandle<()>>, epoll_thread: Option<thread::JoinHandle<()>>,
} }
impl Fs { impl Fs {
@ -371,7 +371,7 @@ impl Fs {
guest_memory: None, guest_memory: None,
acked_protocol_features, acked_protocol_features,
socket_path: path.to_string(), socket_path: path.to_string(),
reconnect_epoll_thread: None, epoll_thread: None,
}) })
} }
} }
@ -468,7 +468,7 @@ impl VirtioDevice for Fs {
// Run a dedicated thread for handling potential reconnections with // Run a dedicated thread for handling potential reconnections with
// the backend as well as requests initiated by the backend. // the backend as well as requests initiated by the backend.
let (kill_evt, pause_evt) = self.common.dup_eventfds(); let (kill_evt, pause_evt) = self.common.dup_eventfds();
let mut reconnect_handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler { let mut handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler {
vu: self.vu.clone(), vu: self.vu.clone(),
mem, mem,
kill_evt, kill_evt,
@ -496,11 +496,11 @@ impl VirtioDevice for Fs {
.spawn(move || { .spawn(move || {
if let Err(e) = SeccompFilter::apply(virtio_vhost_fs_seccomp_filter) { if let Err(e) = SeccompFilter::apply(virtio_vhost_fs_seccomp_filter) {
error!("Error applying seccomp filter: {:?}", e); error!("Error applying seccomp filter: {:?}", e);
} else if let Err(e) = reconnect_handler.run(paused, paused_sync.unwrap()) { } else if let Err(e) = handler.run(paused, paused_sync.unwrap()) {
error!("Error running reconnection worker: {:?}", e); error!("Error running vhost-user-fs worker: {:?}", e);
} }
}) })
.map(|thread| self.reconnect_epoll_thread = Some(thread)) .map(|thread| self.epoll_thread = Some(thread))
.map_err(|e| { .map_err(|e| {
error!("failed to clone queue EventFd: {}", e); error!("failed to clone queue EventFd: {}", e);
ActivateError::BadActivate ActivateError::BadActivate
@ -594,8 +594,8 @@ impl Pausable for Fs {
fn resume(&mut self) -> result::Result<(), MigratableError> { fn resume(&mut self) -> result::Result<(), MigratableError> {
self.common.resume()?; self.common.resume()?;
if let Some(reconnect_epoll_thread) = &self.reconnect_epoll_thread { if let Some(epoll_thread) = &self.epoll_thread {
reconnect_epoll_thread.thread().unpark(); epoll_thread.thread().unpark();
} }
Ok(()) Ok(())
} }

View File

@ -251,7 +251,7 @@ impl<S: VhostUserMasterReqHandler> EpollHelperHandler for VhostUserEpollHandler<
} }
} }
_ => { _ => {
error!("Unknown event for vhost-user reconnection thread"); error!("Unknown event for vhost-user thread");
return true; return true;
} }
} }

View File

@ -101,7 +101,7 @@ pub struct Net {
socket_path: String, socket_path: String,
server: bool, server: bool,
ctrl_queue_epoll_thread: Option<thread::JoinHandle<()>>, ctrl_queue_epoll_thread: Option<thread::JoinHandle<()>>,
reconnect_epoll_thread: Option<thread::JoinHandle<()>>, epoll_thread: Option<thread::JoinHandle<()>>,
seccomp_action: SeccompAction, seccomp_action: SeccompAction,
} }
@ -193,7 +193,7 @@ impl Net {
socket_path: vu_cfg.socket, socket_path: vu_cfg.socket,
server, server,
ctrl_queue_epoll_thread: None, ctrl_queue_epoll_thread: None,
reconnect_epoll_thread: None, epoll_thread: None,
seccomp_action, seccomp_action,
}) })
} }
@ -258,9 +258,9 @@ impl VirtioDevice for Net {
}; };
let paused = self.common.paused.clone(); let paused = self.common.paused.clone();
// Let's update the barrier as we need 1 for the control queue + 1 // Let's update the barrier as we need 1 for the control queue
// for the reconnect thread + 1 for the main thread signalling the // thread + 1 for the common vhost-user thread + 1 for the main
// pause. // thread signalling the pause.
self.common.paused_sync = Some(Arc::new(Barrier::new(3))); self.common.paused_sync = Some(Arc::new(Barrier::new(3)));
let paused_sync = self.common.paused_sync.clone(); let paused_sync = self.common.paused_sync.clone();
@ -317,7 +317,7 @@ impl VirtioDevice for Net {
// the backend. // the backend.
let (kill_evt, pause_evt) = self.common.dup_eventfds(); let (kill_evt, pause_evt) = self.common.dup_eventfds();
let mut reconnect_handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler { let mut handler: VhostUserEpollHandler<SlaveReqHandler> = VhostUserEpollHandler {
vu: self.vhost_user_net.clone(), vu: self.vhost_user_net.clone(),
mem, mem,
kill_evt, kill_evt,
@ -339,11 +339,11 @@ impl VirtioDevice for Net {
thread::Builder::new() thread::Builder::new()
.name(self.id.to_string()) .name(self.id.to_string())
.spawn(move || { .spawn(move || {
if let Err(e) = reconnect_handler.run(paused, paused_sync.unwrap()) { if let Err(e) = handler.run(paused, paused_sync.unwrap()) {
error!("Error running reconnection worker: {:?}", e); error!("Error running vhost-user-net worker: {:?}", e);
} }
}) })
.map(|thread| self.reconnect_epoll_thread = Some(thread)) .map(|thread| self.epoll_thread = Some(thread))
.map_err(|e| { .map_err(|e| {
error!("failed to clone queue EventFd: {}", e); error!("failed to clone queue EventFd: {}", e);
ActivateError::BadActivate ActivateError::BadActivate
@ -418,8 +418,8 @@ impl Pausable for Net {
ctrl_queue_epoll_thread.thread().unpark(); ctrl_queue_epoll_thread.thread().unpark();
} }
if let Some(reconnect_epoll_thread) = &self.reconnect_epoll_thread { if let Some(epoll_thread) = &self.epoll_thread {
reconnect_epoll_thread.thread().unpark(); epoll_thread.thread().unpark();
} }
Ok(()) Ok(())