Skip to content

Commit b6580ac

Browse files
Do not loose string context unless the nix store is on a disk
1 parent f6e7494 commit b6580ac

File tree

9 files changed

+23
-13
lines changed

9 files changed

+23
-13
lines changed

lib/runners/alioth.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ in {
3131
"--num-cpu" (toString vcpu)
3232
"-k" (lib.escapeShellArg "${kernel}/${pkgs.stdenv.hostPlatform.linux-kernel.target}")
3333
"-i" initrdPath
34-
"-c" (lib.escapeShellArg "console=ttyS0 reboot=k panic=1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}")
34+
"-c" (lib.escapeShellArg "console=ttyS0 reboot=k panic=1 ${toString microvmConfig.kernelParams}")
3535
"--entropy"
3636
]
3737
++

lib/runners/cloud-hypervisor.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let
3535

3636
kernelConsole = lib.optionalString (!hasUserSerial || userSerial == "tty") kernelConsoleDefault;
3737

38-
kernelCmdLine = "${kernelConsole} reboot=t panic=-1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}";
38+
kernelCmdLine = "${kernelConsole} reboot=t panic=-1 ${toString microvmConfig.kernelParams}";
3939

4040

4141
userVSockOpts = (extractOptValues "--vsock" extraArgs).values;

lib/runners/crosvm.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ in {
6161
"-m" (toString mem)
6262
"-c" (toString vcpu)
6363
"--serial" "type=stdout,console=true,stdin=true"
64-
"-p" "console=ttyS0 reboot=k panic=1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}"
64+
"-p" "console=ttyS0 reboot=k panic=1 ${toString microvmConfig.kernelParams}"
6565
]
6666
++
6767
lib.optional (!balloon) "--no-balloon"

lib/runners/firecracker.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let
2323
boot-source = {
2424
kernel_image_path = kernelPath;
2525
initrd_path = initrdPath;
26-
boot_args = "console=ttyS0 noapic acpi=off reboot=k panic=1 i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}";
26+
boot_args = "console=ttyS0 noapic acpi=off reboot=k panic=1 i8042.noaux i8042.nomux i8042.nopnp i8042.dumbkbd ${toString microvmConfig.kernelParams}";
2727
};
2828
machine-config = {
2929
vcpu_count = vcpu;

lib/runners/kvmtool.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ in {
3737
"--rng"
3838
"-k" (lib.escapeShellArg "${kernel}/${pkgs.stdenv.hostPlatform.linux-kernel.target}")
3939
"-i" initrdPath
40-
"-p" (lib.escapeShellArg "console=ttyS0 reboot=k panic=1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}")
40+
"-p" (lib.escapeShellArg "console=ttyS0 reboot=k panic=1 ${toString microvmConfig.kernelParams}")
4141
]
4242
++
4343
lib.optionals storeOnDisk [

lib/runners/qemu.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ lib.warnIf (mem == 2048) ''
209209
lib.optionals (system == "x86_64-linux") [
210210
"-device" "i8042"
211211

212-
"-append" "${kernelConsole} reboot=t panic=-1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}"
212+
"-append" "${kernelConsole} reboot=t panic=-1 ${toString microvmConfig.kernelParams}"
213213
] ++
214214
lib.optionals (system == "aarch64-linux") [
215-
"-append" "${kernelConsole} reboot=t panic=-1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}"
215+
"-append" "${kernelConsole} reboot=t panic=-1 ${toString microvmConfig.kernelParams}"
216216
] ++
217217
lib.optionals storeOnDisk [
218218
"-drive" "id=store,format=raw,read-only=on,file=${storeDisk},if=none,aio=${aioEngine}"

lib/runners/stratovirt.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ in {
9292

9393
"-kernel" "${kernel}/bzImage"
9494
"-initrd" initrdPath
95-
"-append" "console=${console} edd=off reboot=t panic=-1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}"
95+
"-append" "console=${console} edd=off reboot=t panic=-1 ${toString microvmConfig.kernelParams}"
9696

9797
"-serial" "stdio"
9898
"-object" "rng-random,id=rng,filename=/dev/random"

nixos-modules/microvm/store-disk.nix

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{ config, lib, pkgs, ... }:
22

33
let
4-
regInfo = pkgs.closureInfo {
5-
rootPaths = [ config.system.build.toplevel ];
6-
};
4+
regInfo = let
5+
regInfo' = pkgs.closureInfo {
6+
rootPaths = [ config.system.build.toplevel ];
7+
};
8+
in if config.microvm.storeOnDisk then
9+
builtins.unsafeDiscardStringContext regInfo'
10+
else
11+
regInfo';
712

813
erofs-utils =
914
# Are any extended options specified?

nixos-modules/microvm/system.nix

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828
"overlay"
2929
];
3030

31-
microvm.kernelParams = config.boot.kernelParams ++ [
32-
"init=${config.system.build.toplevel}/init"
31+
microvm.kernelParams = let
32+
toplevel = if config.microvm.storeOnDisk then
33+
builtins.unsafeDiscardStringContext config.system.build.toplevel;
34+
else
35+
config.system.build.toplevel
36+
in config.boot.kernelParams ++ [
37+
"init=${toplevel}/init"
3338
];
3439

3540
# modules that consume boot time but have rare use-cases

0 commit comments

Comments
 (0)