summary refs log tree commit diff
path: root/nixos/lib
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2018-04-30 01:43:17 +0200
committeraszlig <aszlig@nix.build>2018-04-30 03:02:59 +0200
commitf148c5c4a1ffa353836bfd18a94d457acf83bd36 (patch)
tree2a734c863839dcb2b3739160b9eeb2dc91ac22d2 /nixos/lib
parent1907120f23ada097ccf00ba8ac040097c911e9e6 (diff)
downloadnixpkgs-f148c5c4a1ffa353836bfd18a94d457acf83bd36.tar
nixpkgs-f148c5c4a1ffa353836bfd18a94d457acf83bd36.tar.gz
nixpkgs-f148c5c4a1ffa353836bfd18a94d457acf83bd36.tar.bz2
nixpkgs-f148c5c4a1ffa353836bfd18a94d457acf83bd36.tar.lz
nixpkgs-f148c5c4a1ffa353836bfd18a94d457acf83bd36.tar.xz
nixpkgs-f148c5c4a1ffa353836bfd18a94d457acf83bd36.tar.zst
nixpkgs-f148c5c4a1ffa353836bfd18a94d457acf83bd36.zip
nixos/tests: Fix QEMU flags for SCSI disks
The ability to specify "-drive if=scsi" has been removed in QEMU version
2.12 (introduced in 3e3b39f173f9abc99da84084a1f4657c9de885bd).

Quote from https://wiki.qemu.org/ChangeLog/2.12#Incompatible_changes:

> The deprecated way of configuring SCSI devices with "-drive if=scsi"
> on x86 has been removed. Use an appropriate SCSI controller together
> "-device scsi-hd" or "-device scsi-cd" and a corresponding "-blockdev"
> parameter instead.

So whenever the diskInterface is "scsi" we use the new way to specify
the drive and fall back to the deprecated way for the time being. The
reason why I'm not using the new way for "virtio" and "ide" as well is
because there is no simple generic way anymore to specify these.

This also turns the type of the virtualisation.qemu.diskInterface option
to be an enum, so the user knows which values are allowed but we can
also make sure the right value is provided to prevent typos.

I've tested this against a few non-disk-related NixOS VM tests but also
the installer.grub1 test (because it uses "ide" as its drive interface),
the installer.simple test (just to be sure it still works with
"virtio") and all the tests in nixos/tests/boot.nix.

In order to be able to run the grub1 test I had to go back to
8b1cf100cd8badad6e1b6d4650b904b88aa870db (which is a known commit where
that test still works) and apply the QEMU update and this very commit,
because right now the test is broken.

Apart from the tests here in nixpkgs, I also ran another[1] test in
another repository which uses the "scsi" disk interface as well (in
comparison to most of the installer tests, this one actually failed
prior to this commit).

All of them now succeed.

[1]: https://github.com/openlab-aux/vuizvui/blob/9b5a119972e9c2d327500638d89063f4fce243ec/tests/system/kernel/bfq.nix

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @edostra, @grahamc, @dezgeg, @abbradar, @ts468
Diffstat (limited to 'nixos/lib')
-rw-r--r--nixos/lib/test-driver/Machine.pm17
1 files changed, 14 insertions, 3 deletions
diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm
index 7e269b43e70..b18f48464ce 100644
--- a/nixos/lib/test-driver/Machine.pm
+++ b/nixos/lib/test-driver/Machine.pm
@@ -33,9 +33,20 @@ sub new {
         $startCommand =
             "qemu-kvm -m 384 " .
             "-net nic,model=virtio \$QEMU_OPTS ";
-        my $iface = $args->{hdaInterface} || "virtio";
-        $startCommand .= "-drive file=" . Cwd::abs_path($args->{hda}) . ",if=$iface,werror=report "
-            if defined $args->{hda};
+
+        if (defined $args->{hda}) {
+            if ($args->{hdaInterface} eq "scsi") {
+                $startCommand .= "-drive id=hda,file="
+                               . Cwd::abs_path($args->{hda})
+                               . ",werror=report,if=none "
+                               . "-device scsi-hd,drive=hda ";
+            } else {
+                $startCommand .= "-drive file=" . Cwd::abs_path($args->{hda})
+                               . ",if=" . $args->{hdaInterface}
+                               . ",werror=report ";
+            }
+        }
+
         $startCommand .= "-cdrom $args->{cdrom} "
             if defined $args->{cdrom};
         $startCommand .= "-device piix3-usb-uhci -drive id=usbdisk,file=$args->{usb},if=none,readonly -device usb-storage,drive=usbdisk "