Skip to content

Commit

Permalink
nixos: fix qemu_test being used in normal VMs
Browse files Browse the repository at this point in the history
This is an attempt to fixup PR NixOS#49403.
  • Loading branch information
rnhmjoj committed Oct 21, 2020
1 parent d95b8c3 commit bc2188b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 0 additions & 4 deletions nixos/lib/build-vms.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ rec {

inherit pkgs;

qemu = pkgs.qemu_test;


# Build a virtual network from an attribute set `{ machine1 =
# config1; ... machineN = configN; }', where `machineX' is the
# hostname and `configX' is a NixOS system configuration. Each
Expand All @@ -39,7 +36,6 @@ rec {
[ ../modules/virtualisation/qemu-vm.nix
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
{ key = "no-manual"; documentation.nixos.enable = false; }
{ key = "qemu"; system.build.qemu = qemu; }
{ key = "nodes"; _module.args.nodes = nodes; }
] ++ optional minimal ../modules/testing/minimal-kernel.nix;
};
Expand Down
5 changes: 4 additions & 1 deletion nixos/modules/testing/test-instrumentation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };
# we avoid defining consoles if not possible.
# TODO: refactor such that test-instrumentation can import qemu-vm
# or declare virtualisation.qemu.console option in a module that's always imported
virtualisation = lib.optionalAttrs (options ? virtualisation.qemu.consoles) { qemu.consoles = [ qemuSerialDevice ]; };
virtualisation.qemu = {
consoles = lib.optional (options ? virtualisation.qemu.consoles) qemuSerialDevice;
package = pkgs.qemu_test;
};

boot.initrd.preDeviceCommands =
''
Expand Down
11 changes: 10 additions & 1 deletion nixos/modules/virtualisation/qemu-vm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };

let

qemu = config.system.build.qemu or pkgs.qemu_test;

cfg = config.virtualisation;

qemu = cfg.qemu.package;

consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles;

driveOpts = { ... }: {
Expand Down Expand Up @@ -401,6 +402,14 @@ in
};

virtualisation.qemu = {
package =
mkOption {
type = types.package;
default = pkgs.qemu;
example = "pkgs.qemu_test";
description = "QEMU package to use.";
};

options =
mkOption {
type = types.listOf types.unspecified;
Expand Down

0 comments on commit bc2188b

Please sign in to comment.