nixos/testing: Fix output of systemd messages

Regression introduced by d4468bedb5.

No systemd messages are shown anymore during VM test runs, which is not
very helpful if you want to find out about failures.

There is a bit of a conflict between testing and the change that
introduced the regression. While the mentioned commit makes sure that
the primary console is tty0 for virtualisation.graphics = false, our VM
tests need to have the serial console as primary console.

So in order to support both, I added a new virtualisation.qemu.consoles
option, which allows to specify those options using the module system.

The default of this option is to use the changes that were introduced
and in test-instrumentation.nix we use only the serial console the same
way as before.

For test-instrumentation.nix I didn't add a baudrate to the serial
console because I can't find a reason on top of my head why it should
need it. There also wasn't a reason stated when that was introduced in
7499e4a5b9.

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @flokli, @dezgeg, @edolstra
This commit is contained in:
aszlig 2018-05-10 08:10:19 +02:00
parent e659c32448
commit fb9f5e4a03
No known key found for this signature in database
GPG Key ID: 684089CE67EBB691
2 changed files with 22 additions and 5 deletions

View File

@ -58,6 +58,9 @@ in
systemd.services."serial-getty@${qemuSerialDevice}".enable = false;
systemd.services."serial-getty@hvc0".enable = false;
# Only use a serial console, no TTY.
virtualisation.qemu.consoles = [ qemuSerialDevice ];
boot.initrd.preDeviceCommands =
''
echo 600 > /proc/sys/kernel/hung_task_timeout_secs

View File

@ -25,10 +25,7 @@ let
qemuGraphics = lib.optionalString (!cfg.graphics) "-nographic";
# enable both serial console and tty0. select preferred console (last one) based on cfg.graphics
kernelConsoles = let
consoles = [ "console=${qemuSerialDevice},115200n8" "console=tty0" ];
in lib.concatStringsSep " " (if cfg.graphics then consoles else reverseList consoles);
consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles;
# XXX: This is very ugly and in the future we really should use attribute
# sets to build ALL of the QEMU flags instead of this mixed mess of Nix
@ -111,7 +108,7 @@ let
${mkDiskIfaceDriveFlag "0" "file=$NIX_DISK_IMAGE,cache=writeback,werror=report"} \
-kernel ${config.system.build.toplevel}/kernel \
-initrd ${config.system.build.toplevel}/initrd \
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo}/registration ${kernelConsoles} $QEMU_KERNEL_PARAMS" \
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo}/registration ${consoles} $QEMU_KERNEL_PARAMS" \
''} \
$extraDisks \
${qemuGraphics} \
@ -336,6 +333,23 @@ in
description = "Options passed to QEMU.";
};
consoles = mkOption {
type = types.listOf types.str;
default = let
consoles = [ "${qemuSerialDevice},115200n8" "tty0" ];
in if cfg.graphics then consoles else reverseList consoles;
example = [ "console=tty1" ];
description = ''
The output console devices to pass to the kernel command line via the
<literal>console</literal> parameter, the primary console is the last
item of this list.
By default it enables both serial console and
<literal>tty0</literal>. The preferred console (last one) is based on
the value of <option>virtualisation.graphics</option>.
'';
};
networkingOptions =
mkOption {
default = [