diff options
-rw-r--r-- | nixos/modules/virtualisation/qemu-vm.nix | 25 | ||||
-rw-r--r-- | nixos/tests/installer.nix | 5 |
2 files changed, 25 insertions, 5 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index dcb498493fa2b..15b0da3bab740 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 4feed56cd67ce..32be1ea23b985 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; |