virtio-devices: Remove virtio_pausable! macros

These are no longer needed as virtio device pausing is handledby
VirtioCommon.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-09-07 11:42:16 +01:00 committed by Sebastien Boeuf
parent a641f8930f
commit 42de27b215

View File

@ -323,130 +323,3 @@ impl Pausable for VirtioCommon {
Ok(())
}
}
#[macro_export]
macro_rules! virtio_pausable_trait_definition {
() => {
trait VirtioPausable {
fn virtio_pause(&mut self) -> std::result::Result<(), MigratableError>;
fn virtio_resume(&mut self) -> std::result::Result<(), MigratableError>;
}
};
}
#[macro_export]
macro_rules! virtio_pausable_trait_inner {
() => {
// This is the common Pausable trait implementation for virtio.
fn virtio_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()))?;
// Wait for all threads to acknowledge the pause before going
// any further. This is exclusively performed when pause_evt
// eventfd is Some(), as this means the virtio device has been
// activated. One specific case where the device can be paused
// while it hasn't been yet activated is snapshot/restore.
self.paused_sync.wait();
}
Ok(())
}
fn virtio_resume(&mut self) -> result::Result<(), MigratableError> {
debug!(
"Resuming virtio-{}",
VirtioDeviceType::from(self.device_type())
);
self.paused.store(false, Ordering::SeqCst);
if let Some(epoll_threads) = &self.epoll_threads {
for i in 0..epoll_threads.len() {
epoll_threads[i].thread().unpark();
}
}
Ok(())
}
};
}
#[macro_export]
macro_rules! virtio_pausable_trait {
($type:ident) => {
virtio_pausable_trait_definition!();
impl VirtioPausable for $type {
virtio_pausable_trait_inner!();
}
};
($type:ident, T: $($bounds:tt)+) => {
virtio_pausable_trait_definition!();
impl<T: $($bounds)+ > VirtioPausable for $type<T> {
virtio_pausable_trait_inner!();
}
};
}
#[macro_export]
macro_rules! virtio_pausable_inner {
($type:ident) => {
fn pause(&mut self) -> result::Result<(), MigratableError> {
self.virtio_pause()
}
fn resume(&mut self) -> result::Result<(), MigratableError> {
self.virtio_resume()
}
};
}
#[macro_export]
macro_rules! virtio_pausable {
($type:ident) => {
virtio_pausable_trait!($type);
impl Pausable for $type {
virtio_pausable_inner!($type);
}
};
// For type bound virtio types
($type:ident, T: $($bounds:tt)+) => {
virtio_pausable_trait!($type, T: $($bounds)+);
impl<T: $($bounds)+ > Pausable for $type<T> {
virtio_pausable_inner!($type);
}
};
}
#[macro_export]
macro_rules! virtio_ctrl_q_pausable {
($type:ident) => {
virtio_pausable_trait!($type);
impl Pausable for $type {
fn pause(&mut self) -> result::Result<(), MigratableError> {
self.virtio_pause()
}
fn resume(&mut self) -> result::Result<(), MigratableError> {
self.virtio_resume()?;
if let Some(ctrl_queue_epoll_thread) = &self.ctrl_queue_epoll_thread {
ctrl_queue_epoll_thread.thread().unpark();
}
Ok(())
}
}
};
}