qemu: fix bin/qemu-kvm on aarch64 + minor fixes

* $out/bin/qemu-kvm should point to qemu-system-aarch64 on aarch64, libvirt expect it
* makeWrapper codes are separated as some architectures might require additional command flags (https://github.com/NixOS/nixpkgs/issues/31606#issuecomment-349675127)
* x86_64-on-i686 is not a native emulation and not supported by KVM, so it is removed from the list

authored by volth and committed by Tuomas Tynkkynen 489d3e7d 8f53673c

+11 -11
+11 -11
pkgs/applications/virtualization/qemu/default.nix
··· 24 24 + optionalString pulseSupport "pa," 25 25 + optionalString sdlSupport "sdl,"; 26 26 27 - hostCpuTargets = if stdenv.isi686 || stdenv.isx86_64 then "i386-softmmu,x86_64-softmmu" 28 - else if stdenv.isArm then "arm-softmmu" 29 - else if stdenv.isAarch64 then "aarch64-softmmu" 30 - else throw "Don't know how to build a 'hostCpuOnly = true' QEMU"; 27 + hostCpuTargets = if stdenv.isx86_64 then "i386-softmmu,x86_64-softmmu" 28 + else if stdenv.isi686 then "i386-softmmu" 29 + else if stdenv.isArm then "arm-softmmu" 30 + else if stdenv.isAarch64 then "aarch64-softmmu" 31 + else throw "Don't know how to build a 'hostCpuOnly = true' QEMU"; 31 32 in 32 33 33 34 stdenv.mkDerivation rec { ··· 92 93 done 93 94 ''; 94 95 96 + # Add a ‘qemu-kvm’ wrapper for compatibility/convenience. 95 97 postInstall = 96 - '' 97 - # Add a ‘qemu-kvm’ wrapper for compatibility/convenience. 98 - p="$out/bin/qemu-system-${if stdenv.system == "x86_64-linux" then "x86_64" else "i386"}" 99 - if [ -e "$p" ]; then 100 - makeWrapper "$p" $out/bin/qemu-kvm --add-flags "\$([ -e /dev/kvm ] && echo -enable-kvm)" 101 - fi 102 - ''; 98 + if stdenv.isx86_64 then ''makeWrapper $out/bin/qemu-system-x86_64 $out/bin/qemu-kvm --add-flags "\$([ -e /dev/kvm ] && echo -enable-kvm)"'' 99 + else if stdenv.isi686 then ''makeWrapper $out/bin/qemu-system-i386 $out/bin/qemu-kvm --add-flags "\$([ -e /dev/kvm ] && echo -enable-kvm)"'' 100 + else if stdenv.isArm then ''makeWrapper $out/bin/qemu-system-arm $out/bin/qemu-kvm --add-flags "\$([ -e /dev/kvm ] && echo -enable-kvm)"'' 101 + else if stdenv.isAarch64 then ''makeWrapper $out/bin/qemu-system-aarch64 $out/bin/qemu-kvm --add-flags "\$([ -e /dev/kvm ] && echo -enable-kvm)"'' 102 + else ""; 103 103 104 104 meta = with stdenv.lib; { 105 105 homepage = http://www.qemu.org/;