From 70bc991572ff970b252c012a3c9bfa62e362552e Mon Sep 17 00:00:00 2001 From: xirren Date: Sat, 7 Nov 2026 01:09:28 +0800 Subject: [PATCH] fix(console): map LF back to CR for Windows SAC CMD The console client leaves ICRNL set, so Enter reaches the guest as LF. SAC accepts LF, but its CMD channel only treats CR as Enter. Convert LF back to CR before forwarding; Linux getty's ICRNL turns it back into NL. Reference: cloud-hypervisor#1770, fixed in PR #1771. --- app/src/main/cpp/console/commands/console.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/cpp/console/commands/console.cpp b/app/src/main/cpp/console/commands/console.cpp index 817d5d318..dda1c649b 100644 --- a/app/src/main/cpp/console/commands/console.cpp +++ b/app/src/main/cpp/console/commands/console.cpp @@ -269,6 +269,14 @@ void ConsoleCommand::console_attach( warned = true; } } else { + // The tty line discipline still has ICRNL set (we only touch + // c_lflag above), so the Enter key arrives here as LF. Windows + // SAC accepts LF, but the CMD channel's console only treats CR + // as Enter, so map LF back to CR before it reaches the guest. + // Linux getty is unaffected: its ICRNL turns CR back into NL. + // Same fix as cloud-hypervisor#1770 / PR #1771. + for (ssize_t i = 0; i < n; i++) + if (buf[i] == '\n') buf[i] = '\r'; Json::Value write_req; write_req["command"] = "vm_console_write"; write_req["vm_id"] = filter_vm;