-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Support reset for net device
#4389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
fefe31c
4419bb8
88512b9
71c2a07
ff9dc0d
d178d20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,8 +204,12 @@ impl MmioTransport { | |
| let mut device_status = self.device_status; | ||
| let reset_result = self.locked_device().reset(); | ||
| match reset_result { | ||
| Some((_interrupt_evt, mut _queue_evts)) => {} | ||
| None => { | ||
| Ok(_) => { | ||
| // The device MUST initialize device status to 0 upon reset. | ||
| device_status = INIT; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: I'd actually use 0 here as per the spec. The |
||
| } | ||
| Err(e) => { | ||
| warn!("failed to reset virtio device: {:?}", e); | ||
| device_status |= FAILED; | ||
| } | ||
| } | ||
|
|
@@ -471,7 +475,7 @@ pub(crate) mod tests { | |
| let m = single_region_mem(0x1000); | ||
| let mut dummy = DummyDevice::new(); | ||
| // Validate reset is no-op. | ||
| assert!(dummy.reset().is_none()); | ||
| assert!(dummy.reset().is_err()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd check for the exact error code here |
||
| let mut d = MmioTransport::new(m, Arc::new(Mutex::new(dummy)), false); | ||
|
|
||
| // We just make sure here that the implementation of a mmio device behaves as we expect, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,13 @@ pub enum ActivateError { | |
| QueueMemoryError(QueueError), | ||
| } | ||
|
|
||
| // Errors triggered when resetting a VirtioDevice. | ||
| #[derive(Debug, thiserror::Error, displaydoc::Display)] | ||
| pub enum ResetError { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd merge this with the second patch where the error code is actually used |
||
| /// Reset is not implemented for the device. | ||
| NotImplemented, | ||
| } | ||
|
|
||
| /// Trait that helps in upcasting an object to Any | ||
| pub trait AsAny { | ||
| /// Return the immutable any encapsulated object. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's what I had in mind honestly. I assume the initial idea of giving back the
EventFds was to "ensure" through the type system that they can't be used, but that is a very dubious choice, IMHO.