[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] char: open pipe in write-only mode
From: |
marcandre . lureau |
Subject: |
[PATCH 1/2] char: open pipe in write-only mode |
Date: |
Fri, 5 Aug 2022 14:55:39 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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 <marcandre.lureau@redhat.com>
---
chardev/char-pipe.c | 6 ++++--
qemu-options.hx | 15 +++++++++------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/chardev/char-pipe.c b/chardev/char-pipe.c
index 66d3b85091..f9897a3786 100644
--- a/chardev/char-pipe.c
+++ b/chardev/char-pipe.c
@@ -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;
}
diff --git a/qemu-options.hx b/qemu-options.hx
index 3f23a42fa8..ec99a6db48 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -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``
--
2.37.1
- [PATCH 1/2] char: open pipe in write-only mode,
marcandre . lureau <=