qemu, runInLinuxVM: fix KVM availability check

KVM should only be considered abailable if /dev/kvm exists and
is read-writable by the user that is trying to launch it.

The previous check for existance only had the consequence that
on some Linux distributions running VMs with Nix's QEMU only worked
if KVM was NOT installed.

fixes #124371
This commit is contained in:
Martin Schwaighofer 2021-06-06 12:45:40 +02:00 committed by Alyssa Ross
parent f57e1a4dab
commit 5d06f6933d

View File

@ -231,7 +231,7 @@ stdenv.mkDerivation rec {
if [ -x $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} ]; then
makeWrapper $out/bin/qemu-system-${stdenv.hostPlatform.qemuArch} \
$out/bin/qemu-kvm \
--add-flags "\$([ -e /dev/kvm ] && echo -enable-kvm)"
--add-flags "\$([ -r /dev/kvm -a -w /dev/kvm ] && echo -enable-kvm)"
fi
'';