Skip to content

Commit

Permalink
qemu: Fix cross-compilation
Browse files Browse the repository at this point in the history
Use microvmConfig.cpu == null to check whether we should be doing
virtualization with KVM or emulation of the CPU, instead of checking
pkgs.buildPlatform == pkgs.hostPlatform. The latter kind of check causes
microvm not start, if the system running microvms has been
cross-compiled for example from x86_64-linux to aarch64-linux.

Signed-off-by: Mika Tammi <[email protected]>
  • Loading branch information
Mika Tammi authored and astro committed Dec 30, 2023
1 parent c39a472 commit b1bb1db
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/runners/qemu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ let
++ lib.optional microvmConfig.optimize.enable minimizeQemuClosureSize
);

qemu = overrideQemu (if pkgs.buildPlatform == pkgs.hostPlatform then
pkgs.buildPackages.qemu_kvm else pkgs.buildPackages.qemu_full);
qemu = overrideQemu (if microvmConfig.cpu == null then
pkgs.qemu_kvm else pkgs.buildPackages.qemu_full);

inherit (microvmConfig) hostName cpu vcpu mem balloonMem user interfaces shares socket forwardPorts devices vsock graphics storeOnDisk kernel initrdPath storeDisk;
inherit (microvmConfig.qemu) extraArgs;
Expand All @@ -62,7 +62,7 @@ let
) ];

accel =
if pkgs.buildPlatform == pkgs.hostPlatform
if microvmConfig.cpu == null
then "accel=kvm:tcg"
else "accel=tcg";

Expand Down Expand Up @@ -143,7 +143,7 @@ in {
"-serial" "chardev:stdio"
"-device" "virtio-rng-${devType}"
] ++
lib.optionals (pkgs.buildPlatform == pkgs.hostPlatform) [
lib.optionals (microvmConfig.cpu == null) [
"-enable-kvm"
] ++
cpuArgs ++
Expand Down

0 comments on commit b1bb1db

Please sign in to comment.