From patchwork Sat Nov 19 09:22:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 126532 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A9C16B7236 for ; Sat, 19 Nov 2011 20:23:17 +1100 (EST) Received: from localhost ([::1]:44871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRh8k-0001or-LD for incoming@patchwork.ozlabs.org; Sat, 19 Nov 2011 04:23:14 -0500 Received: from eggs.gnu.org ([140.186.70.92]:34124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRh83-0008GF-5d for qemu-devel@nongnu.org; Sat, 19 Nov 2011 04:22:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRh7o-00089f-T2 for qemu-devel@nongnu.org; Sat, 19 Nov 2011 04:22:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRh7o-00089I-Ly for qemu-devel@nongnu.org; Sat, 19 Nov 2011 04:22:16 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pAJ9MFEf025253 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 19 Nov 2011 04:22:15 -0500 Received: from shalem.localdomain.com (vpn1-6-161.ams2.redhat.com [10.36.6.161]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pAJ9MCpx032695; Sat, 19 Nov 2011 04:22:14 -0500 From: Hans de Goede To: Gerd Hoffmann Date: Sat, 19 Nov 2011 10:22:43 +0100 Message-Id: <1321694567-2855-2-git-send-email-hdegoede@redhat.com> In-Reply-To: <1321694567-2855-1-git-send-email-hdegoede@redhat.com> References: <1321694567-2855-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 1/5] qemu-char: rename qemu_chr_event to qemu_chr_be_event and make it public X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- qemu-char.c | 26 +++++++++++++------------- qemu-char.h | 10 ++++++++++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index b562bf8..27abcb9 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 7efcf99..8ca1e2d 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,