File tree Expand file tree Collapse file tree 6 files changed +33
-39
lines changed
src/vmm/src/devices/virtio Expand file tree Collapse file tree 6 files changed +33
-39
lines changed Original file line number Diff line number Diff line change @@ -948,16 +948,16 @@ impl VirtioDevice for Balloon {
948948 }
949949
950950 fn kick ( & mut self ) {
951- // If device is activated, kick the balloon queue(s) to make up for any
952- // pending or in-flight epoll events we may have not captured in snapshot.
953- // Stats queue doesn't need kicking as it is notified via a `timer_fd`.
954951 if self . is_activated ( ) {
955- info ! ( "kick balloon {}." , self . id( ) ) ;
956952 if self . free_page_hinting ( ) {
957- // On restore we reset back to DONE to ensure everythign is freed
953+ info ! (
954+ "[{:?}:{}] resetting free page hinting to DONE" ,
955+ self . device_type( ) ,
956+ self . id( )
957+ ) ;
958958 self . update_free_page_hint_cmd ( FREE_PAGE_HINT_DONE ) ;
959959 }
960- self . process_virtio_queues ( ) ;
960+ self . notify_queue_events ( ) ;
961961 }
962962 }
963963}
Original file line number Diff line number Diff line change @@ -214,18 +214,6 @@ impl VirtioDevice for Block {
214214 Self :: VhostUser ( b) => b. device_state . is_activated ( ) ,
215215 }
216216 }
217-
218- fn kick ( & mut self ) {
219- // If device is activated, kick the block queue(s) to make up for any
220- // pending or in-flight epoll events we may have not captured in
221- // snapshot. No need to kick Ratelimiters
222- // because they are restored 'unblocked' so
223- // any inflight `timer_fd` events can be safely discarded.
224- if self . is_activated ( ) {
225- info ! ( "kick block {}." , self . id( ) ) ;
226- self . process_virtio_queues ( ) ;
227- }
228- }
229217}
230218
231219impl MutEventSubscriber for Block {
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ use super::queue::{Queue, QueueError};
1717use super :: transport:: VirtioInterrupt ;
1818use crate :: devices:: virtio:: AsAny ;
1919use crate :: devices:: virtio:: generated:: virtio_ids;
20- use crate :: logger:: warn;
20+ use crate :: logger:: { error , info , warn} ;
2121use crate :: vstate:: memory:: GuestMemoryMmap ;
2222
2323/// State of an active VirtIO device
@@ -188,8 +188,28 @@ pub trait VirtioDevice: AsAny + Send {
188188 Ok ( ( ) )
189189 }
190190
191+ /// Notify all queues by writing to the eventfds.
192+ fn notify_queue_events ( & mut self ) {
193+ info ! ( "[{:?}:{}] notifying queues" , self . device_type( ) , self . id( ) ) ;
194+ for ( i, eventfd) in self . queue_events ( ) . iter ( ) . enumerate ( ) {
195+ if let Err ( err) = eventfd. write ( 1 ) {
196+ error ! (
197+ "[{:?}:{}] error notifying queue {}: {}" ,
198+ self . device_type( ) ,
199+ self . id( ) ,
200+ i,
201+ err
202+ ) ;
203+ }
204+ }
205+ }
206+
191207 /// Kick the device, as if it had received external events.
192- fn kick ( & mut self ) { }
208+ fn kick ( & mut self ) {
209+ if self . is_activated ( ) {
210+ self . notify_queue_events ( ) ;
211+ }
212+ }
193213}
194214
195215impl fmt:: Debug for dyn VirtioDevice {
Original file line number Diff line number Diff line change @@ -1056,17 +1056,6 @@ impl VirtioDevice for Net {
10561056 fn is_activated ( & self ) -> bool {
10571057 self . device_state . is_activated ( )
10581058 }
1059-
1060- fn kick ( & mut self ) {
1061- // If device is activated, kick the net queue(s) to make up for any
1062- // pending or in-flight epoll events we may have not captured in snapshot.
1063- // No need to kick Ratelimiters because they are restored 'unblocked' so
1064- // any inflight `timer_fd` events can be safely discarded.
1065- if self . is_activated ( ) {
1066- info ! ( "kick net {}." , self . id( ) ) ;
1067- self . process_virtio_queues ( ) ;
1068- }
1069- }
10701059}
10711060
10721061#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -312,13 +312,6 @@ impl VirtioDevice for Entropy {
312312 self . device_state = DeviceState :: Activated ( ActiveState { mem, interrupt } ) ;
313313 Ok ( ( ) )
314314 }
315-
316- fn kick ( & mut self ) {
317- if self . is_activated ( ) {
318- info ! ( "kick entropy {}." , self . id( ) ) ;
319- self . process_virtio_queues ( ) ;
320- }
321- }
322315}
323316
324317#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -385,7 +385,11 @@ where
385385 // The only reason we still `kick` it is to make guest process
386386 // `TRANSPORT_RESET_EVENT` event we sent during snapshot creation.
387387 if self . is_activated ( ) {
388- info ! ( "kick vsock {}." , self . id( ) ) ;
388+ info ! (
389+ "[{:?}:{}] signaling event queue" ,
390+ self . device_type( ) ,
391+ self . id( )
392+ ) ;
389393 self . signal_used_queue ( EVQ_INDEX ) . unwrap ( ) ;
390394 }
391395 }
You can’t perform that action at this time.
0 commit comments