Skip to content

Commit

Permalink
runInLinuxVM: Use QEMU command line that works on other architectures
Browse files Browse the repository at this point in the history
... by moving the existing definition to qemu-flags.nix and reusing
that.
  • Loading branch information
dezgeg committed Jan 30, 2018
1 parent 8c4f8c5 commit 71631a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
6 changes: 6 additions & 0 deletions nixos/lib/qemu-flags.nix
Expand Up @@ -12,4 +12,10 @@
else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0"
else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";

qemuBinary = qemuPkg: {
"i686-linux" = "${qemuPkg}/bin/qemu-kvm";
"x86_64-linux" = "${qemuPkg}/bin/qemu-kvm -cpu kvm64";
"armv7l-linux" = "${qemuPkg}/bin/qemu-system-arm -enable-kvm -machine virt -cpu host";
"aarch64-linux" = "${qemuPkg}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host";
}.${pkgs.stdenv.system} or (throw "Unknown QEMU binary for '${pkgs.stdenv.system}'");
}
8 changes: 1 addition & 7 deletions nixos/modules/virtualisation/qemu-vm.nix
Expand Up @@ -15,12 +15,6 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };
let

qemu = config.system.build.qemu or pkgs.qemu_test;
qemuKvm = {
"i686-linux" = "${qemu}/bin/qemu-kvm";
"x86_64-linux" = "${qemu}/bin/qemu-kvm -cpu kvm64";
"armv7l-linux" = "${qemu}/bin/qemu-system-arm -enable-kvm -machine virt -cpu host";
"aarch64-linux" = "${qemu}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host";
}.${pkgs.stdenv.system};

vmName =
if config.networking.hostName == ""
Expand Down Expand Up @@ -79,7 +73,7 @@ let
'')}
# Start QEMU.
exec ${qemuKvm} \
exec ${qemuBinary qemu} \
-name ${vmName} \
-m ${toString config.virtualisation.memorySize} \
-smp ${toString config.virtualisation.cores} \
Expand Down
5 changes: 1 addition & 4 deletions pkgs/build-support/vm/default.nix
Expand Up @@ -23,8 +23,6 @@ rec {
patches = [ ../../../nixos/modules/virtualisation/azure-qemu-220-no-etc-install.patch ];
});

qemuProg = "${qemu}/bin/qemu-kvm";


modulesClosure = makeModulesClosure {
inherit kernel rootModules;
Expand Down Expand Up @@ -204,8 +202,7 @@ rec {


qemuCommandLinux = ''
${qemuProg} \
${lib.optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \
${qemuBinary qemu} \
-nographic -no-reboot \
-device virtio-rng-pci \
-virtfs local,path=${storeDir},security_model=none,mount_tag=store \
Expand Down

0 comments on commit 71631a9

Please sign in to comment.