-
Notifications
You must be signed in to change notification settings - Fork 27
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
Crate Addition Request: arch #41
Comments
I think this looks pretty good. Those that wish for dynamic dispatch can use the dynamic trait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Crate Name
arch
(currently) orvmm-arch
(to relate back to the rust-vmm project)Short Description
A crate to provide a hypervisor-agnostic interface to the existing
arch
crate currently used by crosvm/Firecracker, and parts of which are used in libwhp.Why is this crate relevant to the rust-vmm project?
The functionality provided by the
arch
crate is shared across multiple projects (Firecracker and crosvm), but currently uses KVM primitives and APIs directly. libwhp (using Hyper-V) uses a small portion of the logic but ports it to Hyper-V. A hypervisor-agnostic solution would allow the same crate to be used across projects regardless of hypervisor.Design
The proposed
arch
crate relies on the abstraction of the VCPU to achieve hypervisor-agnosticism without sacrificing performance due to hypervisor-specific primitives.When a hypervisor-agnostic
arch
crate was was initially proposed in the rust-vmm biweekly meeting, there was some concern expressed about actually losing KVM primitives in the abstraction, which could result in an unacceptable performance loss for Firecracker/crosvm. In practice, the KVM-specific primitives in the existing crate rely on direct operations on the KVM VcpuFd. Our design allows the continued use of these specific primitives by abstracting out the Vcpu functionality (as proposed in [link to Vcpu proposal]), altering the APIs to accept the Vcpu trait generic as an input parameter instead of the directly taking the data structure. And with Rust's compilation performing static dispatch, the abstraction has "zero cost".Proposed Vcpu trait definition (proposed here):
Example function from the existing
arch
crate(Taking a
VcpuFd
reference as an input parameter):Refactor of function consuming the trait as a generic:
And code calling the arch function just calls it as normal, minimizing refactoring:
The text was updated successfully, but these errors were encountered: