id = 2843 title = "Strange stdin/out <-> console issue (paste problem) . May be char-win-stdio.c bug." state = "opened" created_at = "2025-02-26T11:33:58.282Z" closed_at = "n/a" labels = ["Chardev"] url = "https://gitlab.com/qemu-project/qemu/-/issues/2843" host-os = "Windows 10 22H2" host-arch = "x86" qemu-version = "9.2.50" guest-os = "Linux|FreeBSD" guest-arch = "x86" description = """I was trying to execute QEMU with VM from command line(shell) and work inside a VM within that initial console. All goes well except... pasting from clipboard. Pastings from clipboard are truncated to somewhat less (no more) then a terminal width (in columns). I understand that it seems to be far from QEMU but I tried different terminals/shells/guest systems with the same result. The only things remain the same - QEMU.""" reproduce = """In Windows open a console (shell). Run QEMU with guest serial attached to QEMU stdio. Try to paste some text. Pasted text will be truncated to 15-35 characters. Before QEMU run and after QEMU exit text pasted normally.""" additional = """- Shell probed: **cmd**, **powershell** - Terminals probed: **Windows Terminal**, **Alacritty**, **Wezterm**, **Windows Terminal Preview** - Guest probed: **Alpine Linux**, **FreeBSD** - Setting inside guest probed: various terminal speed/options via **stty** - QEMU arguments probed: from **-nographics** to manually define **-chardev/-serial** with/without **-mon**. Finally I gave up. But want to mention that there are may be bug in source. When I tried to study source to find a hint for my issue I found that (char-win-stdio.c, line 162): ``` is_console = GetConsoleMode(stdio->hStdIn, &dwMode) != 0; stdio->dwOldMode = dwMode; if (is_console) { ``` Documentation of **GetConsoleMode** function says: ``` Return value: If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. ``` If understand correctly **is_console** will always be _true_. It will be _false_ only in case of invalid **stdio->hStdIn**. I don't how this is related to my issue just put here all info I have in hope of resolving."""