Skip to content

Commit

Permalink
feat(xtask): select microvm image automatically
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
  • Loading branch information
mkroening committed Nov 16, 2024
1 parent 37661bf commit 60c44fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ jobs:
if: matrix.target == 'x86_64'
- name: Run VM (hello_world-microvm, dev)
if: matrix.target == 'x86_64' && matrix.os == 'ubuntu-latest'
run: cargo xtask ci qemu --target ${{ matrix.target }} --image hello_world-microvm --microvm
run: cargo xtask ci qemu --target ${{ matrix.target }} --microvm
- name: Run VM (hello_world-microvm, release)
if: matrix.target == 'x86_64' && matrix.os == 'ubuntu-latest'
run: cargo xtask ci qemu --target ${{ matrix.target }} --image hello_world-microvm --microvm --release
run: cargo xtask ci qemu --target ${{ matrix.target }} --microvm --release
- name: Run VM (hello_c, dev)
if: matrix.target == 'x86_64'
run: cargo xtask ci qemu --target ${{ matrix.target }} --image hello_c
Expand Down Expand Up @@ -142,14 +142,14 @@ jobs:
- name: Run QEMU (hello_world, release)
run: cargo xtask ci qemu --target x86_64 --accel --release
- name: Run QEMU (hello_world-microvm, dev)
run: cargo xtask ci qemu --target x86_64 --accel --image hello_world-microvm --microvm
run: cargo xtask ci qemu --target x86_64 --accel --microvm
- name: Run QEMU (hello_world-microvm, release)
run: cargo xtask ci qemu --target x86_64 --accel --image hello_world-microvm --microvm --release
run: cargo xtask ci qemu --target x86_64 --accel --microvm --release
- name: Run UEFI (dev)
run: cargo xtask ci qemu --target x86_64-uefi --accel
- name: Run UEFI (release)
run: cargo xtask ci qemu --target x86_64-uefi --accel --release
- name: Run Firecracker (hello_world, dev)
run: cargo xtask ci firecracker --target x86_64-fc --features fc --image hello_world-microvm
run: cargo xtask ci firecracker --target x86_64-fc --features fc
- name: Run Firecracker (hello_world, release)
run: cargo xtask ci firecracker --target x86_64-fc --features fc --image hello_world-microvm --release
run: cargo xtask ci firecracker --target x86_64-fc --features fc --release
2 changes: 1 addition & 1 deletion xtask/src/ci/firecracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct Firecracker {
#[command(flatten)]
build: Build,

#[arg(long, default_value_t = String::from("hello_world"))]
#[arg(long, default_value_t = String::from("hello_world-microvm"))]
image: String,
}

Expand Down
24 changes: 17 additions & 7 deletions xtask/src/ci/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@ pub struct Qemu {
#[command(flatten)]
build: Build,

#[arg(long, default_value_t = String::from("hello_world"))]
image: String,
#[arg(long)]
image: Option<String>,
}

impl Qemu {
pub fn run(self) -> Result<()> {
pub fn run(mut self) -> Result<()> {
let default_image = if self.microvm {
"hello_world-microvm"
} else {
"hello_world"
};

self.image.get_or_insert_with(|| default_image.to_string());

if super::in_ci() {
eprintln!("::group::cargo build")
}
Expand All @@ -45,7 +53,7 @@ impl Qemu {
sh.create_dir("target/esp/efi/boot")?;
sh.copy_file(self.build.dist_object(), "target/esp/efi/boot/bootx64.efi")?;
sh.copy_file(
self.build.ci_image(&self.image),
self.build.ci_image(self.image.as_deref().unwrap()),
"target/esp/efi/boot/hermit-app",
)?;
}
Expand Down Expand Up @@ -128,7 +136,7 @@ impl Qemu {
cpu_args.push("-initrd".to_string());
cpu_args.push(
self.build
.ci_image(&self.image)
.ci_image(self.image.as_deref().unwrap())
.into_os_string()
.into_string()
.unwrap(),
Expand Down Expand Up @@ -168,7 +176,9 @@ impl Qemu {
cpu_args.push("-device".to_string());
cpu_args.push(format!(
"guest-loader,addr=0x48000000,initrd={}",
self.build.ci_image(&self.image).display()
self.build
.ci_image(self.image.as_deref().unwrap())
.display()
));
cpu_args
}
Expand All @@ -190,7 +200,7 @@ impl Qemu {
cpu_args.push("-initrd".to_string());
cpu_args.push(
self.build
.ci_image(&self.image)
.ci_image(self.image.as_deref().unwrap())
.into_os_string()
.into_string()
.unwrap(),
Expand Down

0 comments on commit 60c44fc

Please sign in to comment.