Merge pull request #101246 from rnhmjoj/vm-fix

nixos: fix qemu_test being used in normal VMs
This commit is contained in:
Andreas Rammhold 2020-10-22 11:09:05 +02:00 committed by GitHub
commit 89351525fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View File

@ -18,9 +18,6 @@ rec {
inherit pkgs; inherit pkgs;
qemu = pkgs.qemu_test;
# Build a virtual network from an attribute set `{ machine1 = # Build a virtual network from an attribute set `{ machine1 =
# config1; ... machineN = configN; }', where `machineX' is the # config1; ... machineN = configN; }', where `machineX' is the
# hostname and `configX' is a NixOS system configuration. Each # hostname and `configX' is a NixOS system configuration. Each
@ -39,7 +36,6 @@ rec {
[ ../modules/virtualisation/qemu-vm.nix [ ../modules/virtualisation/qemu-vm.nix
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
{ key = "no-manual"; documentation.nixos.enable = false; } { key = "no-manual"; documentation.nixos.enable = false; }
{ key = "qemu"; system.build.qemu = qemu; }
{ key = "nodes"; _module.args.nodes = nodes; } { key = "nodes"; _module.args.nodes = nodes; }
] ++ optional minimal ../modules/testing/minimal-kernel.nix; ] ++ optional minimal ../modules/testing/minimal-kernel.nix;
}; };

View File

@ -51,7 +51,10 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };
# we avoid defining consoles if not possible. # we avoid defining consoles if not possible.
# TODO: refactor such that test-instrumentation can import qemu-vm # TODO: refactor such that test-instrumentation can import qemu-vm
# or declare virtualisation.qemu.console option in a module that's always imported # 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 = boot.initrd.preDeviceCommands =
'' ''

View File

@ -14,10 +14,11 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };
let let
qemu = config.system.build.qemu or pkgs.qemu_test;
cfg = config.virtualisation; cfg = config.virtualisation;
qemu = cfg.qemu.package;
consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles; consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles;
driveOpts = { ... }: { driveOpts = { ... }: {
@ -401,6 +402,14 @@ in
}; };
virtualisation.qemu = { virtualisation.qemu = {
package =
mkOption {
type = types.package;
default = pkgs.qemu;
example = "pkgs.qemu_test";
description = "QEMU package to use.";
};
options = options =
mkOption { mkOption {
type = types.listOf types.unspecified; type = types.listOf types.unspecified;