Merge pull request #49403 from andir/qemu_test_reduce_closure

qemu_test: disable features that are not needed for tests (closure 641 -> 335.3M)
This commit is contained in:
Andreas Rammhold 2020-10-21 00:41:01 +02:00 committed by GitHub
commit f6cd17269e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 23 deletions

View file

@ -9,7 +9,7 @@
The test itself can be run interactively. This is particularly useful when
developing or debugging a test:
<screen>
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driver
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive
<prompt>$ </prompt>./result/bin/nixos-test-driver
starting VDE switch for network 1
<prompt>&gt;</prompt>
@ -30,7 +30,7 @@ starting VDE switch for network 1
<para>
To just start and experiment with the VMs, run:
<screen>
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driver
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive
<prompt>$ </prompt>./result/bin/nixos-run-vms
</screen>
The script <command>nixos-run-vms</command> starts the virtual machines

View file

@ -17,9 +17,9 @@ rec {
inherit pkgs;
testDriver = let
mkTestDriver = let
testDriverScript = ./test-driver/test-driver.py;
in stdenv.mkDerivation {
in qemu_pkg: stdenv.mkDerivation {
name = "nixos-test-driver";
nativeBuildInputs = [ makeWrapper ];
@ -47,10 +47,12 @@ rec {
# TODO: copy user script part into this file (append)
wrapProgram $out/bin/nixos-test-driver \
--prefix PATH : "${lib.makeBinPath [ qemu_test vde2 netpbm coreutils ]}" \
--prefix PATH : "${lib.makeBinPath [ qemu_pkg vde2 netpbm coreutils ]}" \
'';
};
testDriver = mkTestDriver qemu_test;
testDriverInteractive = mkTestDriver qemu_kvm;
# Run an automated test suite in the given virtual network.
# `driver' is the script that runs the network.
@ -113,7 +115,11 @@ rec {
# Generate convenience wrappers for running the test driver
# interactively with the specified network, and for starting the
# VMs from the command line.
driver = let warn = if skipLint then lib.warn "Linting is disabled!" else lib.id; in warn (runCommand testDriverName
driver = testDriver:
let
warn = if skipLint then lib.warn "Linting is disabled!" else lib.id;
in
warn (runCommand testDriverName
{ buildInputs = [ makeWrapper];
testScript = testScript';
preferLocalBuild = true;
@ -148,7 +154,7 @@ rec {
meta = (drv.meta or {}) // t.meta;
};
test = passMeta (runTests driver);
test = passMeta (runTests (driver testDriver));
nodeNames = builtins.attrNames nodes;
invalidNodeNames = lib.filter
@ -165,7 +171,9 @@ rec {
''
else
test // {
inherit nodes driver test;
inherit nodes test;
driver = driver testDriver;
driverInteractive = driver testDriverInteractive;
};
runInMachine =

View file

@ -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;
};
}

View file

@ -12,6 +12,11 @@ in {
default = false;
description = "Whether to enable the qemu guest agent.";
};
package = mkOption {
type = types.package;
default = pkgs.qemu.ga;
description = "The QEMU guest agent package.";
};
};
config = mkIf cfg.enable (
@ -25,7 +30,7 @@ in {
systemd.services.qemu-guest-agent = {
description = "Run the QEMU Guest Agent";
serviceConfig = {
ExecStart = "${pkgs.qemu.ga}/bin/qemu-ga";
ExecStart = "${cfg.package}/bin/qemu-ga";
Restart = "always";
RestartSec = 0;
};

View file

@ -1,17 +1,19 @@
{ stdenv, fetchurl, fetchpatch, python, zlib, pkgconfig, glib
, ncurses, perl, pixman, vde2, alsaLib, texinfo, flex
, perl, pixman, vde2, alsaLib, texinfo, flex
, bison, lzo, snappy, libaio, gnutls, nettle, curl
, makeWrapper
, attr, libcap, libcap_ng
, CoreServices, Cocoa, Hypervisor, rez, setfile
, numaSupport ? stdenv.isLinux && !stdenv.isAarch32, numactl
, seccompSupport ? stdenv.isLinux, libseccomp
, pulseSupport ? !stdenv.isDarwin, libpulseaudio
, sdlSupport ? !stdenv.isDarwin, SDL2
, gtkSupport ? !stdenv.isDarwin && !xenSupport, gtk3, gettext, vte, wrapGAppsHook
, vncSupport ? true, libjpeg, libpng
, smartcardSupport ? true, libcacard
, spiceSupport ? !stdenv.isDarwin, spice, spice-protocol
, alsaSupport ? stdenv.lib.hasSuffix "linux" stdenv.hostPlatform.system && !nixosTestRunner
, pulseSupport ? !stdenv.isDarwin && !nixosTestRunner, libpulseaudio
, sdlSupport ? !stdenv.isDarwin && !nixosTestRunner, SDL2
, gtkSupport ? !stdenv.isDarwin && !xenSupport && !nixosTestRunner, gtk3, gettext, vte, wrapGAppsHook
, vncSupport ? !nixosTestRunner, libjpeg, libpng
, smartcardSupport ? !nixosTestRunner, libcacard
, spiceSupport ? !stdenv.isDarwin && !nixosTestRunner, spice, spice-protocol
, ncursesSupport ? !nixosTestRunner, ncurses
, usbredirSupport ? spiceSupport, usbredir
, xenSupport ? false, xen
, cephSupport ? false, ceph
@ -29,7 +31,7 @@
with stdenv.lib;
let
audio = optionalString (hasSuffix "linux" stdenv.hostPlatform.system) "alsa,"
audio = optionalString alsaSupport "alsa,"
+ optionalString pulseSupport "pa,"
+ optionalString sdlSupport "sdl,";
@ -50,10 +52,11 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ python python.pkgs.sphinx pkgconfig flex bison ]
++ optionals gtkSupport [ wrapGAppsHook ];
buildInputs =
[ zlib glib ncurses perl pixman
[ zlib glib perl pixman
vde2 texinfo makeWrapper lzo snappy
gnutls nettle curl
]
++ optionals ncursesSupport [ ncurses ]
++ optionals stdenv.isDarwin [ CoreServices Cocoa Hypervisor rez setfile ]
++ optionals seccompSupport [ libseccomp ]
++ optionals numaSupport [ numactl ]

View file

@ -1,6 +1,6 @@
{ stdenv, fetchFromGitHub, autoreconfHook
, asciidoctor, pkgconfig, xmlto, docbook_xsl, docbook_xml_dtd_45, libxslt
, json_c, kmod, which, utillinux, systemd, keyutils
, json_c, kmod, which, utillinux, udev, keyutils
}:
stdenv.mkDerivation rec {
@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
];
buildInputs =
[ json_c kmod utillinux systemd keyutils
[ json_c kmod utillinux udev keyutils
];
configureFlags =

View file

@ -1,6 +1,6 @@
{ stdenv, fetchFromGitHub
{ stdenv, fetchFromGitHub, fetchpatch
, meson, ninja, pkgconfig, gettext, libxslt, docbook_xsl_ns
, libcap, systemd, libidn2
, libcap, libidn2
}:
with stdenv.lib;
@ -22,18 +22,27 @@ in stdenv.mkDerivation rec {
sha256 = "1jhbcz75a4ij1myyyi110ma1d8d5hpm3scz9pyw7js6qym50xvh4";
};
patches = [
# Proposed upstream patch to reduce dependency on systemd: https://github.com/iputils/iputils/pull/297
(fetchpatch {
url = "https://github.com/iputils/iputils/commit/13d6aefd57fd471ecad06e19073dcc44608dff5e.patch";
sha256 = "1n62zxmzp7hgz9qapbbpqv3fxqvc3qyd2a73jhp357x6by84kj49";
})
];
mesonFlags = [
"-DBUILD_RARPD=true"
"-DBUILD_TRACEROUTE6=true"
"-DBUILD_TFTPD=true"
"-DNO_SETCAP_OR_SUID=true"
"-Dsystemdunitdir=etc/systemd/system"
"-DINSTALL_SYSTEMD_UNITS=true"
]
# Disable idn usage w/musl (https://github.com/iputils/iputils/pull/111):
++ optional stdenv.hostPlatform.isMusl "-DUSE_IDN=false";
nativeBuildInputs = [ meson ninja pkgconfig gettext libxslt.bin docbook_xsl_ns ];
buildInputs = [ libcap systemd ]
buildInputs = [ libcap ]
++ optional (!stdenv.hostPlatform.isMusl) libidn2;
meta = {