forked from mwiget/vmxlwaftr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qemu-snabb.diff
51 lines (50 loc) · 1.4 KB
/
qemu-snabb.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index aff193f..1b4521c 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -84,6 +84,7 @@ struct CharDriverState {
int avail_connections;
int is_mux;
guint fd_in_tag;
+ guint fd_hup_tag;
QemuOpts *opts;
QTAILQ_ENTRY(CharDriverState) next;
};
diff --git a/qemu-char.c b/qemu-char.c
index 00a7526..20783d5 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2937,6 +2937,25 @@ CharDriverState *qemu_chr_open_eventfd(int eventfd)
}
#endif
+static gboolean tcp_chr_chan_close(GIOChannel *channel, GIOCondition cond,
+ void *opaque)
+{
+ CharDriverState *chr = opaque;
+
+ if (cond != G_IO_HUP) {
+ return FALSE;
+ }
+
+ /* connection closed */
+ tcp_chr_disconnect(chr);
+ if (chr->fd_hup_tag) {
+ g_source_remove(chr->fd_hup_tag);
+ chr->fd_hup_tag = 0;
+ }
+
+ return TRUE;
+}
+
static void tcp_chr_connect(void *opaque)
{
CharDriverState *chr = opaque;
@@ -2961,6 +2980,8 @@ static void tcp_chr_connect(void *opaque)
if (s->chan) {
chr->fd_in_tag = io_add_watch_poll(s->chan, tcp_chr_read_poll,
tcp_chr_read, chr);
+ chr->fd_hup_tag = g_io_add_watch(s->chan, G_IO_HUP, tcp_chr_chan_close,
+ chr);
}
qemu_chr_be_generic_open(chr);
}