Skip to content

Commit 972e6fd

Browse files
Merge pull request #377 from Ramblurr/feat/chv-optional-console
2 parents 4645d6e + a90edd5 commit 972e6fd

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lib/runners/cloud-hypervisor.nix

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,26 @@ let
1010
inherit (microvmConfig) vcpu mem balloon initialBalloonMem deflateOnOOM hotplugMem hotpluggedMem user interfaces volumes shares socket devices hugepageMem graphics storeDisk storeOnDisk kernel initrdPath;
1111
inherit (microvmConfig.cloud-hypervisor) platformOEMStrings extraArgs;
1212

13+
hasUserConsole = (extractOptValues "--console" extraArgs).values != [];
14+
hasUserSerial = (extractOptValues "--serial" extraArgs).values != [];
15+
userSerial = lib.optionalString hasUserSerial (extractOptValues "--serial" extraArgs).values;
16+
1317
kernelPath = {
1418
x86_64-linux = "${kernel.dev}/vmlinux";
1519
aarch64-linux = "${kernel.out}/${pkgs.stdenv.hostPlatform.linux-kernel.target}";
1620
}.${pkgs.stdenv.system};
1721

18-
kernelConsole =
22+
kernelConsoleDefault =
1923
if pkgs.stdenv.system == "x86_64-linux"
2024
then "earlyprintk=ttyS0 console=ttyS0"
2125
else if pkgs.stdenv.system == "aarch64-linux"
2226
then "console=ttyAMA0"
2327
else "";
2428

29+
kernelConsole = lib.optionalString (!hasUserSerial || userSerial == "tty") kernelConsoleDefault;
30+
31+
kernelCmdLine = "${kernelConsole} reboot=t panic=-1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}";
32+
2533
useHotPlugMemory = hotplugMem > 0;
2634

2735
useVirtiofs = builtins.any ({ proto, ... }: proto == "virtiofs") shares;
@@ -147,16 +155,18 @@ in {
147155
)
148156
"--cpus" "boot=${toString vcpu}"
149157
"--watchdog"
150-
"--console" "null"
151-
"--serial" "tty"
152158
"--kernel" kernelPath
153159
"--initramfs" initrdPath
154-
"--cmdline" "${kernelConsole} reboot=t panic=-1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}"
160+
"--cmdline" kernelCmdLine
155161
"--seccomp" "true"
156162
"--memory" memOps
157163
"--platform" platformOps
158164
]
159165
++
166+
lib.optionals (!hasUserConsole) ["--console" "null"]
167+
++
168+
lib.optionals (!hasUserSerial) ["--serial" "tty"]
169+
++
160170
lib.optionals supportsNotifySocket [
161171
"--vsock" "cid=3,socket=notify.vsock"
162172
]

0 commit comments

Comments
 (0)