[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 03/28] qemu-char: Keep pty slave file descriptor open
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 03/28] qemu-char: Keep pty slave file descriptor open until the master is closed |
Date: |
Mon, 8 Feb 2016 18:02:54 +0100 |
If a process opens the slave pts device, writes data to it, then
immediately closes it, the data doesn't reliably get delivered to the
emulated serial port. This seems to be because a read of the master
pty device returns EIO on Linux if no process has the pts device open,
even when data is waiting "in the pipe".
A fix seems to be for QEMU to keep the pts file descriptor open until
the pty is closed, as per the below patch.
Signed-off-by: Ashley Jonathan <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael Tokarev <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
qemu-char.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/qemu-char.c b/qemu-char.c
index 927c47e..1fbccf0 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1171,6 +1171,7 @@ typedef struct {
int connected;
guint timer_tag;
guint open_tag;
+ int slave_fd;
} PtyCharDriver;
static void pty_chr_update_read_handler_locked(CharDriverState *chr);
@@ -1347,6 +1348,7 @@ static void pty_chr_close(struct CharDriverState *chr)
qemu_mutex_lock(&chr->chr_write_lock);
pty_chr_state(chr, 0);
+ close(s->slave_fd);
object_unref(OBJECT(s->ioc));
if (s->timer_tag) {
g_source_remove(s->timer_tag);
@@ -1374,7 +1376,6 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
return NULL;
}
- close(slave_fd);
qemu_set_nonblock(master_fd);
chr = qemu_chr_alloc(common, errp);
@@ -1399,6 +1400,7 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
chr->explicit_be_open = true;
s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd));
+ s->slave_fd = slave_fd;
s->timer_tag = 0;
return chr;
--
1.8.3.1
- [Qemu-devel] [PULL 00/28] Misc changes for 2016-02-08, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 01/28] memory: add early bail out from cpu_physical_memory_set_dirty_range, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 03/28] qemu-char: Keep pty slave file descriptor open until the master is closed,
Paolo Bonzini <=
- [Qemu-devel] [PULL 02/28] memory: RCU ram_list.dirty_memory[] for safe RAM hotplug, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 06/28] scsi: push WWN fields up to SCSIDevice, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 07/28] scsi-generic: grab device and port SAS addresses from backend, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 05/28] include/qemu/atomic.h: default to __atomic functions, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 04/28] configure: sanity check the glib library that pkg-config finds, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 09/28] qemu-nbd: Fix unintended texi verbatim formatting, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 12/28] scripts/kvm/kvm_stat: Fix tracefs access checking, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 14/28] kvm-all: trace: strerror fixup, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 17/28] target-i386: Introduce mo_stacksize, Paolo Bonzini, 2016/02/08
- [Qemu-devel] [PULL 15/28] char: fix repeated registration of tcp chardev I/O handlers, Paolo Bonzini, 2016/02/08