Merge pull request #101645 from andir/qemu-tests-fixup

nixos/tests: only apply qemu parameters if the options are defined
This commit is contained in:
Maximilian Bosch 2020-10-25 19:25:50 +01:00 committed by GitHub
commit a3041ab124
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -45,15 +45,21 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };
systemd.services."serial-getty@${qemuSerialDevice}".enable = false;
systemd.services."serial-getty@hvc0".enable = false;
# Only use a serial console, no TTY.
# NOTE: optionalAttrs
# test-instrumentation.nix appears to be used without qemu-vm.nix, so
# 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.qemu = {
consoles = lib.optional (options ? virtualisation.qemu.consoles) qemuSerialDevice;
package = lib.mkDefault pkgs.qemu_test;
# Only set these settings when the options exist. Some tests (e.g. those
# that do not specify any nodes, or an empty attr set as nodes) will not
# have the QEMU module loaded and thuse these options can't and should not
# be set.
virtualisation = lib.optionalAttrs (options ? virtualisation.qemu) {
qemu = {
# Only use a serial console, no TTY.
# NOTE: optionalAttrs
# test-instrumentation.nix appears to be used without qemu-vm.nix, so
# 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
consoles = [ qemuSerialDevice ];
package = lib.mkDefault pkgs.qemu_test;
};
};
boot.initrd.preDeviceCommands =