diff --git a/devices/src/virtio/vhost/user/device/block.rs b/devices/src/virtio/vhost/user/device/block.rs index fd60702a74..46b862cd14 100644 --- a/devices/src/virtio/vhost/user/device/block.rs +++ b/devices/src/virtio/vhost/user/device/block.rs @@ -130,8 +130,6 @@ impl VhostUserBackend for BlockBackend { const MAX_QUEUE_NUM: usize = NUM_QUEUES as usize; const MAX_VRING_LEN: u16 = QUEUE_SIZE; - type Error = anyhow::Error; - fn features(&self) -> u64 { self.avail_features } diff --git a/devices/src/virtio/vhost/user/device/console.rs b/devices/src/virtio/vhost/user/device/console.rs index 79a8c95e1d..ce74f500d8 100644 --- a/devices/src/virtio/vhost/user/device/console.rs +++ b/devices/src/virtio/vhost/user/device/console.rs @@ -237,8 +237,6 @@ impl VhostUserBackend for ConsoleBackend { const MAX_QUEUE_NUM: usize = 2; /* transmit and receive queues */ const MAX_VRING_LEN: u16 = 256; - type Error = anyhow::Error; - fn features(&self) -> u64 { self.device.avail_features } diff --git a/devices/src/virtio/vhost/user/device/cras_snd.rs b/devices/src/virtio/vhost/user/device/cras_snd.rs index 615306c462..7af8be8444 100644 --- a/devices/src/virtio/vhost/user/device/cras_snd.rs +++ b/devices/src/virtio/vhost/user/device/cras_snd.rs @@ -91,8 +91,6 @@ impl VhostUserBackend for CrasSndBackend { const MAX_QUEUE_NUM: usize = MAX_QUEUE_NUM; const MAX_VRING_LEN: u16 = MAX_VRING_LEN; - type Error = anyhow::Error; - fn features(&self) -> u64 { self.avail_features } diff --git a/devices/src/virtio/vhost/user/device/fs.rs b/devices/src/virtio/vhost/user/device/fs.rs index a215e96df8..92f0cd6da6 100644 --- a/devices/src/virtio/vhost/user/device/fs.rs +++ b/devices/src/virtio/vhost/user/device/fs.rs @@ -104,8 +104,6 @@ impl VhostUserBackend for FsBackend { const MAX_QUEUE_NUM: usize = 2; /* worker queue and high priority queue */ const MAX_VRING_LEN: u16 = 1024; - type Error = anyhow::Error; - fn features(&self) -> u64 { self.avail_features } diff --git a/devices/src/virtio/vhost/user/device/gpu.rs b/devices/src/virtio/vhost/user/device/gpu.rs index 26b887ddea..f41d9e00f1 100644 --- a/devices/src/virtio/vhost/user/device/gpu.rs +++ b/devices/src/virtio/vhost/user/device/gpu.rs @@ -151,8 +151,6 @@ impl VhostUserBackend for GpuBackend { const MAX_QUEUE_NUM: usize = gpu::QUEUE_SIZES.len(); const MAX_VRING_LEN: u16 = gpu::QUEUE_SIZES[0]; - type Error = anyhow::Error; - fn features(&self) -> u64 { self.gpu.borrow().features() | VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits() } diff --git a/devices/src/virtio/vhost/user/device/handler.rs b/devices/src/virtio/vhost/user/device/handler.rs index ba87d47a7d..5f00dfe054 100644 --- a/devices/src/virtio/vhost/user/device/handler.rs +++ b/devices/src/virtio/vhost/user/device/handler.rs @@ -155,19 +155,15 @@ pub fn create_guest_memory( pub trait VhostUserBackend where Self: Sized, - Self::Error: std::fmt::Display, { const MAX_QUEUE_NUM: usize; const MAX_VRING_LEN: u16; - /// Error type specific to this backend. - type Error; - /// The set of feature bits that this backend supports. fn features(&self) -> u64; /// Acknowledges that this set of features should be enabled. - fn ack_features(&mut self, value: u64) -> std::result::Result<(), Self::Error>; + fn ack_features(&mut self, value: u64) -> anyhow::Result<()>; /// Returns the set of enabled features. fn acked_features(&self) -> u64; @@ -176,7 +172,7 @@ where fn protocol_features(&self) -> VhostUserProtocolFeatures; /// Acknowledges that this set of protocol features should be enabled. - fn ack_protocol_features(&mut self, _value: u64) -> std::result::Result<(), Self::Error>; + fn ack_protocol_features(&mut self, _value: u64) -> anyhow::Result<()>; /// Returns the set of enabled protocol features. fn acked_protocol_features(&self) -> u64; @@ -188,10 +184,7 @@ where fn write_config(&self, _offset: u64, _data: &[u8]) {} /// Sets the channel for device-specific communication. - fn set_device_request_channel( - &mut self, - _channel: File, - ) -> std::result::Result<(), Self::Error> { + fn set_device_request_channel(&mut self, _channel: File) -> anyhow::Result<()> { Ok(()) } @@ -205,7 +198,7 @@ where mem: GuestMemory, doorbell: Arc>, kick_evt: Event, - ) -> std::result::Result<(), Self::Error>; + ) -> anyhow::Result<()>; /// Indicates that the backend should stop processing requests for virtio queue number `idx`. fn stop_queue(&mut self, idx: usize); @@ -697,13 +690,11 @@ mod tests { const MAX_QUEUE_NUM: usize = 16; const MAX_VRING_LEN: u16 = 256; - type Error = anyhow::Error; - fn features(&self) -> u64 { self.avail_features } - fn ack_features(&mut self, value: u64) -> std::result::Result<(), Self::Error> { + fn ack_features(&mut self, value: u64) -> anyhow::Result<()> { let unrequested_features = value & !self.avail_features; if unrequested_features != 0 { bail!( @@ -723,7 +714,7 @@ mod tests { VhostUserProtocolFeatures::CONFIG } - fn ack_protocol_features(&mut self, features: u64) -> std::result::Result<(), Self::Error> { + fn ack_protocol_features(&mut self, features: u64) -> anyhow::Result<()> { let features = VhostUserProtocolFeatures::from_bits(features).ok_or(anyhow!( "invalid protocol features are given: 0x{:x}", features @@ -750,7 +741,7 @@ mod tests { _mem: GuestMemory, _doorbell: Arc>, _kick_evt: Event, - ) -> std::result::Result<(), Self::Error> { + ) -> anyhow::Result<()> { Ok(()) } diff --git a/devices/src/virtio/vhost/user/device/net.rs b/devices/src/virtio/vhost/user/device/net.rs index abe498758e..2372ea4dc4 100644 --- a/devices/src/virtio/vhost/user/device/net.rs +++ b/devices/src/virtio/vhost/user/device/net.rs @@ -105,8 +105,6 @@ where const MAX_QUEUE_NUM: usize = MAX_QUEUE_NUM; /* rx, tx, ctrl */ const MAX_VRING_LEN: u16 = MAX_VRING_LEN; - type Error = anyhow::Error; - fn features(&self) -> u64 { self.avail_features } diff --git a/devices/src/virtio/vhost/user/device/wl.rs b/devices/src/virtio/vhost/user/device/wl.rs index de3361a122..444a2a96b5 100644 --- a/devices/src/virtio/vhost/user/device/wl.rs +++ b/devices/src/virtio/vhost/user/device/wl.rs @@ -116,8 +116,6 @@ impl VhostUserBackend for WlBackend { const MAX_QUEUE_NUM: usize = wl::QUEUE_SIZES.len(); const MAX_VRING_LEN: u16 = wl::QUEUE_SIZE; - type Error = anyhow::Error; - fn features(&self) -> u64 { self.features }