Skip to contentSkip to conversation

chardev/char-win-stdio: Pass Ctrl+C to guest with a multiplexed monitor

PATCH In review Bin Meng 3 participants 4 messages Oct 25, 2022 – Nov 19, 2022

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 chardev/char-win-stdio: Pass Ctrl+C to guest with a multiplexed monitor

At present when pressing Ctrl+C from a guest running on QEMU Windows with a multiplexed monitor, e.g.: -serial mon:stdio, QEMU executable just exits. This behavior is inconsistent with the Linux version.

Such behavior is caused by unconditionally setting the input mode ENABLE_PROCESSED_INPUT for a console's input buffer. Fix this by testing whether the chardev is allowed to do so.

---

 chardev/char-win-stdio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
chardev/char-win-stdio.c +7 -1
index a4771ab82e..eb830eabd9 100644
@@ -146,6 +146,8 @@ static void qemu_chr_open_stdio(Chardev *chr,
                                 bool *be_opened,
                                 Error **errp)
 {
+    ChardevStdio *opts = backend->u.stdio.data;
+    bool stdio_allow_signal = !opts->has_signal || opts->signal;
     WinStdioChardev *stdio = WIN_STDIO_CHARDEV(chr);
     DWORD              dwMode;
     int                is_console = 0;
@@ -193,7 +195,11 @@ static void qemu_chr_open_stdio(Chardev *chr,
     if (is_console) {
         /* set the terminal in raw mode */
         /* ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS */
-        dwMode |= ENABLE_PROCESSED_INPUT;
+        if (stdio_allow_signal) {
+            dwMode |= ENABLE_PROCESSED_INPUT;
+        } else {
+            dwMode &= ~ENABLE_PROCESSED_INPUT;
+        }
     }
 
     SetConsoleMode(stdio->hStdIn, dwMode);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Bin Meng

At present when pressing Ctrl+C from a guest running on QEMU Windows with a multiplexed monitor, e.g.: -serial mon:stdio, QEMU executable just exits. This behavior is inconsistent with the Linux version.

Such behavior is caused by unconditionally setting the input mode ENABLE_PROCESSED_INPUT for a console's input buffer. Fix this by testing whether the chardev is allowed to do so.

Quoted 35 lines

---

 chardev/char-win-stdio.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
chardev/char-win-stdio.c +7 -2
index a4771ab82e..eb830eabd9 100644
@@ -146,6 +146,8 @@ static void qemu_chr_open_stdio(Chardev *chr,
                                 bool *be_opened,
                                 Error **errp)
 {
+    ChardevStdio *opts = backend->u.stdio.data;
+    bool stdio_allow_signal = !opts->has_signal || opts->signal;
     WinStdioChardev *stdio = WIN_STDIO_CHARDEV(chr);
     DWORD              dwMode;
     int                is_console = 0;
@@ -193,7 +195,11 @@ static void qemu_chr_open_stdio(Chardev *chr,
     if (is_console) {
         /* set the terminal in raw mode */
         /* ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS */
-        dwMode |= ENABLE_PROCESSED_INPUT;
+        if (stdio_allow_signal) {
+            dwMode |= ENABLE_PROCESSED_INPUT;
+        } else {
+            dwMode &= ~ENABLE_PROCESSED_INPUT;
+        }
     }
 
     SetConsoleMode(stdio->hStdIn, dwMode);
--

2.25.1

Signature · 1 line
Marc-André Lureau
#2 lore raw
Quoted 7 lines · Marc-André Lureau
Quoted 5 lines · Bin Meng

At present when pressing Ctrl+C from a guest running on QEMU Windows with a multiplexed monitor, e.g.: -serial mon:stdio, QEMU executable just exits. This behavior is inconsistent with the Linux version.

Quoted 8 lines
Quoted 5 lines

Such behavior is caused by unconditionally setting the input mode ENABLE_PROCESSED_INPUT for a console's input buffer. Fix this by testing whether the chardev is allowed to do so.

Ping?

Who is going to pick up this patch for 7.2?

Regards,
Bin

#3 lore raw
Quoted 14 lines · Bin Meng
Quoted 11 lines · Marc-André Lureau
Quoted 9 lines · Bin Meng

At present when pressing Ctrl+C from a guest running on QEMU Windows with a multiplexed monitor, e.g.: -serial mon:stdio, QEMU executable just exits. This behavior is inconsistent with the Linux version.

Such behavior is caused by unconditionally setting the input mode ENABLE_PROCESSED_INPUT for a console's input buffer. Fix this by testing whether the chardev is allowed to do so.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

Ping?

Who is going to pick up this patch for 7.2?

Ping?