From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RdUHz-0004Wz-Kc for qemu-devel@nongnu.org; Wed, 21 Dec 2011 17:05:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RdUHy-0007pT-Kr for qemu-devel@nongnu.org; Wed, 21 Dec 2011 17:05:31 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:44194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RdUHy-0007pP-GS for qemu-devel@nongnu.org; Wed, 21 Dec 2011 17:05:30 -0500 Received: by iagj37 with SMTP id j37so14138604iag.4 for ; Wed, 21 Dec 2011 14:05:29 -0800 (PST) Message-ID: <4EF25824.7060606@codemonkey.ws> Date: Wed, 21 Dec 2011 16:05:24 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <572329cfb780c2ab584cb89fca6e9dcea08812aa.1324450707.git.amit.shah@redhat.com> In-Reply-To: <572329cfb780c2ab584cb89fca6e9dcea08812aa.1324450707.git.amit.shah@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/3] virtio-console: Check if chardev backends available before calling into them List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: Paolo Bonzini , qemu list , Markus Armbruster On 12/21/2011 12:58 AM, Amit Shah wrote: > For the callback functions invoked by the virtio-serial-bus code, check > if we have chardev backends registered before we call into the chardev > functions. > > Signed-off-by: Amit Shah Applied all. Thanks. Regards, Anthony Liguori > --- > hw/virtio-console.c | 11 +++++++++++ > 1 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/hw/virtio-console.c b/hw/virtio-console.c > index d3351c8..dbbea76 100644 > --- a/hw/virtio-console.c > +++ b/hw/virtio-console.c > @@ -27,6 +27,11 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len) > VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); > ssize_t ret; > > + if (!vcon->chr) { > + /* If there's no backend, we can just say we consumed all data. */ > + return len; > + } > + > ret = qemu_chr_fe_write(vcon->chr, buf, len); > trace_virtio_console_flush_buf(port->id, len, ret); > > @@ -52,6 +57,9 @@ static void guest_open(VirtIOSerialPort *port) > { > VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); > > + if (!vcon->chr) { > + return; > + } > qemu_chr_fe_open(vcon->chr); > } > > @@ -60,6 +68,9 @@ static void guest_close(VirtIOSerialPort *port) > { > VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); > > + if (!vcon->chr) { > + return; > + } > qemu_chr_fe_close(vcon->chr); > } >