@@ -15,14 +15,22 @@ use vhost::vhost_user::message::{
1515 VhostUserSingleMemoryRegion , VhostUserVirtioFeatures , VhostUserVringAddrFlags ,
1616 VhostUserVringState ,
1717} ;
18- use vhost:: vhost_user:: { Error as VhostUserError , Result as VhostUserResult , SlaveFsCacheReq } ;
18+ use vhost:: vhost_user:: {
19+ Error as VhostUserError , Result as VhostUserResult , SlaveFsCacheReq ,
20+ VhostUserSlaveReqHandlerMut ,
21+ } ;
1922use virtio_bindings:: bindings:: virtio_ring:: VIRTIO_RING_F_EVENT_IDX ;
2023use vm_memory:: bitmap:: Bitmap ;
2124use vm_memory:: mmap:: NewBitmap ;
22- use vm_memory:: { FileOffset , GuestAddress , GuestMemoryMmap , GuestRegionMmap } ;
25+ use vm_memory:: {
26+ FileOffset , GuestAddress , GuestAddressSpace , GuestMemoryMmap , GuestRegionMmap , MmapRegion ,
27+ } ;
2328
29+ use super :: backend:: VhostUserBackend ;
30+ use super :: event_loop:: VringEpollHandler ;
2431use super :: event_loop:: { VringEpollError , VringEpollResult } ;
25- use super :: * ;
32+ use super :: vring:: { VringRwLock , VringT } ;
33+ use super :: GM ;
2634
2735const MAX_MEM_SLOTS : u64 = 32 ;
2836
@@ -74,7 +82,7 @@ pub struct VhostUserHandler<S: VhostUserBackend<B>, B: Bitmap + 'static> {
7482 queues_per_thread : Vec < u64 > ,
7583 mappings : Vec < AddrMapping > ,
7684 atomic_mem : GM < B > ,
77- vrings : Vec < Vring < GM < B > > > ,
85+ vrings : Vec < VringRwLock < GM < B > > > ,
7886 worker_threads : Vec < thread:: JoinHandle < VringEpollResult < ( ) > > > ,
7987}
8088
@@ -86,7 +94,7 @@ impl<S: VhostUserBackend<B> + Clone, B: Bitmap + Clone + Send + Sync> VhostUserH
8694
8795 let mut vrings = Vec :: new ( ) ;
8896 for _ in 0 ..num_queues {
89- let vring = Vring :: new ( atomic_mem. clone ( ) , max_queue_size as u16 ) ;
97+ let vring = VringRwLock :: new ( atomic_mem. clone ( ) , max_queue_size as u16 ) ;
9098 vrings. push ( vring) ;
9199 }
92100
@@ -194,7 +202,7 @@ impl<S: VhostUserBackend<B>, B: NewBitmap + Clone> VhostUserSlaveReqHandlerMut
194202 // been disabled by VHOST_USER_SET_VRING_ENABLE with parameter 0.
195203 let vring_enabled =
196204 self . acked_features & VhostUserVirtioFeatures :: PROTOCOL_FEATURES . bits ( ) == 0 ;
197- for vring in self . vrings . iter ( ) {
205+ for vring in self . vrings . iter_mut ( ) {
198206 vring. set_enabled ( vring_enabled) ;
199207 }
200208
0 commit comments