qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Amit Shah <amit.shah@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu list <qemu-devel@nongnu.org>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/3] virtio-console: Check if chardev backends available before calling into them
Date: Wed, 21 Dec 2011 16:05:24 -0600	[thread overview]
Message-ID: <4EF25824.7060606@codemonkey.ws> (raw)
In-Reply-To: <572329cfb780c2ab584cb89fca6e9dcea08812aa.1324450707.git.amit.shah@redhat.com>

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<amit.shah@redhat.com>

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);
>   }
>

      parent reply	other threads:[~2011-12-21 22:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21  6:58 [Qemu-devel] [PATCH 1/3] virtio-console: Check if chardev backends available before calling into them Amit Shah
2011-12-21  6:58 ` [Qemu-devel] [PATCH 2/3] virtio-console: Properly initialise class methods Amit Shah
2011-12-21  6:58 ` [Qemu-devel] [PATCH 3/3] virtio-serial-bus: Ports are expected to implement 'have_data' callback Amit Shah
2011-12-21 22:05 ` Anthony Liguori [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EF25824.7060606@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=amit.shah@redhat.com \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).