Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: efd5508b8998
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a02bb0015608
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Dec 20, 2016

  1. qemu-kvm: Mark the version for tests

    (cherry picked from commit d58a4ec)
    edolstra committed Dec 20, 2016
    Copy the full SHA
    8a0843c View commit details
  2. virtualisation.qemu.program: Remove

    This option is defined in qemu-vm.nix, but that module is not always
    imported.
    
    http://hydra.nixos.org/build/44817443
    (cherry picked from commit 03c5500)
    edolstra committed Dec 20, 2016
    Copy the full SHA
    aad5d1f View commit details
  3. Use only one build of qemu in VM tests

    Previously we were using two or three (qemu_kvm, qemu_test, and
    qemu_test with a different dbus when minimal.nix is included).
    
    (cherry picked from commit 8bfa4ce)
    edolstra committed Dec 20, 2016
    Copy the full SHA
    f173da3 View commit details
  4. Enable virtualisation.writableStore by default

    This works around:
    
      machine: must succeed: nix-store -qR /run/current-system | grep nixos-
      machine# error: changing ownership of path ‘/nix/store’: Invalid argument
    
    Probably Nix shouldn't be anal about the ownership of the store unless
    it's trying to build/write to the store.
    
    http://hydra.nixos.org/build/45093872/nixlog/17/raw
    (cherry picked from commit 57a0f14)
    edolstra committed Dec 20, 2016
    Copy the full SHA
    a02bb00 View commit details
3 changes: 3 additions & 0 deletions nixos/lib/build-vms.nix
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ rec {

inherit pkgs;

qemu = pkgs.qemu_test;


# Build a virtual network from an attribute set `{ machine1 =
# config1; ... machineN = configN; }', where `machineX' is the
@@ -27,6 +29,7 @@ rec {
[ ../modules/virtualisation/qemu-vm.nix
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
{ key = "no-manual"; services.nixosManual.enable = false; }
{ key = "qemu"; system.build.qemu = qemu; }
] ++ optional minimal ../modules/testing/minimal-kernel.nix;
extraArgs = { inherit nodes; };
};
2 changes: 1 addition & 1 deletion nixos/lib/testing.nix
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ rec {
cp ${./test-driver/Logger.pm} $libDir/Logger.pm
wrapProgram $out/bin/nixos-test-driver \
--prefix PATH : "${lib.makeBinPath [ qemu_kvm vde2 netpbm coreutils ]}" \
--prefix PATH : "${lib.makeBinPath [ qemu vde2 netpbm coreutils ]}" \
--prefix PERL5LIB : "${with perlPackages; lib.makePerlPath [ TermReadLineGnu XMLWriter IOTty FileSlurp ]}:$out/lib/perl5/site_perl"
'';
};
3 changes: 0 additions & 3 deletions nixos/modules/testing/test-instrumentation.nix
Original file line number Diff line number Diff line change
@@ -119,9 +119,6 @@ let kernel = config.boot.kernelPackages.kernel; in

networking.usePredictableInterfaceNames = false;

# Make sure we use a patched QEMU that ignores file ownership.
virtualisation.qemu.program = "${pkgs.qemu_test}/bin/qemu-kvm";

# Make it easy to log in as root when running the test interactively.
users.extraUsers.root.initialHashedPassword = mkOverride 150 "";

22 changes: 8 additions & 14 deletions nixos/modules/virtualisation/qemu-vm.nix
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ with lib;

let

qemu = config.system.build.qemu or pkgs.qemu_test;

vmName =
if config.networking.hostName == ""
then "noname"
@@ -32,7 +34,7 @@ let
NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}})
if ! test -e "$NIX_DISK_IMAGE"; then
${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 "$NIX_DISK_IMAGE" \
${qemu}/bin/qemu-img create -f qcow2 "$NIX_DISK_IMAGE" \
${toString config.virtualisation.diskSize}M || exit 1
fi
@@ -47,7 +49,7 @@ let
${if cfg.useBootLoader then ''
# Create a writable copy/snapshot of the boot disk.
# A writable boot disk can be booted from automatically.
${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 -b ${bootDisk}/disk.img $TMPDIR/disk.img || exit 1
${qemu}/bin/qemu-img create -f qcow2 -b ${bootDisk}/disk.img $TMPDIR/disk.img || exit 1
${if cfg.useEFIBoot then ''
# VM needs a writable flash BIOS.
@@ -63,14 +65,14 @@ let
extraDisks=""
${flip concatMapStrings cfg.emptyDiskImages (size: ''
if ! test -e "empty$idx.qcow2"; then
${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 "empty$idx.qcow2" "${toString size}M"
${qemu}/bin/qemu-img create -f qcow2 "empty$idx.qcow2" "${toString size}M"
fi
extraDisks="$extraDisks -drive index=$idx,file=$(pwd)/empty$idx.qcow2,if=${cfg.qemu.diskInterface},werror=report"
idx=$((idx + 1))
'')}
# Start QEMU.
exec ${cfg.qemu.program} \
exec ${qemu}/bin/qemu-kvm \
-name ${vmName} \
-m ${toString config.virtualisation.memorySize} \
${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \
@@ -121,7 +123,7 @@ let
mkdir $out
diskImage=$out/disk.img
bootFlash=$out/bios.bin
${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 $diskImage "40M"
${qemu}/bin/qemu-img create -f qcow2 $diskImage "40M"
${if cfg.useEFIBoot then ''
cp ${pkgs.OVMF-CSM}/FV/OVMF.fd $bootFlash
chmod 0644 $bootFlash
@@ -272,7 +274,7 @@ in

virtualisation.writableStore =
mkOption {
default = false;
default = true; # FIXME
description =
''
If enabled, the Nix store in the VM is made writable by
@@ -299,14 +301,6 @@ in
};

virtualisation.qemu = {
program = mkOption {
type = types.path;
default = "${pkgs.qemu_kvm}/bin/qemu-kvm";
defaultText = "\${pkgs.qemu_kvm}/bin/qemu-kvm";
example = literalExample "\${pkgs.qemu_test}/bin/qemu-kvm";
description = "The QEMU variant used to start the VM.";
};

options =
mkOption {
type = types.listOf types.unspecified;
5 changes: 4 additions & 1 deletion pkgs/applications/virtualization/qemu/default.nix
Original file line number Diff line number Diff line change
@@ -23,7 +23,10 @@ let
in

stdenv.mkDerivation rec {
name = "qemu-" + stdenv.lib.optionalString x86Only "x86-only-" + version;
name = "qemu-"
+ stdenv.lib.optionalString x86Only "x86-only-"
+ stdenv.lib.optionalString nixosTestRunner "for-vm-tests-"
+ version;

src = fetchurl {
url = "http://wiki.qemu.org/download/qemu-${version}.tar.bz2";