char: open pipe in write-only mode
PATCH 1/2 char: open pipe in write-only mode
From: Marc-André Lureau <[email protected]>
When not using the "path.in", "path.out", open "path" in read-only mode, as eating our own output is usually not what we want.
Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=2106975
Signed-off-by Marc-André Lureau <[email protected]>
--- chardev/char-pipe.c | 6 ++++-- qemu-options.hx | 15 +++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-)
chardev/char-pipe.c +4 -2
@@ -138,12 +138,14 @@ static void qemu_chr_open_pipe(Chardev *chr,if (fd_in <0 || fd_out <0 ) {if (fd_in >=0 ) {close (fd_in); + fd_in =-1 ; }if (fd_out >=0 ) {close (fd_out); + fd_out =-1 ; } -TFR (fd_in = fd_out =qemu_open_old (filename,O_RDWR |O_BINARY )); -if (fd_in <0 ) { +TFR (fd_out =qemu_open_old (filename,O_WRONLY |O_BINARY )); +if (fd_out <0 ) {error_setg_file_open (errp, errno, filename);return ; }
qemu-options.hx +9 -6
@@ -3514,18 +3514,21 @@ The available backends are: ``path`` is required. ``-chardev pipe,id=id,path=path`` - Create a two-way connection to the guest. The behaviour differs + Create a one-way or two-way stream. The behaviour differs slightly between Windows hosts and other hosts: - On Windows, a single duplex pipe will be created at + On Windows, a full duplex pipe will be created at ``\\.pipe\path``. - On other hosts, 2 pipes will be created called ``path.in`` and + On other hosts, 2 paths will be opened called ``path.in`` and ``path.out``. Data written to ``path.in`` will be received by the - guest. Data written by the guest can be read from ``path.out``. QEMU - will not create these fifos, and requires them to be present. + guest. Data written by the guest can be read from ``path.out``. + QEMU will not create these fifos, and requires them to be present. - ``path`` forms part of the pipe path as described above. ``path`` is + If ``path.in`` or ``path.out`` are missing, QEMU will open + ``path`` for an output-only stream. + + ``path`` forms part of the paths as described above. ``path`` is required. ``-chardev console,id=id``
Signature · 1 line
2.37.1
PATCH 2/2 char: open unidirectional in/out pipes with one-way mode
From: Marc-André Lureau <[email protected]>
This is how those paths are meant to be used.
Signed-off-by Marc-André Lureau <[email protected]>
--- chardev/char-pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
chardev/char-pipe.c +2 -2
@@ -131,8 +131,8 @@ static void qemu_chr_open_pipe(Chardev *chr, filename_in =g_strdup_printf ("%s.in" , filename); filename_out =g_strdup_printf ("%s.out" , filename); -TFR (fd_in =qemu_open_old (filename_in,O_RDWR |O_BINARY )); -TFR (fd_out =qemu_open_old (filename_out,O_RDWR |O_BINARY )); +TFR (fd_in =qemu_open_old (filename_in,O_RDONLY |O_BINARY )); +TFR (fd_out =qemu_open_old (filename_out,O_WRONLY |O_BINARY ));g_free (filename_in);g_free (filename_out);if (fd_in <0 || fd_out <0 ) {
Signature · 1 line
2.37.1