Installer test: Fix booting from SCSI

This is required by the GRUB 1 test.
This commit is contained in:
Eelco Dolstra 2015-06-17 15:40:46 +02:00
parent 6563dd251f
commit f93d8425c3
2 changed files with 25 additions and 5 deletions

View file

@ -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" ];

View file

@ -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;