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

View file

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

View file

@ -116,6 +116,10 @@ with import ../../lib/qemu-flags.nix { inherit pkgs; };
users.users.root.initialHashedPassword = mkOverride 150 ""; users.users.root.initialHashedPassword = mkOverride 150 "";
services.xserver.displayManager.job.logToJournal = true; 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; default = false;
description = "Whether to enable the qemu guest agent."; 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 ( config = mkIf cfg.enable (
@ -25,7 +30,7 @@ in {
systemd.services.qemu-guest-agent = { systemd.services.qemu-guest-agent = {
description = "Run the QEMU Guest Agent"; description = "Run the QEMU Guest Agent";
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.qemu.ga}/bin/qemu-ga"; ExecStart = "${cfg.package}/bin/qemu-ga";
Restart = "always"; Restart = "always";
RestartSec = 0; RestartSec = 0;
}; };

View file

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

View file

@ -1,6 +1,6 @@
{ stdenv, fetchFromGitHub, autoreconfHook { stdenv, fetchFromGitHub, autoreconfHook
, asciidoctor, pkgconfig, xmlto, docbook_xsl, docbook_xml_dtd_45, libxslt , 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 { stdenv.mkDerivation rec {
@ -22,7 +22,7 @@ stdenv.mkDerivation rec {
]; ];
buildInputs = buildInputs =
[ json_c kmod utillinux systemd keyutils [ json_c kmod utillinux udev keyutils
]; ];
configureFlags = configureFlags =

View file

@ -1,6 +1,6 @@
{ stdenv, fetchFromGitHub { stdenv, fetchFromGitHub, fetchpatch
, meson, ninja, pkgconfig, gettext, libxslt, docbook_xsl_ns , meson, ninja, pkgconfig, gettext, libxslt, docbook_xsl_ns
, libcap, systemd, libidn2 , libcap, libidn2
}: }:
with stdenv.lib; with stdenv.lib;
@ -22,18 +22,27 @@ in stdenv.mkDerivation rec {
sha256 = "1jhbcz75a4ij1myyyi110ma1d8d5hpm3scz9pyw7js6qym50xvh4"; 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 = [ mesonFlags = [
"-DBUILD_RARPD=true" "-DBUILD_RARPD=true"
"-DBUILD_TRACEROUTE6=true" "-DBUILD_TRACEROUTE6=true"
"-DBUILD_TFTPD=true" "-DBUILD_TFTPD=true"
"-DNO_SETCAP_OR_SUID=true" "-DNO_SETCAP_OR_SUID=true"
"-Dsystemdunitdir=etc/systemd/system" "-Dsystemdunitdir=etc/systemd/system"
"-DINSTALL_SYSTEMD_UNITS=true"
] ]
# Disable idn usage w/musl (https://github.com/iputils/iputils/pull/111): # Disable idn usage w/musl (https://github.com/iputils/iputils/pull/111):
++ optional stdenv.hostPlatform.isMusl "-DUSE_IDN=false"; ++ optional stdenv.hostPlatform.isMusl "-DUSE_IDN=false";
nativeBuildInputs = [ meson ninja pkgconfig gettext libxslt.bin docbook_xsl_ns ]; nativeBuildInputs = [ meson ninja pkgconfig gettext libxslt.bin docbook_xsl_ns ];
buildInputs = [ libcap systemd ] buildInputs = [ libcap ]
++ optional (!stdenv.hostPlatform.isMusl) libidn2; ++ optional (!stdenv.hostPlatform.isMusl) libidn2;
meta = { meta = {