-
Notifications
You must be signed in to change notification settings - Fork 113
Add GuestMemory method to return an Iterator #9
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
Conversation
alexandruag
left a comment
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.
Looks good to me! I have some comments on error handling for GuestMemory in general, but I'll put those in the comment PR/RFC I'm still trying to write :(
bonzini
left a comment
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.
Is this needed, or is it just a cleanup? Even if it is only used by mmap-related code, it can be useful in general.
bonzini
left a comment
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.
Can you also look into removing map_and_fold(), and replacing it with iter()?
|
Just a cleanup, so I will remove it from the patch set.
… On Apr 3, 2019, at 1:29 AM, Paolo Bonzini ***@***.*** ***@***.***>> wrote:
@bonzini commented on this pull request.
Is this needed, or is it just a cleanup? Even if it is only used by mmap-related code, it can be useful in general.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#9 (review)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AB14_Jy-Vg5E8PLk5T9wDRz_6dJVRl8Wks5vc5OXgaJpZM4cUVYs>.
|
|
Nice! Can you add some comments explaining the reason for the PhantomData? |
Signed-off-by: Liu Jiang <[email protected]>
|
Hey people, I placed my initial attempt at converting firecracker at https://github.com/bonzini/firecracker branch master. A more sensible way to do it would be to split like:
The vm-memory is not properly vendored, it's hacked to add the mmap feature to Cargo.toml. And so on... still if it saves you a couple hours, all for the best. |
|
Hey @bonzini, thanks. I will open an issue in the Firecracker repository to switch to vm-memory and link the commit from your fork. We will wait for the vm-memory to be published to crates.io before using it. Before doing the switch we want to make sure we have good code coverage and the necessary mechanisms in place to ensure that future PRs won't decrease it. I will open issues in vm-memory for the other things that I'll find. |
Add an iterator interface to the GuestMemory trait, so the with_regions() and with_regions_mut() methods could be removed later. Signed-off-by: Liu Jiang <[email protected]>
Now we have iterator for the GuestMemory trait, so remove with_regions(), with_regions_mut() and map_and_fold(). Signed-off-by: Liu Jiang <[email protected]>
|
I have tried to migrate the vhost crate in firecracker to the vm-memory crate, it works with one more patch upon this PR. |
|
@jiangliu we are currently trying to move away from vhost. See this RFC with the design doc: firecracker-microvm/firecracker#1044 |
|
Thanks @andreeaflorescu , happy to see the progress on support of vsock. I will keep current firecracker's vsock implementation as an example:) |
Some guest memory consumers, such as in-kernel vhost driver, boot loader etc, need to access the guest memory by pointers. So add method get_host_address() to the GuestMemory and GuestMemoryRegion traits, otherwise those guest memory consumers will explicitly depend on the GuestMemoryMmap struct. Signed-off-by: Liu Jiang <[email protected]>
Enhance the GuestMemory trait to support Clone, so guest memory consumers could hold a local guest memory object by calling guest_memory.clone(). Signed-off-by: Liu Jiang <[email protected]>
|
@jiangliu what is the status here? Do we still want to merge this one? |
| } | ||
|
|
||
| impl GuestMemoryRegion for GuestRegionMmap { | ||
| const DIRECT_ACCESS: bool = true; |
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.
Why is DIRECT_ACCESS useful?
| /// Convert an absolute address in an address space (GuestMemory) to a host pointer, | ||
| /// or return None if it is out of bounds. It always returns None when `DIRECT_ACCESS` is false. | ||
| /// The returned pointer may be used for ioctls etc. | ||
| fn get_host_address(&self, addr: MemoryRegionAddress) -> Option<*mut u8>; |
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.
This can be implemented in terms of as_mut_slice(). Also please make the result Option<NonNull<u8>>.
Hi Paolo, |
|
Agreed. |
Fix #8