Skip to content

fix(console): map LF back to CR for Windows SAC CMD - #92

Open
Xirren wants to merge 1 commit into
Droid-VM:masterfrom
Xirren:fix/ems-sac-enter
Open

Xirren wants to merge 1 commit into
Droid-VM:masterfrom
Xirren:fix/ems-sac-enter

Conversation

@Xirren

@Xirren Xirren commented Nov 6, 2026

Copy link
Copy Markdown

问题

droidvm console 只清了 ICANON|ECHO|ISIG,ICRNL 仍在,回车到 guest 时已变成 LF。Windows SAC 接受 LF,但 CMD 频道只认 CR,所以 SAC 正常、cmd 里回车无效。

修复

转发前把 LF 映射回 CR。Linux getty 不受影响:其 ICRNL 会把 CR 再转回 NL。

验证

  • Windows(EMS/SAC,SBSA 串口):SAC 与 CMD 回车正常
  • Alpine Linux:串口 getty 登录正常(未受影响)

参考实现

cloud-hypervisor 的同一问题(#1770)由 PR #1771 修复,做法相同:

// Replace "\n" with "\r" to deal with Windows SAC (#1170)
if count == 1 && out[0] == 0x0a {
    out[0] = 0x0d;
}

cloud-hypervisor/cloud-hypervisor#1770
cloud-hypervisor/cloud-hypervisor#1771

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants