mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-virtio: Implement control queue support for net devices
While feature VIRTIO_NET_F_CTRL_VQ is negotiated, control queue will exits besides the Tx/Rx virtqueues, an epoll handler should be started to monitor and handle the control queue event. Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
d38787c578
commit
709f7fe607
@@ -133,7 +133,41 @@ macro_rules! virtio_pausable_inner {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
};
|
||||
($ctrl_q:expr) => {
|
||||
fn pause(&mut self) -> result::Result<(), MigratableError> {
|
||||
debug!(
|
||||
"Pausing virtio-{}",
|
||||
VirtioDeviceType::from(self.device_type())
|
||||
);
|
||||
self.paused.store(true, Ordering::SeqCst);
|
||||
if let Some(pause_evt) = &self.pause_evt {
|
||||
pause_evt
|
||||
.write(1)
|
||||
.map_err(|e| MigratableError::Pause(e.into()))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn resume(&mut self) -> result::Result<(), MigratableError> {
|
||||
debug!(
|
||||
"Resuming virtio-{}",
|
||||
VirtioDeviceType::from(self.device_type())
|
||||
);
|
||||
self.paused.store(false, Ordering::SeqCst);
|
||||
|
||||
if let Some(epoll_thread) = &self.epoll_thread {
|
||||
epoll_thread.thread().unpark();
|
||||
}
|
||||
|
||||
if let Some(ctrl_queue_epoll_thread) = &self.ctrl_queue_epoll_thread {
|
||||
ctrl_queue_epoll_thread.thread().unpark();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
@@ -143,4 +177,9 @@ macro_rules! virtio_pausable {
|
||||
virtio_pausable_inner!();
|
||||
}
|
||||
};
|
||||
($name:ident, $ctrl_q:expr) => {
|
||||
impl Pausable for $name {
|
||||
virtio_pausable_inner!($ctrl_q);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user