-
Notifications
You must be signed in to change notification settings - Fork 28
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
memory-model design discussion #16
Comments
Hi all,
So we can’t simply replace u64 with usize. With the introduction of the AddressSpace abstraction, the proposal to solve this conflict is: Thanks, |
This review is based on commit ab37cf3324310b074869680b3a471ca436f51a68 at jiangliu/memory-model. A memory model crate is certainly a very good starting point for rust-vmm, but it shouldn't include the implementation of the backend. Instead, for rust-vmm we should focus on defining common traits that can be used by any VMM. In this light, GuestMemory is composed of two parts that are completely independent. The first is a way to convert a GuestAddress to a MemoryMapping and an offset, which can be a very simple MemoryMap trait:
This can be implemented with linear lookup as is currently the case in firecracker, or it could use a binary search or a radix tree. rust-vmm shouldn't care. It should only define the trait so that (for example) virtio crates can receive a MemoryMap and access it. The second part is the convenience API to access memory as slices/streams/objects. This part of the API is actually shared by MemoryMapping and GuestMemory:
... though sometimes the methods have different names:
This API should be a trait that is implemented by both
(Alternatively, the offset type could be an associated type. Opinions are welcome from people more familiar with Rust API design, but I think it's better to have it as an argument so that The
On the other hand, I am very positive that
No objections from me of course on other parts of the crate, for example |
@bonzini |
Right, which in my description are
Yes. More precisely memory-model should provide the traits for all three layers. It turns out that:
As you say it's not just QEMU and Firecracker, vhost-user crates should also be able to use
Sure. Hopefully the changes to crosvm and firecracker amount to little more than search-and-replace. |
@alexandruag @dhrgit can you also take a look at this? |
One issue regarding testing: even if we can have a reference implementation in a different “example” crate, or we need an implementation of the traits to test the whole thing. What does everyone think of implementing |
Hi everyone, Apologies for joining the discussion so late. I really like @bonzini's point of view; it makes sense to have The implementation of If pub trait GuestMemoryRegion<T>: Bytes<T> {
fn host_address(&self) -> usize;
fn guest_address(&self) -> usize;
fn size(&self) -> usize;
} I used Speaking of regions, what do you think about having some sort of slice (or view if you will) analogue for The At this point I guess the next step is having some sort of initial version/proposal for the complete interface. Thanks for taking the time to read all of this! |
How about rethink about the AddressSpace abstraction? |
I suppose it is sound because all reads/writes are for types that are Regarding GuestMemoryRegion, instead I think that |
Hi all, |
Thanks! Let's move the discussion there. @andreeaflorescu can you close this one? |
No description provided.
The text was updated successfully, but these errors were encountered: