@@ -32,21 +32,15 @@ let
3232 # expressions and shell script stuff.
3333 mkDiskIfaceDriveFlag = idx: driveArgs: let
3434 inherit (cfg.qemu) diskInterface;
35− isSCSI = diskInterface == "scsi";
3635 # The drive identifier created by incrementing the index by one using the
3736 # shell.
3837 drvId = "drive$((${idx} + 1))";
39− dvcId = "${diskInterface}$((${idx} + 1))";
4038 # NOTE: DO NOT shell escape, because this may contain shell variables.
41− commonDriveArgs = "media=disk,id=${drvId},${driveArgs}";
42− commonInterfaceArgs = "drive=${drvId},id=${dvcId},bootindex=${idx}";
43− in lib.concatStrings [
44− "-drive ${commonDriveArgs},if=none "
45− ''${if isSCSI then
46− "-device lsi53c895a -device ${diskInterface}-hd,${commonInterfaceArgs}"
47− else
48− "-device virtio-blk-pci,scsi=off,${commonInterfaceArgs}"} ''
49− ];
39+ commonArgs = "index=${idx},id=${drvId},${driveArgs}";
40+ isSCSI = diskInterface == "scsi";
41+ devArgs = "${diskInterface}-hd,drive=${drvId}";
42+ args = "-drive ${commonArgs},if=none -device lsi53c895a -device ${devArgs}";
43+ in if isSCSI then args else "-drive ${commonArgs},if=${diskInterface}";
5044
5145 # Shell script to start the VM.
5246 startVM =
@@ -103,15 +97,15 @@ let
10397 -virtfs local,path=/nix/store,security_model=none,mount_tag=store \
10498 -virtfs local,path=$TMPDIR/xchg,security_model=none,mount_tag=xchg \
10599 -virtfs local,path=''${SHARED_DIR:-$TMPDIR/xchg},security_model=none,mount_tag=shared \
106− ${mkDiskIfaceDriveFlag "1" "file=$NIX_DISK_IMAGE,media=disk,cache=writeback,werror=report"} \
107100 ${if cfg.useBootLoader then ''
108− -boot menu=on \
109− ${mkDiskIfaceDriveFlag "0" "file=$TMPDIR/disk.img,media=disk"} \
101+ ${mkDiskIfaceDriveFlag "0" "file=$NIX_DISK_IMAGE,cache=writeback,werror=report"} \
102+ ${mkDiskIfaceDriveFlag "1" "file=$TMPDIR/disk.img,media=disk"} \
110103 ${if cfg.useEFIBoot then ''
111104 -pflash $TMPDIR/bios.bin \
112105 '' else ''
113− \''}
114− '' else '' \
106+ ''}
107+ '' else ''
108+ ${mkDiskIfaceDriveFlag "0" "file=$NIX_DISK_IMAGE,cache=writeback,werror=report"} \
115109 -kernel ${config.system.build.toplevel}/kernel \
116110 -initrd ${config.system.build.toplevel}/initrd \
117111 -append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo}/registration ${consoles} $QEMU_KERNEL_PARAMS" \
@@ -147,9 +141,8 @@ let
147141 '';
148142 buildInputs = [ pkgs.utillinux ];
149143 QEMU_OPTS = if cfg.useEFIBoot
150− then "-pflash $out/bios.bin -nographic"
151− else "-nographic";
152− diskInterface = cfg.qemu.diskInterface;
144+ then "-pflash $out/bios.bin -nographic -serial pty"
145+ else "-nographic -serial pty";
153146 }
154147 ''
155148 # Create a /boot EFI partition with 40M and arbitrary but fixed GUIDs for reproducibility
@@ -162,10 +155,10 @@ let
162155 --partition-guid=1:1C06F03B-704E-4657-B9CD-681A087A2FDC \
163156 --partition-guid=2:970C694F-AFD0-4B99-B750-CDB7A329AB6F \
164157 --hybrid 2 \
165− --recompute-chs ${config.virtualisation.bootDevice}
166− ${pkgs.dosfstools}/bin/mkfs.fat -F16 ${config.virtualisation.bootDevice}2
158+ --recompute-chs /dev/vda
159+ ${pkgs.dosfstools}/bin/mkfs.fat -F16 /dev/vda2
167160 export MTOOLS_SKIP_CHECK=1
168− ${pkgs.mtools}/bin/mlabel -i ${config.virtualisation.bootDevice}2 ::boot
161+ ${pkgs.mtools}/bin/mlabel -i /dev/vda2 ::boot
169162
170163 # Mount /boot; load necessary modules first.
171164 ${pkgs.kmod}/bin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/nls/nls_cp437.ko.xz || true
@@ -174,11 +167,11 @@ let
174167 ${pkgs.kmod}/bin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/fat/vfat.ko.xz || true
175168 ${pkgs.kmod}/bin/insmod ${pkgs.linux}/lib/modules/*/kernel/fs/efivarfs/efivarfs.ko.xz || true
176169 mkdir /boot
177− mount ${config.virtualisation.bootDevice}2 /boot
170+ mount /dev/vda2 /boot
178171
179172 # This is needed for GRUB 0.97, which doesn't know about virtio devices.
180173 mkdir /boot/grub
181− echo '(hd0) ${config.virtualisation.bootDevice}' > /boot/grub/device.map
174+ echo '(hd0) /dev/vda' > /boot/grub/device.map
182175
183176 # Install GRUB and generate the GRUB boot menu.
184177 touch /etc/NIXOS
@@ -471,8 +464,7 @@ in
471464
472465 boot.initrd.availableKernelModules =
473466 optional cfg.writableStore "overlay"
474− ++ optional (cfg.qemu.diskInterface == "scsi") "sym53c8xx"
475− ++ optional (cfg.qemu.diskInterface == "scsi") "virtio_scsi";
467+ ++ optional (cfg.qemu.diskInterface == "scsi") "sym53c8xx";
476468
477469 virtualisation.bootDevice =
478470 mkDefault (if cfg.qemu.diskInterface == "scsi" then "/dev/sda" else "/dev/vda");