-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Merge feature/uffd into main #2980
Merged
Merged
Conversation
This file contains 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
Memory::restore now takes an optional &File and creates file-backed memory or anonymous memory depending on the option. Signed-off-by: Adrian Catangiu <[email protected]>
Deprecate 'mem_file_path' field and add a new 'mem_backend' optional object. At least one of 'mem_file_path' and `mem_backend` fields are required and it is forbidden to specify both at the same time. `mem_backend` object contains: - 'backend_type': required String parameter that can take either: - File - Uffd as valid values. - 'backend_path': required String parameter. Interpretation of this field depends on the value of 'backend_type': - Path to file that contains the guest memory to be loaded if type is 'File', - Path to UDS where a custom page-fault handler process is listening and expecting a Uffd to be sent by Firecracker. The Uffd is used to handle Firecracker's guest memory page faults in this separate process. If `mem_file_path` is specified instead of `mem_backend`, we construct the `MemBackendConfig` object from the path specified, through `mem_file_path`, with `File` as backend type. Add plumbing for the new API, the Uffd path is only a stub for now. Signed-off-by: Adrian Catangiu <[email protected]> Signed-off-by: Luminita Voicu <[email protected]>
When /snapshot/load specifies memory backend type as 'UffdOverUDS', Firecracker doesn't handle the memory file itself anymore and expects an external process to handle its guest memory page faults. To do this, anonymous memory is mmapped as guest memory while keeping the original memory regions shape. Then a Uffd is created and each guest memory range is registered with the Uffd so that any page faults won't be handled by the kernel, but will come up as events on the Uffd. Firecracker then sends the memory ranges descriptions/mappings along with the Uffd over a UnixDomainSocket specified in 'mem_backend_path' parameter on the API call. It is expected that on the other side there is already a process listening for incoming connections. Once Firecracker's connection is accepted, Firecracker sends the mappings and Uffd. The receiving process is from now responsible for handling any pagefaults on the Uffd. The communication medium is a UDS, the protocol is SOCK_STREAM and the encoding is JSON. Signed-off-by: Adrian Catangiu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]> Signed-off-by: Diana Popa <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
The page fault handler process requires FC's PID in order to be able to notify FC of any crashes/exists. The way we initially intended to make the handler process aware of FC's PID was to have FC sent its PID explicitly through the UDS. But there is a problem with this approach: Firecracker's PID depends on the way the process was started. When normally started through the jailer, Firecracker will see its global PID. However, if using `--new-pid-ns` flag when running the jailer, the jailer will spawn FC in a new PID namespace, which would cause Firecracker to not be aware of its PID and see it as being 1. Moreover, when not using `--new-pid-ns` flag, we recommend to the users to spawn the jailer process into a new PID namespace when starting it. This is why sending FC's PID from whithin the FC process is not reliable. To tackle this, we no longer send FC's PID explicitly, but advise the page fault handler process to use `getsockopt` call with `SO_PEERCRED` option in order to fetch the global Firecracker PID at the moment of connecting. Signed-off-by: Luminita Voicu <[email protected]>
The feature will get enabled only when the microVM uses a balloon device. Signed-off-by: Diana Popa <[email protected]>
Signed-off-by: Diana Popa <[email protected]> CI: enable uffd testing when building from snapshot Signed-off-by: Diana Popa <[email protected]> Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Diana Popa <[email protected]> Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Diana Popa <[email protected]> Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Diana Popa <[email protected]> Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Diana Popa <[email protected]> Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Diana Popa <[email protected]> Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
The PUT snapshot/load `mem_file_path` field is under the deprecation policy. Check for the presence of deprecation header in the response when using it. Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
Signed-off-by: Luminita Voicu <[email protected]>
alindima
approved these changes
Apr 28, 2022
dianpopa
approved these changes
Apr 28, 2022
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.
Reason for This PR
merge feature/uffd into main
rust-vmm
.License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
PR Checklist
[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]
git commit -s
).unsafe
code is properly documented.CHANGELOG.md
.