From b29edfbee82c203ac8db1427bc2274c31e7572d5 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 1 May 2024 09:24:48 +0100 Subject: [PATCH] net_util: Replace specific bitmap implementation with trait Replace the specific Bitmap implementation from the type signature used for functions that take memory. This allows more flexibility when using these functions in particular when these functions are used by the vhost-user-net backend. An updated vhost-user-backend crate requires extra constraints on the Bitmap implementation used (it must support BitmapReplace which AtomicBitmap does not.) Signed-off-by: Rob Bradford --- net_util/src/queue_pair.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/net_util/src/queue_pair.rs b/net_util/src/queue_pair.rs index 231a735b8..d6ff0fd9e 100644 --- a/net_util/src/queue_pair.rs +++ b/net_util/src/queue_pair.rs @@ -3,7 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause use super::{register_listener, unregister_listener, vnet_hdr_len, Tap}; -use crate::GuestMemoryMmap; use rate_limiter::{RateLimiter, TokenType}; use std::io; use std::num::Wrapping; @@ -12,6 +11,7 @@ use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Arc; use thiserror::Error; use virtio_queue::{Queue, QueueOwnedT, QueueT}; +use vm_memory::bitmap::Bitmap; use vm_memory::{Bytes, GuestMemory}; use vm_virtio::{AccessPlatform, Translatable}; @@ -35,9 +35,9 @@ impl TxVirtio { } } - pub fn process_desc_chain( + pub fn process_desc_chain( &mut self, - mem: &GuestMemoryMmap, + mem: &vm_memory::GuestMemoryMmap, tap: &Tap, queue: &mut Queue, rate_limiter: &mut Option, @@ -161,9 +161,9 @@ impl RxVirtio { } } - pub fn process_desc_chain( + pub fn process_desc_chain( &mut self, - mem: &GuestMemoryMmap, + mem: &vm_memory::GuestMemoryMmap, tap: &Tap, queue: &mut Queue, rate_limiter: &mut Option, @@ -350,9 +350,9 @@ pub struct NetQueuePair { } impl NetQueuePair { - pub fn process_tx( + pub fn process_tx( &mut self, - mem: &GuestMemoryMmap, + mem: &vm_memory::GuestMemoryMmap, queue: &mut Queue, ) -> Result { let tx_tap_retry = self.tx.process_desc_chain( @@ -400,9 +400,9 @@ impl NetQueuePair { .map_err(NetQueuePairError::QueueNeedsNotification) } - pub fn process_rx( + pub fn process_rx( &mut self, - mem: &GuestMemoryMmap, + mem: &vm_memory::GuestMemoryMmap, queue: &mut Queue, ) -> Result { self.rx_desc_avail = !self.rx.process_desc_chain(