diff mbox

[3/9] char: add qemu_chr_remove_handlers()

Message ID 20161013111449.29387-4-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Oct. 13, 2016, 11:14 a.m. UTC
Remove the handlers associated with a frontend tag.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qemu-char.c           | 9 +++++++++
 include/sysemu/char.h | 9 +++++++++
 2 files changed, 18 insertions(+)
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 168af69..a7fec6a 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -526,6 +526,15 @@  int qemu_chr_add_handlers(CharDriverState *s,
                                       fd_event, opaque, NULL);
 }
 
+void qemu_chr_remove_handlers(CharDriverState *s, int tag)
+{
+    if (tag < 0) {
+        return;
+    }
+    /* FIXME: recycle mux tag */
+    qemu_chr_set_handlers(s, NULL, NULL, NULL, NULL, NULL, tag);
+}
+
 static int null_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
 {
     return len;
diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index bdd61ea..36d82b1 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -453,6 +453,15 @@  int qemu_chr_add_handlers_full(CharDriverState *s,
                                 void *opaque,
                                 GMainContext *context);
 
+/**
+ * @qemu_chr_remove_handlers:
+ *
+ * @tag: the tag returned from qemu_chr_add_handlers()
+ *
+ * Remove the frontend callbacks.
+ */
+void qemu_chr_remove_handlers(CharDriverState *s, int tag);
+
 void qemu_chr_be_generic_open(CharDriverState *s);
 void qemu_chr_accept_input(CharDriverState *s);
 int qemu_chr_add_client(CharDriverState *s, int fd);