Skip to content

Conversation

lovesegfault
Copy link
Member

Motivation

I had a host with the kvm system-feature enabled, but no /dev/kvm available and it was causing VM tests to be extremely slow. It took me a minute to figure out that the host didn't have KVM, and that qemu was falling back to emulation. I figured it'd be nice to warn in this scenario.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@edolstra
Copy link
Member

I think the real issue here is that system-features shouldn't contain kvm if /dev/kvm doesn't exist. Nix does that correctly (see Settings::getDefaultSystemFeatures()) but NixOS sets it by default in nix.conf.

@lovesegfault
Copy link
Member Author

@edolstra this wasn't on a NixOS system at all, but rather a (ubuntu) container image with Nix that had KVM enabled in the config, but was deployed to a host without virtualization support.

I don't think it's bad that you can enable kvm on a host without it and let qemu fallback to emulation, it's handy if you don't have a host with KVM available, but doing it silently is just a bit surprising.

@Mic92
Copy link
Member

Mic92 commented Aug 29, 2025

@edolstra this wasn't on a NixOS system at all, but rather a (ubuntu) container image with Nix that had KVM enabled in the config, but was deployed to a host without virtualization support.

I don't think it's bad that you can enable kvm on a host without it and let qemu fallback to emulation, it's handy if you don't have a host with KVM available, but doing it silently is just a bit surprising.

Sounds reasonable to me.

@edolstra
Copy link
Member

I don't think it's bad that you can enable kvm on a host without it and let qemu fallback to emulation, it's handy if you don't have a host with KVM available, but doing it silently is just a bit surprising.

You can still manually add it to system-features, it just shouldn't be the default. That defeats the purpose of the kvm system feature.

@Mic92
Copy link
Member

Mic92 commented Aug 29, 2025

I don't think it's bad that you can enable kvm on a host without it and let qemu fallback to emulation, it's handy if you don't have a host with KVM available, but doing it silently is just a bit surprising.

You can still manually add it to system-features, it just shouldn't be the default. That defeats the purpose of the kvm system feature.

Ok. This is fair, but is this not somewhat orthogonal to having this warning if someone misconfigures their nix?

@Ericson2314
Copy link
Member

Are people using kvm in Nixpkgs to control whether to use QEMU at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants