···8 "-net vde,vlan=${toString nic},sock=$QEMU_VDE_SOCKET_${toString net}"
9 ];
1011+ qemuSerialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0"
12+ else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0"
13+ else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";
14+15}
+8-11
nixos/modules/testing/test-instrumentation.nix
···4{ config, lib, pkgs, ... }:
56with lib;
078let
9 kernel = config.boot.kernelPackages.kernel;
10- # FIXME: figure out a common place for this instead of copy pasting
11- serialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0"
12- else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0"
13- else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";
14in
1516{
···2829 systemd.services.backdoor =
30 { wantedBy = [ "multi-user.target" ];
31- requires = [ "dev-hvc0.device" "dev-${serialDevice}.device" ];
32- after = [ "dev-hvc0.device" "dev-${serialDevice}.device" ];
33 script =
34 ''
35 export USER=root
···4647 cd /tmp
48 exec < /dev/hvc0 > /dev/hvc0
49- while ! exec 2> /dev/${serialDevice}; do sleep 0.1; done
50 echo "connecting to host..." >&2
51 stty -F /dev/hvc0 raw -echo # prevent nl -> cr/nl conversion
52 echo
···55 serviceConfig.KillSignal = "SIGHUP";
56 };
5758- # Prevent agetty from being instantiated on ${serialDevice}, since it
59- # interferes with the backdoor (writes to ${serialDevice} will randomly fail
60 # with EIO). Likewise for hvc0.
61- systemd.services."serial-getty@${serialDevice}".enable = false;
62 systemd.services."serial-getty@hvc0".enable = false;
6364 boot.initrd.preDeviceCommands =
···94 # Panic if an error occurs in stage 1 (rather than waiting for
95 # user intervention).
96 boot.kernelParams =
97- [ "console=${serialDevice}" "panic=1" "boot.panic_on_fail" ];
9899 # `xwininfo' is used by the test driver to query open windows.
100 environment.systemPackages = [ pkgs.xorg.xwininfo ];
···4{ config, lib, pkgs, ... }:
56with lib;
7+with import ../../lib/qemu-flags.nix { inherit pkgs; };
89let
10 kernel = config.boot.kernelPackages.kernel;
000011in
1213{
···2526 systemd.services.backdoor =
27 { wantedBy = [ "multi-user.target" ];
28+ requires = [ "dev-hvc0.device" "dev-${qemuSerialDevice}.device" ];
29+ after = [ "dev-hvc0.device" "dev-${qemuSerialDevice}.device" ];
30 script =
31 ''
32 export USER=root
···4344 cd /tmp
45 exec < /dev/hvc0 > /dev/hvc0
46+ while ! exec 2> /dev/${qemuSerialDevice}; do sleep 0.1; done
47 echo "connecting to host..." >&2
48 stty -F /dev/hvc0 raw -echo # prevent nl -> cr/nl conversion
49 echo
···52 serviceConfig.KillSignal = "SIGHUP";
53 };
5455+ # Prevent agetty from being instantiated on the serial device, since it
56+ # interferes with the backdoor (writes to it will randomly fail
57 # with EIO). Likewise for hvc0.
58+ systemd.services."serial-getty@${qemuSerialDevice}".enable = false;
59 systemd.services."serial-getty@hvc0".enable = false;
6061 boot.initrd.preDeviceCommands =
···91 # Panic if an error occurs in stage 1 (rather than waiting for
92 # user intervention).
93 boot.kernelParams =
94+ [ "console=${qemuSerialDevice}" "panic=1" "boot.panic_on_fail" ];
9596 # `xwininfo' is used by the test driver to query open windows.
97 environment.systemPackages = [ pkgs.xorg.xwininfo ];
+2-6
nixos/modules/virtualisation/qemu-vm.nix
···10{ config, lib, pkgs, ... }:
1112with lib;
01314let
15···21 "aarch64-linux" = "${qemu}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host";
22 }.${pkgs.stdenv.system};
2324- # FIXME: figure out a common place for this instead of copy pasting
25- serialDevice = if pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64 then "ttyS0"
26- else if pkgs.stdenv.isArm || pkgs.stdenv.isAarch64 then "ttyAMA0"
27- else throw "Unknown QEMU serial device for system '${pkgs.stdenv.system}'";
28-29 vmName =
30 if config.networking.hostName == ""
31 then "noname"
···34 cfg = config.virtualisation;
3536 qemuGraphics = if cfg.graphics then "" else "-nographic";
37- kernelConsole = if cfg.graphics then "" else "console=${serialDevice}";
38 ttys = [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ];
3940 # Shell script to start the VM.
···10{ config, lib, pkgs, ... }:
1112with lib;
13+with import ../../lib/qemu-flags.nix { inherit pkgs; };
1415let
16···22 "aarch64-linux" = "${qemu}/bin/qemu-system-aarch64 -enable-kvm -machine virt,gic-version=host -cpu host";
23 }.${pkgs.stdenv.system};
240000025 vmName =
26 if config.networking.hostName == ""
27 then "noname"
···30 cfg = config.virtualisation;
3132 qemuGraphics = if cfg.graphics then "" else "-nographic";
33+ kernelConsole = if cfg.graphics then "" else "console=${qemuSerialDevice}";
34 ttys = [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ];
3536 # Shell script to start the VM.