From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIk5c-0000Uw-0X for qemu-devel@nongnu.org; Thu, 21 Mar 2013 14:19:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIk5Z-0006xU-Uv for qemu-devel@nongnu.org; Thu, 21 Mar 2013 14:19:47 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:50567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIk5Z-0006xG-Df for qemu-devel@nongnu.org; Thu, 21 Mar 2013 14:19:45 -0400 Received: from /spool/local by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 22 Mar 2013 04:12:42 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 135D0357804A for ; Fri, 22 Mar 2013 05:19:36 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2LI5xLW3539246 for ; Fri, 22 Mar 2013 05:06:02 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2LIJ21W012278 for ; Fri, 22 Mar 2013 05:19:02 +1100 From: Anthony Liguori In-Reply-To: <1363883716-30289-2-git-send-email-alevy@redhat.com> References: <87boadc2yp.fsf@codemonkey.ws> <1363883716-30289-1-git-send-email-alevy@redhat.com> <1363883716-30289-2-git-send-email-alevy@redhat.com> Date: Thu, 21 Mar 2013 13:18:58 -0500 Message-ID: <87sj3o62gd.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 1/2] char: add qemu_chr_be_is_fe_connected List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alon Levy , qemu-devel@nongnu.org Cc: amit.shah@redhat.com, hdegoede@redhat.com, kraxel@redhat.com Alon Levy writes: > Note that the handler is called chr_is_guest_connected and not > chr_is_fe_connected, consistent with other members of CharDriverState. Sorry, I don't get it. There isn't a notion of "connected" for the front-ends in the char layer. The closest thing is whether add_handlers() have been called or not. I really dislike the idea of introduction a new concept to the char layer in a half baked way. Why can't migration notifiers be used for this? I think Gerd objected to using a migration *handler* but not necessarily a state notifier. Regards, Anthony Liguori > > Signed-off-by: Alon Levy > --- > hw/virtio-console.c | 9 +++++++++ > include/char/char.h | 11 +++++++++++ > qemu-char.c | 9 +++++++++ > 3 files changed, 29 insertions(+) > > diff --git a/hw/virtio-console.c b/hw/virtio-console.c > index e2d1c58..643e24e 100644 > --- a/hw/virtio-console.c > +++ b/hw/virtio-console.c > @@ -120,6 +120,13 @@ static void chr_event(void *opaque, int event) > } > } > > +static bool chr_is_guest_connected(void *opaque) > +{ > + VirtConsole *vcon = opaque; > + > + return vcon->port.guest_connected; > +} > + > static int virtconsole_initfn(VirtIOSerialPort *port) > { > VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); > @@ -133,6 +140,8 @@ static int virtconsole_initfn(VirtIOSerialPort *port) > if (vcon->chr) { > qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event, > vcon); > + /* only user of chr_is_guest_connected so leave it as special cased*/ > + vcon->chr->chr_is_guest_connected = chr_is_guest_connected; > } > > return 0; > diff --git a/include/char/char.h b/include/char/char.h > index 0326b2a..b41ddc0 100644 > --- a/include/char/char.h > +++ b/include/char/char.h > @@ -52,6 +52,7 @@ typedef struct { > #define CHR_TIOCM_RTS 0x004 > > typedef void IOEventHandler(void *opaque, int event); > +typedef bool IOIsGuestConnectedHandler(void *opaque); > > struct CharDriverState { > void (*init)(struct CharDriverState *s); > @@ -64,6 +65,7 @@ struct CharDriverState { > IOEventHandler *chr_event; > IOCanReadHandler *chr_can_read; > IOReadHandler *chr_read; > + IOIsGuestConnectedHandler *chr_is_guest_connected; > void *handler_opaque; > void (*chr_close)(struct CharDriverState *chr); > void (*chr_accept_input)(struct CharDriverState *chr); > @@ -229,6 +231,15 @@ void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len); > */ > void qemu_chr_be_event(CharDriverState *s, int event); > > +/** > + * @qemu_chr_be_is_fe_connected: > + * > + * Back end calls this to check if the front end is connected. > + * > + * Returns: true if the guest (front end) is connected, false otherwise. > + */ > +bool qemu_chr_be_is_fe_connected(CharDriverState *s); > + > void qemu_chr_add_handlers(CharDriverState *s, > IOCanReadHandler *fd_can_read, > IOReadHandler *fd_read, > diff --git a/qemu-char.c b/qemu-char.c > index 4e011df..77a501a 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -120,6 +120,15 @@ void qemu_chr_be_event(CharDriverState *s, int event) > s->chr_event(s->handler_opaque, event); > } > > +bool qemu_chr_be_is_fe_connected(CharDriverState *s) > +{ > + if (s->chr_is_guest_connected) { > + return s->chr_is_guest_connected(s->handler_opaque); > + } > + /* default to always connected */ > + return true; > +} > + > static gboolean qemu_chr_generic_open_bh(gpointer opaque) > { > CharDriverState *s = opaque; > -- > 1.8.1.4