diff mbox series

[v3,14/15] char-pty: Print "char device redirected" message to stdout

Message ID 20190417190641.26814-15-armbru@redhat.com
State New
Headers show
Series Clean up use of error_printf() | expand

Commit Message

Markus Armbruster April 17, 2019, 7:06 p.m. UTC
char_pty_open() prints a "char device redirected to PTY_NAME (label
LABEL)" message to the current monitor or else to stderr.  This is not
an error, so it shouldn't go to stderr.  Print it to stdout instead.

Why is it even printed?  No other ChardevClass::open() prints anything
on success.  It's because you need to know PTY_NAME to actually use
this char device, e.g. like e.g. "socat STDIO,cfmakeraw FILE:PTY_NAME"
to use the monitor's readline interface.  You can get PTY_NAME with
"info chardev" (a.k.a. query-chardev for QMP), but only if you already
have a monitor.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 chardev/char-pty.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Eric Blake April 17, 2019, 7:31 p.m. UTC | #1
On 4/17/19 2:06 PM, Markus Armbruster wrote:
> char_pty_open() prints a "char device redirected to PTY_NAME (label
> LABEL)" message to the current monitor or else to stderr.  This is not
> an error, so it shouldn't go to stderr.  Print it to stdout instead.
> 
> Why is it even printed?  No other ChardevClass::open() prints anything
> on success.  It's because you need to know PTY_NAME to actually use
> this char device, e.g. like e.g. "socat STDIO,cfmakeraw FILE:PTY_NAME"
> to use the monitor's readline interface.  You can get PTY_NAME with
> "info chardev" (a.k.a. query-chardev for QMP), but only if you already
> have a monitor.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  chardev/char-pty.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index b034332edd..04759b0ef9 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -28,6 +28,7 @@ 
 #include "io/channel-file.h"
 #include "qemu/sockets.h"
 #include "qemu/error-report.h"
+#include "qemu/qemu-print.h"
 
 #include "chardev/char-io.h"
 
@@ -211,8 +212,8 @@  static void char_pty_open(Chardev *chr,
     qemu_set_nonblock(master_fd);
 
     chr->filename = g_strdup_printf("pty:%s", pty_name);
-    error_printf("char device redirected to %s (label %s)\n",
-                 pty_name, chr->label);
+    qemu_printf("char device redirected to %s (label %s)\n",
+                pty_name, chr->label);
 
     s = PTY_CHARDEV(chr);
     s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd));