···88 "-net vde,vlan=${toString nic},sock=$QEMU_VDE_SOCKET_${toString net}"
99 ];
10101111+ qemuSerialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0"
1212+ else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0"
1313+ else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";
1414+1115}
+8-11
nixos/modules/testing/test-instrumentation.nix
···44{ config, lib, pkgs, ... }:
5566with lib;
77+with import ../../lib/qemu-flags.nix { inherit pkgs; };
7889let
910 kernel = config.boot.kernelPackages.kernel;
1010- # FIXME: figure out a common place for this instead of copy pasting
1111- serialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0"
1212- else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0"
1313- else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";
1411in
15121613{
···28252926 systemd.services.backdoor =
3027 { wantedBy = [ "multi-user.target" ];
3131- requires = [ "dev-hvc0.device" "dev-${serialDevice}.device" ];
3232- after = [ "dev-hvc0.device" "dev-${serialDevice}.device" ];
2828+ requires = [ "dev-hvc0.device" "dev-${qemuSerialDevice}.device" ];
2929+ after = [ "dev-hvc0.device" "dev-${qemuSerialDevice}.device" ];
3330 script =
3431 ''
3532 export USER=root
···46434744 cd /tmp
4845 exec < /dev/hvc0 > /dev/hvc0
4949- while ! exec 2> /dev/${serialDevice}; do sleep 0.1; done
4646+ while ! exec 2> /dev/${qemuSerialDevice}; do sleep 0.1; done
5047 echo "connecting to host..." >&2
5148 stty -F /dev/hvc0 raw -echo # prevent nl -> cr/nl conversion
5249 echo
···5552 serviceConfig.KillSignal = "SIGHUP";
5653 };
57545858- # Prevent agetty from being instantiated on ${serialDevice}, since it
5959- # interferes with the backdoor (writes to ${serialDevice} will randomly fail
5555+ # Prevent agetty from being instantiated on the serial device, since it
5656+ # interferes with the backdoor (writes to it will randomly fail
6057 # with EIO). Likewise for hvc0.
6161- systemd.services."serial-getty@${serialDevice}".enable = false;
5858+ systemd.services."serial-getty@${qemuSerialDevice}".enable = false;
6259 systemd.services."serial-getty@hvc0".enable = false;
63606461 boot.initrd.preDeviceCommands =
···9491 # Panic if an error occurs in stage 1 (rather than waiting for
9592 # user intervention).
9693 boot.kernelParams =
9797- [ "console=${serialDevice}" "panic=1" "boot.panic_on_fail" ];
9494+ [ "console=${qemuSerialDevice}" "panic=1" "boot.panic_on_fail" ];
98959996 # `xwininfo' is used by the test driver to query open windows.
10097 environment.systemPackages = [ pkgs.xorg.xwininfo ];
+2-6
nixos/modules/virtualisation/qemu-vm.nix
···1010{ config, lib, pkgs, ... }:
11111212with lib;
1313+with import ../../lib/qemu-flags.nix { inherit pkgs; };
13141415let
1516···2122 "aarch64-linux" = "${qemu}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host";
2223 }.${pkgs.stdenv.system};
23242424- # FIXME: figure out a common place for this instead of copy pasting
2525- serialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0"
2626- else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0"
2727- else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";
2828-2925 vmName =
3026 if config.networking.hostName == ""
3127 then "noname"
···3430 cfg = config.virtualisation;
35313632 qemuGraphics = if cfg.graphics then "" else "-nographic";
3737- kernelConsole = if cfg.graphics then "" else "console=${serialDevice}";
3333+ kernelConsole = if cfg.graphics then "" else "console=${qemuSerialDevice}";
3834 ttys = [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ];
39354036 # Shell script to start the VM.