The purpose of this gist is to get a discussion started about what the Firecracker team can contribute to crosvm.
This comparison is based on the following commits:
- crosvm commit 7df5a0ef1a23542b0cc7db7797b8b287eaa05699
- Firecracker commit d6861f91acc13868cac4cde94cbce21d9cb5e833
This comparison only touches the common crates of Firecracker and crosvm.
In Firecracker we unified the kernel_loader and kernel_cmdline crates in one crate with two modules:
- loader - corresponds to kernel_loader in crosvm
- cmdline - corresponds to kernel_cmdline in crosvm
- added derive clone to the Cmdline structure
- in the constructor, we use the capacity to initialize the string as advertised by the doc string.
- Removed unnecessary defines from elf.rs. This file was originally generated with bindgen from linux “include/uapi/linux/elf.h” file.
- Added an extra sanity check for e_entry, which is required to be < the high memory start.
- The load_kernel function returns the entry address of the kernel.
- load_kernel function has a new parameter in the signature: kernel_start. The parameter is used for computing the guest memory offset.
The unit tests are also changed a bit.
- kernel_loader: e_entry sanity check
- kernel_loader: stripped down version of the elf.rs file
- kernel_cmdline: initialize the cmdline string with the capacity specified in the function signature.
In Firecracker we moved all the memory related utilities in the memory_model crate. Initially this crate was the same as the data_model crate from crosvm.
We moved the following files from sys_util to memory_model: guest_address.rs, guest_memory.rs, mmap.rs.
- The GuestAddress is represented as usize instead of u64.
- Added more unit tests
- Added map and fold function for memory regions. This is a helper function for counting the guest dirty pages.
- Added immutable version of the with_regions function.
- Use overflowing_add() to validate requested address range and avoid panicking at runtime.
- Function for getting the memory size (we should also do this instead of making the MemoryRegion a public structure).
- Function for madvising an adress range
- Implementation for Volatile Memory.
- When initializing the memory, use madvise MADV_DONTDUMP, which specifies that the memory regions should be excluded from a core dump.
- split from_fd in 2 functions: from_fd and from_fd_offset.
- function for removing memory region (using madvise).
- volatile memory support.
- Overflow add in mmap.rs
- Others?.
In Firecracker all generated files are in _gen crates. KVM bindings are generated from the kernel version 4.13. In Crosvm, the autogenerated files are in _sys crates. The implementation of the kvm wrappers seems to have divereged, so I am just going to highlight some things that might be useful to contribute back.
- Added get_api_version
- Updated
check_extension
to return true for KVM_CHECK_EXTENSION >=1 as per KVM documentation (before it was == 1). - Others?