about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-06-17 15:40:46 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-06-17 15:47:43 +0200
commitf93d8425c3897467798742d5f9ba871dca4a8e47 (patch)
tree2c1849bd21bfc1e934a0080ef8a1b8afcc63589f /nixos
parent6563dd251fee81b50f5c27bc6e44c91829b51649 (diff)
downloadnixlib-f93d8425c3897467798742d5f9ba871dca4a8e47.tar
nixlib-f93d8425c3897467798742d5f9ba871dca4a8e47.tar.gz
nixlib-f93d8425c3897467798742d5f9ba871dca4a8e47.tar.bz2
nixlib-f93d8425c3897467798742d5f9ba871dca4a8e47.tar.lz
nixlib-f93d8425c3897467798742d5f9ba871dca4a8e47.tar.xz
nixlib-f93d8425c3897467798742d5f9ba871dca4a8e47.tar.zst
nixlib-f93d8425c3897467798742d5f9ba871dca4a8e47.zip
Installer test: Fix booting from SCSI
This is required by the GRUB 1 test.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix25
-rw-r--r--nixos/tests/installer.nix5
2 files changed, 25 insertions, 5 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index dcb498493fa2..15b0da3bab74 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -62,7 +62,7 @@ let
       extraDisks=""
       ${flip concatMapStrings cfg.emptyDiskImages (size: ''
         ${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 "empty$idx.qcow2" "${toString size}M"
-        extraDisks="$extraDisks -drive index=$idx,file=$(pwd)/empty$idx.qcow2,if=virtio,werror=report"
+        extraDisks="$extraDisks -drive index=$idx,file=$(pwd)/empty$idx.qcow2,if=${cfg.qemu.diskInterface},werror=report"
         idx=$((idx + 1))
       '')}
 
@@ -76,14 +76,14 @@ let
           -virtfs local,path=$TMPDIR/xchg,security_model=none,mount_tag=xchg \
           -virtfs local,path=''${SHARED_DIR:-$TMPDIR/xchg},security_model=none,mount_tag=shared \
           ${if cfg.useBootLoader then ''
-            -drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=virtio,cache=writeback,werror=report \
+            -drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=${cfg.qemu.diskInterface},cache=writeback,werror=report \
             -drive index=1,id=drive2,file=$TMPDIR/disk.img,media=disk \
             ${if cfg.useEFIBoot then ''
               -pflash $TMPDIR/bios.bin \
             '' else ''
             ''}
           '' else ''
-            -drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=virtio,cache=writeback,werror=report \
+            -drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=${cfg.qemu.diskInterface},cache=writeback,werror=report \
             -kernel ${config.system.build.toplevel}/kernel \
             -initrd ${config.system.build.toplevel}/initrd \
             -append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo} ${kernelConsole} $QEMU_KERNEL_PARAMS" \
@@ -207,7 +207,7 @@ in
     virtualisation.bootDevice =
       mkOption {
         type = types.str;
-        default = "/dev/vda";
+        example = "/dev/vda";
         description =
           ''
             The disk to be used for the root filesystem.
@@ -318,6 +318,17 @@ in
             to keep the default runtime behaviour.
           '';
         };
+
+      diskInterface =
+        mkOption {
+          default = "virtio";
+          example = "scsi";
+          type = types.str;
+          description = ''
+            The interface used for the virtual hard disks
+            (<literal>virtio</literal> or <literal>scsi</literal>).
+          '';
+        };
     };
 
     virtualisation.useBootLoader =
@@ -393,6 +404,12 @@ in
         fi
       '';
 
+    boot.initrd.availableKernelModules =
+      optional (cfg.qemu.diskInterface == "scsi") "sym53c8xx";
+
+    virtualisation.bootDevice =
+      mkDefault (if cfg.qemu.diskInterface == "scsi" then "/dev/sda" else "/dev/vda");
+
     virtualisation.pathsInNixDB = [ config.system.build.toplevel ];
 
     virtualisation.qemu.options = [ "-vga std" "-usbdevice tablet" ];
diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix
index 4feed56cd67c..32be1ea23b98 100644
--- a/nixos/tests/installer.nix
+++ b/nixos/tests/installer.nix
@@ -175,7 +175,10 @@ let
             # installer. This ensures the target disk (/dev/vda) is
             # the same during and after installation.
             virtualisation.emptyDiskImages = [ 512 ];
-            virtualisation.bootDevice = "/dev/vdb";
+            virtualisation.bootDevice =
+              if grubVersion == 1 then "/dev/sdb" else "/dev/vdb";
+            virtualisation.qemu.diskInterface =
+              if grubVersion == 1 then "scsi" else "virtio";
 
             hardware.enableAllFirmware = mkForce false;