From 8ab2f09522d5aefabf1100b3f59a3bde628cb2b4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 14 Jun 2023 21:54:39 +0000 Subject: [PATCH] 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. --- nixos/modules/virtualisation/qemu-vm.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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