Arrow key not functional in QEMU monitor when using nographic on Windows 11 host
Host environment
- Operating system: Windows 11 22H2
- OS/kernel version: OS build 22621.1702
- Architecture: x86_64
- QEMU flavor: qemu-system-arm
- QEMU version: QEMU emulator version 8.0.0 (v8.0.0-12024-gd6b71850be-dirty)
- QEMU command line:
./qemu-system-arm -s -S -M virt -nographic
Emulated/Virtualized environment
- Operating system: Linux
- OS/kernel version: v6.1
- Architecture: ARM
Description of problem
The arrow keys do not work on the Windows QEMU when using -nographic option. On the Linux QEMU they work.
Steps to reproduce
- Download the qemu source code from https://download.qemu.org/qemu-8.0.0.tar.xz. THe sha256sum of the file is bb60f0341531181d6cc3969dd19a013d0427a87f918193970d9adb91131e56d0.
- Prepare the build system on MSYS2 according to the instructions on https://wiki.qemu.org/Hosts/W32#Native_builds_with_MSYS2.
- Uncompress the source code using
tar -xf qemu-8.0.0.tar.xz
. - Change the working directory to qemu-8.0.0/. The build configuration command is
./configure --target-list=arm-softmmu --extra-cflags="-g -ggdb"
- Run the command
./qemu-system-arm -s -S -M virt -nographic
. - Press Ctrl-C A to switch to QEMU monitor.
- Input "help" command to the monitor.
- Press Arrow-Up key.
- The previous "help" command does not appear in the monitor prompt.
Additional information
- The pre-built binary downloaded from https://qemu.weilnetz.de/w64/qemu-w64-setup-20230424.exe has the same behaviour.
- The QEMU from MSYS2,
pacman -S mingw-w64-x86_64-qemu
, has the same behaviour. - If the "-nographic" option is removed, the arrow-up key works in the GTK console.
- Neither of arrow-up, arrow-down, arrow-right, arrow-left key work.
- If the valid kernel and rootfs are added in the command line by "-kernel" and "-initrd" options, neither key work after booting to the Linux successfully.
- If the code
dwMode |= ENABLE_LINE_INPUT;
in the functionqemu_chr_open_stdio()
is changed todwMode |= ENABLE_LINE_INPUT|ENABLE_VIRTUAL_TERMINAL_INPUT;
, build again. All arrow keys work. - The VT sequence support was added in
EmulatorPkg/Win/Host/WinThunk.c
by this commit edk2@5601e90d. - The above commit is to add VT sequence support at compile-time. Microsoft provides some code to enable it at run-time on https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example-of-enabling-virtual-terminal-processing.
- The function readline_handle_byte() is not called when the VT sequence is not enabled.