diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccdd7346..4b36b372 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/xtask/src/ci/firecracker.rs b/xtask/src/ci/firecracker.rs index 4ec63a6f..1e38fb2a 100644 --- a/xtask/src/ci/firecracker.rs +++ b/xtask/src/ci/firecracker.rs @@ -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, } diff --git a/xtask/src/ci/qemu.rs b/xtask/src/ci/qemu.rs index ac3bfe97..91b2aa74 100644 --- a/xtask/src/ci/qemu.rs +++ b/xtask/src/ci/qemu.rs @@ -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, } 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") } @@ -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", )?; } @@ -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(), @@ -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 } @@ -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(),