From: Anthony Liguori <anthony@codemonkey.ws>
To: Lei Li <lilei@linux.vnet.ibm.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-char: (Re-)connect for tcp_chr_write() unconnected writing
Date: Thu, 19 Jul 2012 18:09:05 -0500 [thread overview]
Message-ID: <87394nbb72.fsf@codemonkey.ws> (raw)
In-Reply-To: <1342706962-11268-1-git-send-email-lilei@linux.vnet.ibm.com>
Lei Li <lilei@linux.vnet.ibm.com> writes:
> tcp_chr_write() did not deal with writing to an unconnected
> connection and return the original length of the data, it's
> not right and would cause false writing. So (re-)connect it
> and return 0 for this situation.
>
> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Looks good.
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Regards,
Anthony Liguori
> ---
> qemu-char.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index c2aaaee..25eaeeb 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -2141,14 +2141,17 @@ typedef struct {
>
> static void tcp_chr_accept(void *opaque);
>
> +static void tcp_chr_connect(void *opaque);
> +
> static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
> {
> TCPCharDriver *s = chr->opaque;
> if (s->connected) {
> return send_all(s->fd, buf, len);
> } else {
> - /* XXX: indicate an error ? */
> - return len;
> + /* (Re-)connect for unconnected writing */
> + tcp_chr_connect(chr);
> + return 0;
> }
> }
>
> --
> 1.7.7.6
next prev parent reply other threads:[~2012-07-19 23:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-19 14:09 [Qemu-devel] [PATCH] qemu-char: (Re-)connect for tcp_chr_write() unconnected writing Lei Li
2012-07-19 23:09 ` Anthony Liguori [this message]
2012-08-06 10:54 ` Lei Li
-- strict thread matches above, loose matches on Subject: below --
2012-07-16 2:58 Lei Li
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=87394nbb72.fsf@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=lilei@linux.vnet.ibm.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).