aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-11-19 10:22:43 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2011-11-28 16:20:51 -0600
commita425d23f8fad482f7792745036896eb2f72330de (patch)
tree1ca2d76b818220a5c58d158f808b3c0230240294
parent2507718baf311ea78156c6777d38410a9f89ce89 (diff)
qemu-char: rename qemu_chr_event to qemu_chr_be_event and make it public
Rename qemu_chr_event to qemu_chr_be_event, since it is only to be called by backends and make it public so that it can be used by chardev code which lives outside of qemu-char.c Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--qemu-char.c26
-rw-r--r--qemu-char.h10
2 files changed, 23 insertions, 13 deletions
diff --git a/qemu-char.c b/qemu-char.c
index b562bf88a7..27abcb9186 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -106,7 +106,7 @@
static QTAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs =
QTAILQ_HEAD_INITIALIZER(chardevs);
-static void qemu_chr_event(CharDriverState *s, int event)
+void qemu_chr_be_event(CharDriverState *s, int event)
{
/* Keep track if the char device is open */
switch (event) {
@@ -126,7 +126,7 @@ static void qemu_chr_event(CharDriverState *s, int event)
static void qemu_chr_generic_open_bh(void *opaque)
{
CharDriverState *s = opaque;
- qemu_chr_event(s, CHR_EVENT_OPENED);
+ qemu_chr_be_event(s, CHR_EVENT_OPENED);
qemu_bh_delete(s->bh);
s->bh = NULL;
}
@@ -359,7 +359,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
bdrv_commit_all();
break;
case 'b':
- qemu_chr_event(chr, CHR_EVENT_BREAK);
+ qemu_chr_be_event(chr, CHR_EVENT_BREAK);
break;
case 'c':
/* Switch to the next registered device */
@@ -580,7 +580,7 @@ static void fd_chr_read(void *opaque)
if (size == 0) {
/* FD has been closed. Remove it from the active list. */
qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL);
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
return;
}
if (size > 0) {
@@ -613,7 +613,7 @@ static void fd_chr_close(struct CharDriverState *chr)
}
g_free(s);
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
/* open a character device to a unix fd */
@@ -715,7 +715,7 @@ static void stdio_read(void *opaque)
if (size == 0) {
/* stdin has been closed. Remove it from the active list. */
qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL);
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
return;
}
if (size > 0) {
@@ -977,7 +977,7 @@ static void pty_chr_close(struct CharDriverState *chr)
qemu_del_timer(s->timer);
qemu_free_timer(s->timer);
g_free(s);
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
@@ -1355,7 +1355,7 @@ static void pp_close(CharDriverState *chr)
ioctl(fd, PPRELEASE);
close(fd);
g_free(drv);
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
static int qemu_chr_open_pp(QemuOpts *opts, CharDriverState **_chr)
@@ -1500,7 +1500,7 @@ static void win_chr_close(CharDriverState *chr)
else
qemu_del_polling_cb(win_chr_poll, chr);
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
static int win_chr_init(CharDriverState *chr, const char *filename)
@@ -2108,7 +2108,7 @@ static void udp_chr_close(CharDriverState *chr)
closesocket(s->fd);
}
g_free(s);
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
static int qemu_chr_open_udp(QemuOpts *opts, CharDriverState **_chr)
@@ -2213,7 +2213,7 @@ static void tcp_chr_process_IAC_bytes(CharDriverState *chr,
} else {
if ((unsigned char)buf[i] == IAC_BREAK && s->do_telnetopt == 2) {
/* Handle IAC break commands by sending a serial break */
- qemu_chr_event(chr, CHR_EVENT_BREAK);
+ qemu_chr_be_event(chr, CHR_EVENT_BREAK);
s->do_telnetopt++;
}
s->do_telnetopt++;
@@ -2321,7 +2321,7 @@ static void tcp_chr_read(void *opaque)
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
closesocket(s->fd);
s->fd = -1;
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
} else if (size > 0) {
if (s->do_telnetopt)
tcp_chr_process_IAC_bytes(chr, s, buf, &size);
@@ -2433,7 +2433,7 @@ static void tcp_chr_close(CharDriverState *chr)
closesocket(s->listen_fd);
}
g_free(s);
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
static int qemu_chr_open_socket(QemuOpts *opts, CharDriverState **_chr)
diff --git a/qemu-char.h b/qemu-char.h
index 7efcf99f53..8ca1e2d54e 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -212,6 +212,16 @@ int qemu_chr_be_can_write(CharDriverState *s);
*/
void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len);
+
+/**
+ * @qemu_chr_be_event:
+ *
+ * Send an event from the back end to the front end.
+ *
+ * @event the event to send
+ */
+void qemu_chr_be_event(CharDriverState *s, int event);
+
void qemu_chr_add_handlers(CharDriverState *s,
IOCanReadHandler *fd_can_read,
IOReadHandler *fd_read,