lol

Merge pull request #49403 from andir/qemu_test_reduce_closure

qemu_test: disable features that are not needed for tests (closure 641 -> 335.3M)

authored by

Andreas Rammhold and committed by
GitHub
f6cd1726 6e5ccaa3

+52 -23
+2 -2
nixos/doc/manual/development/running-nixos-tests-interactively.xml
··· 9 9 The test itself can be run interactively. This is particularly useful when 10 10 developing or debugging a test: 11 11 <screen> 12 - <prompt>$ </prompt>nix-build nixos/tests/login.nix -A driver 12 + <prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive 13 13 <prompt>$ </prompt>./result/bin/nixos-test-driver 14 14 starting VDE switch for network 1 15 15 <prompt>&gt;</prompt> ··· 30 30 <para> 31 31 To just start and experiment with the VMs, run: 32 32 <screen> 33 - <prompt>$ </prompt>nix-build nixos/tests/login.nix -A driver 33 + <prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive 34 34 <prompt>$ </prompt>./result/bin/nixos-run-vms 35 35 </screen> 36 36 The script <command>nixos-run-vms</command> starts the virtual machines
+14 -6
nixos/lib/testing-python.nix
··· 17 17 inherit pkgs; 18 18 19 19 20 - testDriver = let 20 + mkTestDriver = let 21 21 testDriverScript = ./test-driver/test-driver.py; 22 - in stdenv.mkDerivation { 22 + in qemu_pkg: stdenv.mkDerivation { 23 23 name = "nixos-test-driver"; 24 24 25 25 nativeBuildInputs = [ makeWrapper ]; ··· 47 47 # TODO: copy user script part into this file (append) 48 48 49 49 wrapProgram $out/bin/nixos-test-driver \ 50 - --prefix PATH : "${lib.makeBinPath [ qemu_test vde2 netpbm coreutils ]}" \ 50 + --prefix PATH : "${lib.makeBinPath [ qemu_pkg vde2 netpbm coreutils ]}" \ 51 51 ''; 52 52 }; 53 53 54 + testDriver = mkTestDriver qemu_test; 55 + testDriverInteractive = mkTestDriver qemu_kvm; 54 56 55 57 # Run an automated test suite in the given virtual network. 56 58 # `driver' is the script that runs the network. ··· 113 115 # Generate convenience wrappers for running the test driver 114 116 # interactively with the specified network, and for starting the 115 117 # VMs from the command line. 116 - driver = let warn = if skipLint then lib.warn "Linting is disabled!" else lib.id; in warn (runCommand testDriverName 118 + driver = testDriver: 119 + let 120 + warn = if skipLint then lib.warn "Linting is disabled!" else lib.id; 121 + in 122 + warn (runCommand testDriverName 117 123 { buildInputs = [ makeWrapper]; 118 124 testScript = testScript'; 119 125 preferLocalBuild = true; ··· 148 154 meta = (drv.meta or {}) // t.meta; 149 155 }; 150 156 151 - test = passMeta (runTests driver); 157 + test = passMeta (runTests (driver testDriver)); 152 158 153 159 nodeNames = builtins.attrNames nodes; 154 160 invalidNodeNames = lib.filter ··· 165 171 '' 166 172 else 167 173 test // { 168 - inherit nodes driver test; 174 + inherit nodes test; 175 + driver = driver testDriver; 176 + driverInteractive = driver testDriverInteractive; 169 177 }; 170 178 171 179 runInMachine =
+4
nixos/modules/testing/test-instrumentation.nix
··· 116 116 users.users.root.initialHashedPassword = mkOverride 150 ""; 117 117 118 118 services.xserver.displayManager.job.logToJournal = true; 119 + 120 + # Make sure we use the Guest Agent from the QEMU package for testing 121 + # to reduce the closure size required for the tests. 122 + services.qemuGuest.package = pkgs.qemu_test.ga; 119 123 }; 120 124 121 125 }
+6 -1
nixos/modules/virtualisation/qemu-guest-agent.nix
··· 12 12 default = false; 13 13 description = "Whether to enable the qemu guest agent."; 14 14 }; 15 + package = mkOption { 16 + type = types.package; 17 + default = pkgs.qemu.ga; 18 + description = "The QEMU guest agent package."; 19 + }; 15 20 }; 16 21 17 22 config = mkIf cfg.enable ( ··· 25 30 systemd.services.qemu-guest-agent = { 26 31 description = "Run the QEMU Guest Agent"; 27 32 serviceConfig = { 28 - ExecStart = "${pkgs.qemu.ga}/bin/qemu-ga"; 33 + ExecStart = "${cfg.package}/bin/qemu-ga"; 29 34 Restart = "always"; 30 35 RestartSec = 0; 31 36 };
+12 -9
pkgs/applications/virtualization/qemu/default.nix
··· 1 1 { stdenv, fetchurl, fetchpatch, python, zlib, pkgconfig, glib 2 - , ncurses, perl, pixman, vde2, alsaLib, texinfo, flex 2 + , perl, pixman, vde2, alsaLib, texinfo, flex 3 3 , bison, lzo, snappy, libaio, gnutls, nettle, curl 4 4 , makeWrapper 5 5 , attr, libcap, libcap_ng 6 6 , CoreServices, Cocoa, Hypervisor, rez, setfile 7 7 , numaSupport ? stdenv.isLinux && !stdenv.isAarch32, numactl 8 8 , seccompSupport ? stdenv.isLinux, libseccomp 9 - , pulseSupport ? !stdenv.isDarwin, libpulseaudio 10 - , sdlSupport ? !stdenv.isDarwin, SDL2 11 - , gtkSupport ? !stdenv.isDarwin && !xenSupport, gtk3, gettext, vte, wrapGAppsHook 12 - , vncSupport ? true, libjpeg, libpng 13 - , smartcardSupport ? true, libcacard 14 - , spiceSupport ? !stdenv.isDarwin, spice, spice-protocol 9 + , alsaSupport ? stdenv.lib.hasSuffix "linux" stdenv.hostPlatform.system && !nixosTestRunner 10 + , pulseSupport ? !stdenv.isDarwin && !nixosTestRunner, libpulseaudio 11 + , sdlSupport ? !stdenv.isDarwin && !nixosTestRunner, SDL2 12 + , gtkSupport ? !stdenv.isDarwin && !xenSupport && !nixosTestRunner, gtk3, gettext, vte, wrapGAppsHook 13 + , vncSupport ? !nixosTestRunner, libjpeg, libpng 14 + , smartcardSupport ? !nixosTestRunner, libcacard 15 + , spiceSupport ? !stdenv.isDarwin && !nixosTestRunner, spice, spice-protocol 16 + , ncursesSupport ? !nixosTestRunner, ncurses 15 17 , usbredirSupport ? spiceSupport, usbredir 16 18 , xenSupport ? false, xen 17 19 , cephSupport ? false, ceph ··· 29 31 30 32 with stdenv.lib; 31 33 let 32 - audio = optionalString (hasSuffix "linux" stdenv.hostPlatform.system) "alsa," 34 + audio = optionalString alsaSupport "alsa," 33 35 + optionalString pulseSupport "pa," 34 36 + optionalString sdlSupport "sdl,"; 35 37 ··· 50 52 nativeBuildInputs = [ python python.pkgs.sphinx pkgconfig flex bison ] 51 53 ++ optionals gtkSupport [ wrapGAppsHook ]; 52 54 buildInputs = 53 - [ zlib glib ncurses perl pixman 55 + [ zlib glib perl pixman 54 56 vde2 texinfo makeWrapper lzo snappy 55 57 gnutls nettle curl 56 58 ] 59 + ++ optionals ncursesSupport [ ncurses ] 57 60 ++ optionals stdenv.isDarwin [ CoreServices Cocoa Hypervisor rez setfile ] 58 61 ++ optionals seccompSupport [ libseccomp ] 59 62 ++ optionals numaSupport [ numactl ]
+2 -2
pkgs/development/libraries/libndctl/default.nix
··· 1 1 { stdenv, fetchFromGitHub, autoreconfHook 2 2 , asciidoctor, pkgconfig, xmlto, docbook_xsl, docbook_xml_dtd_45, libxslt 3 - , json_c, kmod, which, utillinux, systemd, keyutils 3 + , json_c, kmod, which, utillinux, udev, keyutils 4 4 }: 5 5 6 6 stdenv.mkDerivation rec { ··· 22 22 ]; 23 23 24 24 buildInputs = 25 - [ json_c kmod utillinux systemd keyutils 25 + [ json_c kmod utillinux udev keyutils 26 26 ]; 27 27 28 28 configureFlags =
+12 -3
pkgs/os-specific/linux/iputils/default.nix
··· 1 - { stdenv, fetchFromGitHub 1 + { stdenv, fetchFromGitHub, fetchpatch 2 2 , meson, ninja, pkgconfig, gettext, libxslt, docbook_xsl_ns 3 - , libcap, systemd, libidn2 3 + , libcap, libidn2 4 4 }: 5 5 6 6 with stdenv.lib; ··· 22 22 sha256 = "1jhbcz75a4ij1myyyi110ma1d8d5hpm3scz9pyw7js6qym50xvh4"; 23 23 }; 24 24 25 + patches = [ 26 + # Proposed upstream patch to reduce dependency on systemd: https://github.com/iputils/iputils/pull/297 27 + (fetchpatch { 28 + url = "https://github.com/iputils/iputils/commit/13d6aefd57fd471ecad06e19073dcc44608dff5e.patch"; 29 + sha256 = "1n62zxmzp7hgz9qapbbpqv3fxqvc3qyd2a73jhp357x6by84kj49"; 30 + }) 31 + ]; 32 + 25 33 mesonFlags = [ 26 34 "-DBUILD_RARPD=true" 27 35 "-DBUILD_TRACEROUTE6=true" 28 36 "-DBUILD_TFTPD=true" 29 37 "-DNO_SETCAP_OR_SUID=true" 30 38 "-Dsystemdunitdir=etc/systemd/system" 39 + "-DINSTALL_SYSTEMD_UNITS=true" 31 40 ] 32 41 # Disable idn usage w/musl (https://github.com/iputils/iputils/pull/111): 33 42 ++ optional stdenv.hostPlatform.isMusl "-DUSE_IDN=false"; 34 43 35 44 nativeBuildInputs = [ meson ninja pkgconfig gettext libxslt.bin docbook_xsl_ns ]; 36 - buildInputs = [ libcap systemd ] 45 + buildInputs = [ libcap ] 37 46 ++ optional (!stdenv.hostPlatform.isMusl) libidn2; 38 47 39 48 meta = {