about summary refs log tree commit diff
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-05-10 08:10:19 +0200
committeraszlig <aszlig@nix.build>2018-05-10 08:21:20 +0200
commitfb9f5e4a0322da74201145a3ecbc816525972ab3 (patch)
treeaab6c1011a0d161628d0d1deafb767d116bfd57a
parente659c324484aa610c84ca76424b0e17502789e8c (diff)
downloadnixlib-fb9f5e4a0322da74201145a3ecbc816525972ab3.tar
nixlib-fb9f5e4a0322da74201145a3ecbc816525972ab3.tar.gz
nixlib-fb9f5e4a0322da74201145a3ecbc816525972ab3.tar.bz2
nixlib-fb9f5e4a0322da74201145a3ecbc816525972ab3.tar.lz
nixlib-fb9f5e4a0322da74201145a3ecbc816525972ab3.tar.xz
nixlib-fb9f5e4a0322da74201145a3ecbc816525972ab3.tar.zst
nixlib-fb9f5e4a0322da74201145a3ecbc816525972ab3.zip
nixos/testing: Fix output of systemd messages
Regression introduced by d4468bedb52bf03ff125d721634f83604bddd589.

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
7499e4a5b917227696b7292ae1bd728d6b1978b0.

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @flokli, @dezgeg, @edolstra
-rw-r--r--nixos/modules/testing/test-instrumentation.nix3
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix24
2 files changed, 22 insertions, 5 deletions
diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix
index 41dec2af9ed4..98da55ed68a7 100644
--- a/nixos/modules/testing/test-instrumentation.nix
+++ b/nixos/modules/testing/test-instrumentation.nix
@@ -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
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index d271144af48b..0abf7b11703c 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -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 = [