Received: from eggs.gnu.org ([2001:4830:134:3::10]:46828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byfbs-0004H1-AV for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byfbr-0006W1-4D for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:16 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36027) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byfbq-0006Vh-UI for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:15 -0400 Received: by mail-wm0-x242.google.com with SMTP id f193so9918045wmg.3 for ; Mon, 24 Oct 2016 06:48:14 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 24 Oct 2016 15:47:14 +0200 Message-Id: <1477316855-42218-30-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477316855-42218-1-git-send-email-pbonzini@redhat.com> References: <1477316855-42218-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 29/50] char: start converting mux driver to use CharBackend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau Start using qemu_chr_fe* CharBackend functions: initialize a CharBackend and use qemu_chr_fe_set_handlers(). Signed-off-by: Marc-André Lureau Message-Id: <20161022095318.17775-11-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- qemu-char.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 9c27371..9eefa7f 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -502,9 +502,7 @@ void qemu_chr_add_handlers_full(CharDriverState *s, if (s->is_mux) { tag = mux_chr_new_handler_tag(s, &error_abort); - if (tag == 0) { - mux_chr_set_handlers(s, context); - } + mux_chr_set_handlers(s, context); } qemu_chr_set_handlers(s, fd_can_read, fd_read, @@ -557,6 +555,7 @@ struct MuxDriver { IOEventHandler *chr_event[MAX_MUX]; void *ext_opaque[MAX_MUX]; CharDriverState *drv; + CharBackend chr; int focus; int mux_cnt; int term_got_escape; @@ -847,12 +846,12 @@ static void mux_chr_set_handlers(CharDriverState *chr, GMainContext *context) MuxDriver *d = chr->opaque; /* Fix up the real driver with mux routines */ - qemu_chr_add_handlers_full(d->drv, - mux_chr_can_read, - mux_chr_read, - mux_chr_event, - chr, - context); + qemu_chr_fe_set_handlers(&d->chr, + mux_chr_can_read, + mux_chr_read, + mux_chr_event, + chr, + context); } static void mux_set_focus(MuxDriver *d, int focus) @@ -906,6 +905,10 @@ static CharDriverState *qemu_chr_open_mux(const char *id, */ chr->explicit_be_open = muxes_realized ? 0 : 1; chr->is_mux = 1; + if (!qemu_chr_fe_init(&d->chr, d->drv, errp)) { + qemu_chr_free(chr); + return NULL; + } return chr; } @@ -4231,9 +4234,6 @@ void qemu_chr_disconnect(CharDriverState *chr) static void qemu_chr_free_common(CharDriverState *chr) { - if (chr->be) { - chr->be->chr = NULL; - } g_free(chr->filename); g_free(chr->label); if (chr->logfd != -1) { -- 1.8.3.1