Add FwCfg::iter_files#3
Merged
Merged
Conversation
The fw_cfg device is a shared resource: there’s only one per QEMU guest. And it is stateful: when happens when accessing an I/O port depends on previous accesses. This means that concurrent access would behave incorectly (though probably not cause memory unsafety, as long as DMA is not used). To fix this, require of users (through `unsafe fn new`) to only have one `FwCfg` value at a time, and change methods to take `&mut self` instead of `&self`. This is a breaking API change, update the version number accordingly.
The name string is now kept in a byte buffer inside `FwCfgFile` instead of externally and referenced through that lifetime. Upside: * Manipulating values of this type is now more flexible, since we don’t need to manage name string buffers separately. Downsides: * The type is bigger: from 16 bytes on 32-bit targets to 64 bytes * Calling `.name()` repeatedly will iterate bytes repeatedly to find the null terminator, instead of only once was `FwCfgFile` is first created.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This involves breaking API changes:
FwCfgFilewas removed. Having files own the buffer for their name makesiter_fileseasier (which would otherwise need scratch space for names or something like that).FwCfgmethods were changed to take&mut selfsince they rely on a global shared resource. (For example interleaving two iterations would give incorrect results.)