about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJamie McClymont <jamie@kwiius.com>2020-05-22 15:15:32 +1200
committerJamie McClymont <jamie@kwiius.com>2020-06-08 11:21:53 +1200
commit55912f3535217910b12e81f07fb10d70511a471b (patch)
treea2d4075cc7f4acc315f4e4081ad9fc0566375373
parent2defee2981107428aae547773ddcf2cab65d2c6f (diff)
downloadnixlib-55912f3535217910b12e81f07fb10d70511a471b.tar
nixlib-55912f3535217910b12e81f07fb10d70511a471b.tar.gz
nixlib-55912f3535217910b12e81f07fb10d70511a471b.tar.bz2
nixlib-55912f3535217910b12e81f07fb10d70511a471b.tar.lz
nixlib-55912f3535217910b12e81f07fb10d70511a471b.tar.xz
nixlib-55912f3535217910b12e81f07fb10d70511a471b.tar.zst
nixlib-55912f3535217910b12e81f07fb10d70511a471b.zip
nixos/qemu-vm: add option to use a non-standard BIOS
I'd like to change the default on x86 platforms to qboot at some point, since it
saves a fair bit of startup time.
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix15
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/qboot.nix13
-rw-r--r--pkgs/applications/virtualization/qboot/default.nix4
4 files changed, 32 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index ac86330c098b..42776e80ffef 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -441,6 +441,18 @@ in
           '';
       };
 
+    virtualisation.bios =
+      mkOption {
+        default = null;
+        type = types.nullOr types.package;
+        description =
+          ''
+            An alternate BIOS (such as <package>qboot</package>) with which to start the VM.
+            Should containin a file named <literal>bios.bin</literal>.
+            If <literal>null</literal>, QEMU's builtin SeaBIOS will be used.
+          '';
+      };
+
   };
 
   config = {
@@ -521,6 +533,9 @@ in
       (mkIf cfg.useEFIBoot [
         "-pflash $TMPDIR/bios.bin"
       ])
+      (mkIf (cfg.bios != null) [
+        "-bios ${cfg.bios}/bios.bin"
+      ])
       (mkIf (!cfg.graphics) [
         "-nographic"
       ])
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 796c626f3dde..8e262d8eee7d 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -273,6 +273,7 @@ in
   prosody = handleTest ./xmpp/prosody.nix {};
   prosodyMysql = handleTest ./xmpp/prosody-mysql.nix {};
   proxy = handleTest ./proxy.nix {};
+  qboot = handleTestOn ["x86_64-linux" "i686-linux"] ./qboot.nix {};
   quagga = handleTest ./quagga.nix {};
   quorum = handleTest ./quorum.nix {};
   rabbitmq = handleTest ./rabbitmq.nix {};
diff --git a/nixos/tests/qboot.nix b/nixos/tests/qboot.nix
new file mode 100644
index 000000000000..12aef6decfae
--- /dev/null
+++ b/nixos/tests/qboot.nix
@@ -0,0 +1,13 @@
+import ./make-test-python.nix ({ pkgs, ...} : {
+  name = "qboot";
+
+  machine = { ... }: {
+    virtualisation.bios = pkgs.qboot;
+  };
+
+  testScript =
+    ''
+      start_all()
+      machine.wait_for_unit("multi-user.target")
+    '';
+})
diff --git a/pkgs/applications/virtualization/qboot/default.nix b/pkgs/applications/virtualization/qboot/default.nix
index 800d601c76e6..8d1f9dac2e51 100644
--- a/pkgs/applications/virtualization/qboot/default.nix
+++ b/pkgs/applications/virtualization/qboot/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, meson, ninja, fetchFromGitHub }:
+{ stdenv, meson, ninja, fetchFromGitHub, nixosTests }:
 
 stdenv.mkDerivation {
   name = "qboot-20200423";
@@ -19,6 +19,8 @@ stdenv.mkDerivation {
 
   hardeningDisable = [ "stackprotector" "pic" ];
 
+  passthru.tests = { qboot = nixosTests.qboot; };
+
   meta = {
     description = "A simple x86 firmware for booting Linux";
     homepage = "https://github.com/bonzini/qboot";