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 8bfa4ce82ea7d23a1d4c6073bcc044e6bf9c4dbe)
This commit is contained in:
parent
aad5d1f9a7
commit
f173da375d
@ -9,6 +9,8 @@ rec {
|
|||||||
|
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
|
|
||||||
|
qemu = pkgs.qemu_test;
|
||||||
|
|
||||||
|
|
||||||
# Build a virtual network from an attribute set `{ machine1 =
|
# Build a virtual network from an attribute set `{ machine1 =
|
||||||
# config1; ... machineN = configN; }', where `machineX' is the
|
# config1; ... machineN = configN; }', where `machineX' is the
|
||||||
@ -27,6 +29,7 @@ rec {
|
|||||||
[ ../modules/virtualisation/qemu-vm.nix
|
[ ../modules/virtualisation/qemu-vm.nix
|
||||||
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
|
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
|
||||||
{ key = "no-manual"; services.nixosManual.enable = false; }
|
{ key = "no-manual"; services.nixosManual.enable = false; }
|
||||||
|
{ key = "qemu"; system.build.qemu = qemu; }
|
||||||
] ++ optional minimal ../modules/testing/minimal-kernel.nix;
|
] ++ optional minimal ../modules/testing/minimal-kernel.nix;
|
||||||
extraArgs = { inherit nodes; };
|
extraArgs = { inherit nodes; };
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ rec {
|
|||||||
cp ${./test-driver/Logger.pm} $libDir/Logger.pm
|
cp ${./test-driver/Logger.pm} $libDir/Logger.pm
|
||||||
|
|
||||||
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 vde2 netpbm coreutils ]}" \
|
||||||
--prefix PERL5LIB : "${with perlPackages; lib.makePerlPath [ TermReadLineGnu XMLWriter IOTty FileSlurp ]}:$out/lib/perl5/site_perl"
|
--prefix PERL5LIB : "${with perlPackages; lib.makePerlPath [ TermReadLineGnu XMLWriter IOTty FileSlurp ]}:$out/lib/perl5/site_perl"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,8 @@ with lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
qemu = config.system.build.qemu or pkgs.qemu_test;
|
||||||
|
|
||||||
vmName =
|
vmName =
|
||||||
if config.networking.hostName == ""
|
if config.networking.hostName == ""
|
||||||
then "noname"
|
then "noname"
|
||||||
@ -32,7 +34,7 @@ let
|
|||||||
NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}})
|
NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}})
|
||||||
|
|
||||||
if ! test -e "$NIX_DISK_IMAGE"; then
|
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
|
${toString config.virtualisation.diskSize}M || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ let
|
|||||||
${if cfg.useBootLoader then ''
|
${if cfg.useBootLoader then ''
|
||||||
# Create a writable copy/snapshot of the boot disk.
|
# Create a writable copy/snapshot of the boot disk.
|
||||||
# A writable boot disk can be booted from automatically.
|
# 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 ''
|
${if cfg.useEFIBoot then ''
|
||||||
# VM needs a writable flash BIOS.
|
# VM needs a writable flash BIOS.
|
||||||
@ -63,14 +65,14 @@ let
|
|||||||
extraDisks=""
|
extraDisks=""
|
||||||
${flip concatMapStrings cfg.emptyDiskImages (size: ''
|
${flip concatMapStrings cfg.emptyDiskImages (size: ''
|
||||||
if ! test -e "empty$idx.qcow2"; then
|
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
|
fi
|
||||||
extraDisks="$extraDisks -drive index=$idx,file=$(pwd)/empty$idx.qcow2,if=${cfg.qemu.diskInterface},werror=report"
|
extraDisks="$extraDisks -drive index=$idx,file=$(pwd)/empty$idx.qcow2,if=${cfg.qemu.diskInterface},werror=report"
|
||||||
idx=$((idx + 1))
|
idx=$((idx + 1))
|
||||||
'')}
|
'')}
|
||||||
|
|
||||||
# Start QEMU.
|
# Start QEMU.
|
||||||
exec ${pkgs.qemu_test}/bin/qemu-kvm \
|
exec ${qemu}/bin/qemu-kvm \
|
||||||
-name ${vmName} \
|
-name ${vmName} \
|
||||||
-m ${toString config.virtualisation.memorySize} \
|
-m ${toString config.virtualisation.memorySize} \
|
||||||
${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \
|
${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \
|
||||||
@ -121,7 +123,7 @@ let
|
|||||||
mkdir $out
|
mkdir $out
|
||||||
diskImage=$out/disk.img
|
diskImage=$out/disk.img
|
||||||
bootFlash=$out/bios.bin
|
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 ''
|
${if cfg.useEFIBoot then ''
|
||||||
cp ${pkgs.OVMF-CSM}/FV/OVMF.fd $bootFlash
|
cp ${pkgs.OVMF-CSM}/FV/OVMF.fd $bootFlash
|
||||||
chmod 0644 $bootFlash
|
chmod 0644 $bootFlash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user