|
10 | 10 | inherit (microvmConfig) vcpu mem balloon initialBalloonMem deflateOnOOM hotplugMem hotpluggedMem user interfaces volumes shares socket devices hugepageMem graphics storeDisk storeOnDisk kernel initrdPath; |
11 | 11 | inherit (microvmConfig.cloud-hypervisor) platformOEMStrings extraArgs; |
12 | 12 |
|
| 13 | + hasUserConsole = (extractOptValues "--console" extraArgs).values != []; |
| 14 | + hasUserSerial = (extractOptValues "--serial" extraArgs).values != []; |
| 15 | + userSerial = lib.optionalString hasUserSerial (extractOptValues "--serial" extraArgs).values; |
| 16 | + |
13 | 17 | kernelPath = { |
14 | 18 | x86_64-linux = "${kernel.dev}/vmlinux"; |
15 | 19 | aarch64-linux = "${kernel.out}/${pkgs.stdenv.hostPlatform.linux-kernel.target}"; |
16 | 20 | }.${pkgs.stdenv.system}; |
17 | 21 |
|
18 | | - kernelConsole = |
| 22 | + kernelConsoleDefault = |
19 | 23 | if pkgs.stdenv.system == "x86_64-linux" |
20 | 24 | then "earlyprintk=ttyS0 console=ttyS0" |
21 | 25 | else if pkgs.stdenv.system == "aarch64-linux" |
22 | 26 | then "console=ttyAMA0" |
23 | 27 | else ""; |
24 | 28 |
|
| 29 | + kernelConsole = lib.optionalString (!hasUserSerial || userSerial == "tty") kernelConsoleDefault; |
| 30 | + |
| 31 | + kernelCmdLine = "${kernelConsole} reboot=t panic=-1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}"; |
| 32 | + |
25 | 33 | useHotPlugMemory = hotplugMem > 0; |
26 | 34 |
|
27 | 35 | useVirtiofs = builtins.any ({ proto, ... }: proto == "virtiofs") shares; |
@@ -147,16 +155,18 @@ in { |
147 | 155 | ) |
148 | 156 | "--cpus" "boot=${toString vcpu}" |
149 | 157 | "--watchdog" |
150 | | - "--console" "null" |
151 | | - "--serial" "tty" |
152 | 158 | "--kernel" kernelPath |
153 | 159 | "--initramfs" initrdPath |
154 | | - "--cmdline" "${kernelConsole} reboot=t panic=-1 ${builtins.unsafeDiscardStringContext (toString microvmConfig.kernelParams)}" |
| 160 | + "--cmdline" kernelCmdLine |
155 | 161 | "--seccomp" "true" |
156 | 162 | "--memory" memOps |
157 | 163 | "--platform" platformOps |
158 | 164 | ] |
159 | 165 | ++ |
| 166 | + lib.optionals (!hasUserConsole) ["--console" "null"] |
| 167 | + ++ |
| 168 | + lib.optionals (!hasUserSerial) ["--serial" "tty"] |
| 169 | + ++ |
160 | 170 | lib.optionals supportsNotifySocket [ |
161 | 171 | "--vsock" "cid=3,socket=notify.vsock" |
162 | 172 | ] |
|
0 commit comments