-
Notifications
You must be signed in to change notification settings - Fork 1
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
Linux VM builder refactor #46
Conversation
bd49d34
to
b9ba7b4
Compare
f5de9a1
to
f6adc73
Compare
@@ -0,0 +1,187 @@ | |||
//! Core interfaces for builders. |
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.
❤️
} | ||
|
||
impl Mbr { | ||
pub const DISK_SIGNATURE: [u8; 4] = [b'G', b'V', b'L', b'T']; |
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.
Love it
cfa2432
to
e8824e3
Compare
Also added new options: --fuse, --from-scratch, --generate-base-image
Unfortunatelly this increases gvltctl executable size by ~9MB.
This will be triggered only manually for now because building kernel takes a lot of time.
Co-authored-by: Tino Rusch <[email protected]>
e8824e3
to
ffdd52f
Compare
Update on CII've added a proper workflow for testing VM builder (works with
(Sorry for force-pushing, I messed up merging master somehow) |
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.
Given we clear out the licensing question, otherwise this looks very good to me 🙌
|
||
- name: Update APT packages | ||
run: |- | ||
sudo apt-get update |
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 the intention here to only prepare for later package installations or actually upgrade all packages? apt-get update
only updates the package index. apt-get upgrade
upgrades packages themselves 🙂
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.
Yep, just preparing for future installations.
src/builders_v2/linux_vm/extlinux.rs
Outdated
/// This boot code is copied from extlinux 6.04. | ||
const BOOTCODE: &[u8; 440] = include_bytes!(concat!( | ||
env!("CARGO_MANIFEST_DIR"), | ||
"/src/builders_v2/linux_vm/data/extlinux/mbr.bin" | ||
)); | ||
|
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.
Hmm... This is slightly in grey area. After a quick peek, it seems that the syslinux/extlinux and it's mbr are under GPL. When embedding pre-compiled binary inside a binary, does it count as redistribution or linking (legally)? At least the copyright and license should probably be present somewhere.
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.
Tbh I have absolutely no idea what we should do here :) Does it mean that we have to include GPL to our repo?
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 include is removed in the following commits.
Read bootcode file from EXTLINUX locations instead, or use --mbr-file option.
This PR contains a big Linux VM builder refactor.
Motivation
sudo
--size
)extlinux
installedChanges
Most of the code is located in
src/builders_v2
. Most of commits are representing a single entity addition to new builder.Code structure
core.rs
- implements pipeline and context logic for builder.linux_vm/mod.rs
- is the main entrypoint for Linux VM builder. Pipeline steps are configured there. Build options are also defined there.linux_vm/*.rs
- other modules. Each module contains helping data types (normally they will be stored in Context) and Step implementations. Most of the step implementations are dramatically reworked from olderSkopeoSyslinuxBuilder
.linux_vm/data
- contains some auxiliary data for builder, which will be baked intogvltctl
executable.Changes overview
sudo
for mounting!). R.n. it is enabled with--fuse
option, however in the future this should be the default behavior and this option will be replaced with--no-fuse
.linux_vm/resize.rs
). However--size
option is still available to overwrite this behavior.This doesn't boost performance a lot, however eliminates the need of EXTLINUX for user. To create an image from scratch added
--from-scratch
option. This will require root however, because EXTLINUX installation doesn't support FUSE filesystems. So using--from-scratch
is almost the same asSkopeoSyslinuxBuilder
.--generate-base-image
option.FileSystemHandler
trait allows to add other filesystems (EXT3 or else). Same withMountHandler
trait. The same is possible for partition table handling, but for now I use only MBR.mbrman
crate. MBR limits our filesystem size and in the future we will probably need to change it. However I haven't find a nice read-write API for GPT in Rust.Notes
vm-builder-v2
. To use new builder, compilegvltctl
with this feature enabled. Without this feature everything is working as it was before.Example
Simple VM test is added to
tests/vm_builder/simple_vm
. You can install required runtime dependencies (described in README) and run it:cargo build --features vm-builder-v2 cd tests/vm_builder/simple_vm ../../../target/debug/gvltctl build -f ./Containerfile --fuse --no-gevulot-runtime qemu-system-x86_64 -machine q35 -enable-kvm -nographic --hda disk.img
You should see "Hello world" printed by main application in the VM.
Future work