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

View File

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

View File

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