[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 2/5] qemu-char: Add qemu_chr_disconnect to close
From: |
Tetsuya Mukawa |
Subject: |
[Qemu-devel] [PATCH v2 2/5] qemu-char: Add qemu_chr_disconnect to close a fd accepted by listen fd |
Date: |
Mon, 22 Jun 2015 12:50:45 +0900 |
The patch introduces qemu_chr_disconnect(). The function is used for
closing a fd accepted by listen fd. Though we already have qemu_chr_delete(),
but it closes not only accepted fd but also listen fd. This new function
is used when we still want to keep listen fd.
Signed-off-by: Tetsuya Mukawa <address@hidden>
---
include/sysemu/char.h | 7 +++++++
qemu-char.c | 8 ++++++++
2 files changed, 15 insertions(+)
diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index 832b7fe..141edbd 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -70,6 +70,7 @@ struct CharDriverState {
IOReadHandler *chr_read;
void *handler_opaque;
void (*chr_close)(struct CharDriverState *chr);
+ void (*chr_disconnect)(struct CharDriverState *chr);
void (*chr_accept_input)(struct CharDriverState *chr);
void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
void (*chr_set_fe_open)(struct CharDriverState *chr, int fe_open);
@@ -124,6 +125,12 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
*/
CharDriverState *qemu_chr_new(const char *label, const char *filename,
void (*init)(struct CharDriverState *s));
+/**
+ * @qemu_chr_disconnect:
+ *
+ * Close a fd accpeted by character backend.
+ */
+void qemu_chr_disconnect(CharDriverState *chr);
/**
* @qemu_chr_delete:
diff --git a/qemu-char.c b/qemu-char.c
index d0c1564..122632b 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3836,6 +3836,13 @@ void qemu_chr_fe_release(CharDriverState *s)
s->avail_connections++;
}
+void qemu_chr_disconnect(CharDriverState *chr)
+{
+ if (chr->chr_disconnect) {
+ chr->chr_disconnect(chr);
+ }
+}
+
void qemu_chr_delete(CharDriverState *chr)
{
QTAILQ_REMOVE(&chardevs, chr, next);
@@ -4154,6 +4161,7 @@ static CharDriverState
*qmp_chardev_open_socket(ChardevSocket *sock,
chr->chr_write = tcp_chr_write;
chr->chr_sync_read = tcp_chr_sync_read;
chr->chr_close = tcp_chr_close;
+ chr->chr_disconnect = tcp_chr_disconnect;
chr->get_msgfds = tcp_get_msgfds;
chr->set_msgfds = tcp_set_msgfds;
chr->chr_add_client = tcp_chr_add_client;
--
2.1.4
- [Qemu-devel] [PATCH v2 0/5] Add feature to start QEMU without vhost-user backend, Tetsuya Mukawa, 2015/06/21
- [Qemu-devel] [PATCH v2 1/5] vhost-user: Add ability to know vhost-user backend disconnection, Tetsuya Mukawa, 2015/06/21
- [Qemu-devel] [PATCH v2 3/5] vhost-user: Shutdown vhost-user connection when wrong messages are passed, Tetsuya Mukawa, 2015/06/21
- [Qemu-devel] [PATCH v2 2/5] qemu-char: Add qemu_chr_disconnect to close a fd accepted by listen fd,
Tetsuya Mukawa <=
- [Qemu-devel] [PATCH v2 4/5] vhost-user: Enable 'nowait' and 'reconnect' option, Tetsuya Mukawa, 2015/06/21
- [Qemu-devel] [PATCH v2 5/5] vhost-user: Add new option to specify vhost-user backend supports, Tetsuya Mukawa, 2015/06/21
- Re: [Qemu-devel] [PATCH v2 0/5] Add feature to start QEMU without vhost-user backend, Michael S. Tsirkin, 2015/06/22