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