Kvm version too old

I want to build an image using make-disk-image.nix for aarch64-linux, I picked what seemed to be the simplest derivation nixos/modules/virtualisation/hyperv-image.nix just as a test, with the following simple patch:

37c37
<     system.build.hypervImage = import ../../lib/make-disk-image.nix {
---
>     system.build.hypervImage = import <nixpkgs/nixos/lib/make-disk-image.nix> {
39,42d38
<       postVM = ''
<         ${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -o subformat=dynamic -O vhdx $diskImage $out/${cfg.vmFileName}
<         rm $diskImage
<       '';
69d64
<     virtualisation.hypervGuest.enable = true;

I try to build it like nix-build --argstr system aarch64-linux '<nixpkgs/nixos>' -I nixos-config=./default.nix -A config.system.build.hypervImage --show-trace.

Eventually I get to the vm booting but then something happens:

[    1.710327] Run /init as init process
[    1.757031] EXT4-fs (vda2): mounted filesystem with ordered data mode. Opts:
[    2.080044] random: fast init done
[    5.591459] random: crng init done
[   60.658328] reboot: Restarting system
WARNING: Image format was not specified for 'nixos.raw' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
kvm version too old
.qemu-system-aarch64-wrapped: failed to initialize kvm: Function not implemented
builder for '/nix/store/4g391kv25kwh6nc5vzc66x93ri5lzy5z-nixos-hyperv-21.11pre312229.08ef0f28e3a-aarch64-linux.drv' failed with exit code 1
error: build of '/nix/store/4g391kv25kwh6nc5vzc66x93ri5lzy5z-nixos-hyperv-21.11pre312229.08ef0f28e3a-aarch64-linux.drv' failed

I have no idea what to do. I should note I am running this not on NixOS, but on Arch with Nix installed. I had to install qemu-user-static on my host os to get this far. KVM seems to work otherwise, I have been able to make and launch a VirtualBox-based guest with KVM as well as a “hello world” KVM application found on github. Any ideas?

Can confirm the issue on NixOS aswell. @tsj have you opened an issue on nixpkgs for this already?

error: builder for '/nix/store/i5r4xy3c4d1hhvi6rbmcfl0cc3zyf8qr-base-image.drv' failed with exit code 1;
       last 10 log lines:
       > [    1.908530] Run /init as init process
       > [    1.992662] EXT4-fs (vda1): mounted filesystem with ordered data mode. Opts:
       > [    2.345883] random: fast init done
       > [    9.185599] random: crng init done
       > [   82.020042] reboot: Restarting system
       > WARNING: Image format was not specified for 'nixos.raw' and probing guessed raw.
       >          Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
       >          Specify the 'raw' format explicitly to remove the restrictions.
       > kvm version too old
       > .qemu-system-aarch64-wrapped: failed to initialize kvm: Function not implemented
       For full logs, run 'nix log /nix/store/i5r4xy3c4d1hhvi6rbmcfl0cc3zyf8qr-base-image.drv'.

Hi @pinpox I never did open an issue. Go for it

Hosted by Flying Circus.