From 98d6b55fdc89c679dabdfe2f685bdc224f1642c4 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 5 Sep 2020 16:07:14 +0200 Subject: nixos/testing: remove remaining coverage-data logic This isn't used anymore as per https://github.com/NixOS/nixpkgs/pull/72354#discussion_r451031449. --- nixos/modules/testing/test-instrumentation.nix | 9 --------- 1 file changed, 9 deletions(-) (limited to 'nixos/modules/testing/test-instrumentation.nix') diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 30ffb12cbad..c0ec76e8a3a 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -74,15 +74,8 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; # OOM killer randomly get rid of processes, since this leads # to failures that are hard to diagnose. echo 2 > /proc/sys/vm/panic_on_oom - - # Coverage data is written into /tmp/coverage-data. - mkdir -p /tmp/xchg/coverage-data ''; - # If the kernel has been built with coverage instrumentation, make - # it available under /proc/gcov. - boot.kernelModules = [ "gcov-proc" ]; - # Panic if an error occurs in stage 1 (rather than waiting for # user intervention). boot.kernelParams = @@ -111,8 +104,6 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; networking.defaultGateway = mkOverride 150 ""; networking.nameservers = mkOverride 150 [ ]; - systemd.globalEnvironment.GCOV_PREFIX = "/tmp/xchg/coverage-data"; - system.requiredKernelConfig = with config.lib.kernelConfig; [ (isYes "SERIAL_8250_CONSOLE") (isYes "SERIAL_8250") -- cgit 1.4.1 From 8ed57ac9166c3b0fcde9e8e6d2a379e501bcb7e5 Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Mon, 19 Oct 2020 18:03:01 +0200 Subject: nixos/tests: make sure we use the qemu_test package to provide the Guest Agent This reduces the closure size for the minimal test by a lot since we no longer have to build the regular QEMU for even the simplest test. --- nixos/modules/testing/test-instrumentation.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'nixos/modules/testing/test-instrumentation.nix') diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index c0ec76e8a3a..dbbcb0bed5b 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -116,6 +116,10 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; users.users.root.initialHashedPassword = mkOverride 150 ""; services.xserver.displayManager.job.logToJournal = true; + + # Make sure we use the Guest Agent from the QEMU package for testing + # to reduce the closure size required for the tests. + services.qemuGuest.package = pkgs.qemu_test.ga; }; } -- cgit 1.4.1 From bc2188b083dfbbe749a221023e2960b60d4c8951 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 21 Oct 2020 13:02:09 +0200 Subject: nixos: fix qemu_test being used in normal VMs This is an attempt to fixup PR #49403. --- nixos/lib/build-vms.nix | 4 ---- nixos/modules/testing/test-instrumentation.nix | 5 ++++- nixos/modules/virtualisation/qemu-vm.nix | 11 ++++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'nixos/modules/testing/test-instrumentation.nix') diff --git a/nixos/lib/build-vms.nix b/nixos/lib/build-vms.nix index b1575fc13bb..ebbb0296bef 100644 --- a/nixos/lib/build-vms.nix +++ b/nixos/lib/build-vms.nix @@ -18,9 +18,6 @@ rec { inherit pkgs; - qemu = pkgs.qemu_test; - - # Build a virtual network from an attribute set `{ machine1 = # config1; ... machineN = configN; }', where `machineX' is the # hostname and `configX' is a NixOS system configuration. Each @@ -39,7 +36,6 @@ rec { [ ../modules/virtualisation/qemu-vm.nix ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs { key = "no-manual"; documentation.nixos.enable = false; } - { key = "qemu"; system.build.qemu = qemu; } { key = "nodes"; _module.args.nodes = nodes; } ] ++ optional minimal ../modules/testing/minimal-kernel.nix; }; diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index dbbcb0bed5b..e9f5eac7f5f 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -51,7 +51,10 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; # 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 = lib.optionalAttrs (options ? virtualisation.qemu.consoles) { qemu.consoles = [ qemuSerialDevice ]; }; + virtualisation.qemu = { + consoles = lib.optional (options ? virtualisation.qemu.consoles) qemuSerialDevice; + package = pkgs.qemu_test; + }; boot.initrd.preDeviceCommands = '' diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 42e43f5ee02..191d7c758c0 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -14,10 +14,11 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; let - qemu = config.system.build.qemu or pkgs.qemu_test; cfg = config.virtualisation; + qemu = cfg.qemu.package; + consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles; driveOpts = { ... }: { @@ -401,6 +402,14 @@ in }; virtualisation.qemu = { + package = + mkOption { + type = types.package; + default = pkgs.qemu; + example = "pkgs.qemu_test"; + description = "QEMU package to use."; + }; + options = mkOption { type = types.listOf types.unspecified; -- cgit 1.4.1 From aab534b894c60e69199aba4cc57b8b3f8fd1a8c2 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 23 Oct 2020 17:33:10 +0200 Subject: nixos/nixos-build-vms: use `pkgs.qemu` for virtualisation When I test a change e.g. in the module system manually, I usually use `nixos-build-vms(8)` which also gives me a QEMU window where I can play around in the freshly built VM. It seems as this has changed recently when the default package for non-interactive VM tests using the same framework was switched to `pkgs.qemu_test` to reduce the closure size. While this is a reasonable decision for our CI tests, I think that you really want a QEMU window of the VM by default when using `nixos-build-vms(8)`. [1] bc2188b083dfbbe749a221023e2960b60d4c8951 --- nixos/modules/installer/tools/nixos-build-vms/build-vms.nix | 7 ++++++- nixos/modules/testing/test-instrumentation.nix | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'nixos/modules/testing/test-instrumentation.nix') diff --git a/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix b/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix index 0c9f8522cc1..199e5f9206b 100644 --- a/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix +++ b/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix @@ -6,7 +6,12 @@ let nodes = builtins.mapAttrs (vm: module: { _file = "${networkExpr}@node-${vm}"; - imports = [ module ]; + imports = [ + module + ({ pkgs, ... }: { + virtualisation.qemu.package = pkgs.qemu; + }) + ]; }) (import networkExpr); in diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index e9f5eac7f5f..2986bd4c4e3 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -53,7 +53,7 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; }; # or declare virtualisation.qemu.console option in a module that's always imported virtualisation.qemu = { consoles = lib.optional (options ? virtualisation.qemu.consoles) qemuSerialDevice; - package = pkgs.qemu_test; + package = lib.mkDefault pkgs.qemu_test; }; boot.initrd.preDeviceCommands = -- cgit 1.4.1 From f4d74931628accc733f9e0e996575b5ca3042d8a Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Sun, 25 Oct 2020 13:19:25 +0100 Subject: nixos/tests: only apply qemu parameters if the options are defined This fixes an eval error that occurred on hydra with the small channel and the `nixos.tests.boot.biosCdrom.x86_64-linux` attribute: > $ nix-instantiate nixos/release-small.nix -A nixos.tests.boot.biosCdrom.x86_64-linux > warning: unknown setting 'experimental-features' > error: The option `virtualisation.qemu' does not exist. Definition values: > - In `/home/andi/dev/nixos/nixpkgs/nixos/modules/testing/test-instrumentation.nix': > { > consoles = [ ]; > package = { > _type = "override"; > content = ; > ... > (use '--show-trace' to show detailed location information) In bc2188b we changed test test-instrumentation to also set the QEMU package that is being used. That change unfortunately caused us to always assing values to the virtualisation.qemu.package option even when the option is not defined. The original code was explicitly testing for the consoles case but the then newly extended version did not adjust the check as the intention was probably not clear. With this commit we are always ensuring the entire virtualisation.qemu section exists and can thus drop the individual tests for each of the sections since the QEMU module always defines both the package and the consoles option when it's root is defined.. --- nixos/modules/testing/test-instrumentation.nix | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'nixos/modules/testing/test-instrumentation.nix') diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 2986bd4c4e3..be5fa88b8ad 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -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 = -- cgit 1.4.1