[PATCH] chardev/char-win-stdio: Fix keyboard input after exit Qemu on

Irina Ryapolova posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240324152150.21506-1-irina.ryapolova@syntacore.com
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
chardev/char-win-stdio.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] chardev/char-win-stdio: Fix keyboard input after exit Qemu on
Posted by Irina Ryapolova 1 month ago
After exit Qemu need to return the terminal to the default state.

Signed-off-by: Irina Ryapolova <irina.ryapolova@syntacore.com>
---
 chardev/char-win-stdio.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c
index 1a18999e78..4fa2c3de8b 100644
--- a/chardev/char-win-stdio.c
+++ b/chardev/char-win-stdio.c
@@ -220,6 +220,7 @@ err1:
 static void char_win_stdio_finalize(Object *obj)
 {
     WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj);
+    DWORD dwMode;
 
     if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
         CloseHandle(stdio->hInputReadyEvent);
@@ -230,6 +231,10 @@ static void char_win_stdio_finalize(Object *obj)
     if (stdio->hInputThread != INVALID_HANDLE_VALUE) {
         TerminateThread(stdio->hInputThread, 0);
     }
+
+    GetConsoleMode(stdio->hStdIn, &dwMode);
+    dwMode &= ~ENABLE_VIRTUAL_TERMINAL_INPUT;
+    SetConsoleMode(stdio->hStdIn, dwMode);
 }
 
 static int win_stdio_write(Chardev *chr, const uint8_t *buf, int len)
-- 
2.25.1
Re: [PATCH] chardev/char-win-stdio: Fix keyboard input after exit Qemu on
Posted by Marc-André Lureau 1 month ago
Hi

On Sun, Mar 24, 2024 at 7:23 PM Irina Ryapolova
<irina.ryapolova@syntacore.com> wrote:
>
> After exit Qemu need to return the terminal to the default state.
>
> Signed-off-by: Irina Ryapolova <irina.ryapolova@syntacore.com>
> ---
>  chardev/char-win-stdio.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c
> index 1a18999e78..4fa2c3de8b 100644
> --- a/chardev/char-win-stdio.c
> +++ b/chardev/char-win-stdio.c
> @@ -220,6 +220,7 @@ err1:
>  static void char_win_stdio_finalize(Object *obj)
>  {
>      WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj);
> +    DWORD dwMode;
>
>      if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
>          CloseHandle(stdio->hInputReadyEvent);
> @@ -230,6 +231,10 @@ static void char_win_stdio_finalize(Object *obj)
>      if (stdio->hInputThread != INVALID_HANDLE_VALUE) {
>          TerminateThread(stdio->hInputThread, 0);
>      }
> +
> +    GetConsoleMode(stdio->hStdIn, &dwMode);
> +    dwMode &= ~ENABLE_VIRTUAL_TERMINAL_INPUT;
> +    SetConsoleMode(stdio->hStdIn, dwMode);

I'd suggest saving the mode when opening instead, to make sure we
restore the same value.

thanks

-- 
Marc-André Lureau
Re: [PATCH] chardev/char-win-stdio: Fix keyboard input after exit Qemu on
Posted by Marc-André Lureau 1 week, 5 days ago
Hi Irina

On Mon, Mar 25, 2024 at 10:44 AM Marc-André Lureau
<marcandre.lureau@gmail.com> wrote:
>
> Hi
>
> On Sun, Mar 24, 2024 at 7:23 PM Irina Ryapolova
> <irina.ryapolova@syntacore.com> wrote:
> >
> > After exit Qemu need to return the terminal to the default state.
> >
> > Signed-off-by: Irina Ryapolova <irina.ryapolova@syntacore.com>
> > ---
> >  chardev/char-win-stdio.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c
> > index 1a18999e78..4fa2c3de8b 100644
> > --- a/chardev/char-win-stdio.c
> > +++ b/chardev/char-win-stdio.c
> > @@ -220,6 +220,7 @@ err1:
> >  static void char_win_stdio_finalize(Object *obj)
> >  {
> >      WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj);
> > +    DWORD dwMode;
> >
> >      if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
> >          CloseHandle(stdio->hInputReadyEvent);
> > @@ -230,6 +231,10 @@ static void char_win_stdio_finalize(Object *obj)
> >      if (stdio->hInputThread != INVALID_HANDLE_VALUE) {
> >          TerminateThread(stdio->hInputThread, 0);
> >      }
> > +
> > +    GetConsoleMode(stdio->hStdIn, &dwMode);
> > +    dwMode &= ~ENABLE_VIRTUAL_TERMINAL_INPUT;
> > +    SetConsoleMode(stdio->hStdIn, dwMode);
>
> I'd suggest saving the mode when opening instead, to make sure we
> restore the same value.
>
> thanks

Do you agree? Could you update the patch? thanks

-- 
Marc-André Lureau