Patchwork [3/9] char: introduce fd_chr_detach()

login
register
mail settings
Submitter Amit Shah
Date Aug. 28, 2013, 5:10 a.m.
Message ID <cc4e3773a2f7d70f5a3aebe7ef6197fbc1e2c9a8.1377666450.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/270332/
State New
Headers show

Comments

Amit Shah - Aug. 28, 2013, 5:10 a.m.
Remove any registered callbacks if a frontend is detached.

CC: <qemu-stable@nongnu.org>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-char.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index e235334..91ae1da 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -806,6 +806,17 @@  typedef struct FDCharDriver {
     QTAILQ_ENTRY(FDCharDriver) node;
 } FDCharDriver;
 
+
+static void fd_chr_detach(struct CharDriverState *chr)
+{
+    FDCharDriver *s = chr->opaque;
+
+    if (s->fd_in_tag) {
+        io_remove_watch_poll(s->fd_in_tag);
+        s->fd_in_tag = 0;
+    }
+}
+
 static int fd_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
 {
     FDCharDriver *s = chr->opaque;
@@ -913,6 +924,7 @@  static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
     chr->chr_write = fd_chr_write;
     chr->chr_update_read_handler = fd_chr_update_read_handler;
     chr->chr_close = fd_chr_close;
+    chr->chr_detach = fd_chr_detach;
 
     return chr;
 }