about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-06-14 21:54:39 +0000
committerAlyssa Ross <hi@alyssa.is>2023-11-06 13:49:31 +0100
commit8ab2f09522d5aefabf1100b3f59a3bde628cb2b4 (patch)
tree92ea009eec2ea34a84763708ff60808005f4d93c /nixos
parenta29cae7046d725a77dc2611dfaf2c69fe103f609 (diff)
downloadnixlib-8ab2f09522d5aefabf1100b3f59a3bde628cb2b4.tar
nixlib-8ab2f09522d5aefabf1100b3f59a3bde628cb2b4.tar.gz
nixlib-8ab2f09522d5aefabf1100b3f59a3bde628cb2b4.tar.bz2
nixlib-8ab2f09522d5aefabf1100b3f59a3bde628cb2b4.tar.lz
nixlib-8ab2f09522d5aefabf1100b3f59a3bde628cb2b4.tar.xz
nixlib-8ab2f09522d5aefabf1100b3f59a3bde628cb2b4.tar.zst
nixlib-8ab2f09522d5aefabf1100b3f59a3bde628cb2b4.zip
nixos/qemu-vm: fix infinite recursion
The virtualisation.directBoot.initrd option was added for netboot
images, but the assertion to check directBoot enabled if it was used
caused an infinite recursion if it was.  Minimal reproduction:

	import nixos/tests/make-test-python.nix ({ pkgs, ... }: {
	  name = "";

	  nodes = {
	    machine = { config, ...}: {
	      imports = [ nixos/modules/installer/netboot/netboot-minimal.nix ];

	      virtualisation.directBoot = {
	        enable = true;
	        initrd = "${config.system.build.netbootRamdisk}/${config.system.boot.loader.initrdFile}";
	      };
	    };
	  };
	  testScript = "";
	}) {}

The fix is to swap the two conditions, so that cfg.directBoot.enable
is checked first, and the initrd comparision will be short circuited.

This wasn't noticed during review because in earlier versions of the
virtualisation.directBoot patch, the assertion was accidentally in the
conditional above, so wasn't evaluated unless port forwarding was in
use.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/virtualisation/qemu-vm.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix
index e625c6322d9c..6f275baf60dc 100644
--- a/nixos/modules/virtualisation/qemu-vm.nix
+++ b/nixos/modules/virtualisation/qemu-vm.nix
@@ -997,7 +997,7 @@ in
               virtualisation.memorySize is above 2047, but qemu is only able to allocate 2047MB RAM on 32bit max.
             '';
           }
-          { assertion = cfg.directBoot.initrd != options.virtualisation.directBoot.initrd.default -> cfg.directBoot.enable;
+          { assertion = cfg.directBoot.enable || cfg.directBoot.initrd == options.virtualisation.directBoot.initrd.default;
             message =
               ''
                 You changed the default of `virtualisation.directBoot.initrd` but you are not