File tree 2 files changed +11
-8
lines changed
src/vmm/src/devices/virtio
2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ use utils::eventfd::EventFd;
13
13
14
14
use super :: mmio:: { VIRTIO_MMIO_INT_CONFIG , VIRTIO_MMIO_INT_VRING } ;
15
15
use super :: queue:: Queue ;
16
- use super :: ActivateError ;
16
+ use super :: { ActivateError , ResetError } ;
17
17
use crate :: devices:: virtio:: AsAny ;
18
18
use crate :: logger:: { error, warn} ;
19
19
use crate :: vstate:: memory:: GuestMemoryMmap ;
@@ -174,10 +174,9 @@ pub trait VirtioDevice: AsAny + Send {
174
174
/// Checks if the resources of this device are activated.
175
175
fn is_activated ( & self ) -> bool ;
176
176
177
- /// Optionally deactivates this device and returns ownership of the guest memory map, interrupt
178
- /// event, and queue events.
179
- fn reset ( & mut self ) -> Option < ( EventFd , Vec < EventFd > ) > {
180
- None
177
+ /// Optionally deactivates this device.
178
+ fn reset ( & mut self ) -> Result < ( ) , ResetError > {
179
+ Err ( ResetError :: NotImplemented )
181
180
}
182
181
}
183
182
Original file line number Diff line number Diff line change @@ -201,8 +201,12 @@ impl MmioTransport {
201
201
let mut device_status = self . device_status ;
202
202
let reset_result = self . locked_device ( ) . reset ( ) ;
203
203
match reset_result {
204
- Some ( ( _interrupt_evt, mut _queue_evts) ) => { }
205
- None => {
204
+ Ok ( _) => {
205
+ // The device MUST initialize device status to 0 upon reset.
206
+ device_status = INIT ;
207
+ }
208
+ Err ( e) => {
209
+ warn ! ( "failed to reset virtio device: {:?}" , e) ;
206
210
device_status |= FAILED ;
207
211
}
208
212
}
@@ -469,7 +473,7 @@ pub(crate) mod tests {
469
473
let m = single_region_mem ( 0x1000 ) ;
470
474
let mut dummy = DummyDevice :: new ( ) ;
471
475
// Validate reset is no-op.
472
- assert ! ( dummy. reset( ) . is_none ( ) ) ;
476
+ assert ! ( dummy. reset( ) . is_err ( ) ) ;
473
477
let mut d = MmioTransport :: new ( m, Arc :: new ( Mutex :: new ( dummy) ) , false ) ;
474
478
475
479
// We just make sure here that the implementation of a mmio device behaves as we expect,
You can’t perform that action at this time.
0 commit comments