All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gonglei (Arei)" <arei.gonglei@huawei.com>
To: linzhecheng <linzhecheng@huawei.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
	"wangxin (U)" <wangxinxin.wang@huawei.com>,
	"berrange@redhat.com" <berrange@redhat.com>,
	"peterx@redhat.com" <peterx@redhat.com>,
	"marcandre.lureau@redhat.com" <marcandre.lureau@redhat.com>,
	"eblake@redhat.com" <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] socket: dont't free msgfds if error equals EAGAIN
Date: Tue, 29 May 2018 08:41:04 +0000	[thread overview]
Message-ID: <33183CC9F5247A488A2544077AF19020DA64285E@DGGEMA505-MBX.china.huawei.com> (raw)
In-Reply-To: <D9DE8DBB19F2A24080482022C1DE758302C898BB@dggemm509-mbx.china.huawei.com>

Hi all,

The issue is easy to reproduce when we confiugred multi-queue function for vhost-user nics.

The main backtrace is as follows:

vhost_user_write  ==>  0)  sets s->write_msgfds_num to 8
	qemu_chr_fe_write_all
		qemu_chr_fe_write_buffer  ==> 4) rewrite because (ret <0 && errno is EAGAIN)
			tcp_chr_write  ==> 3) clear resource about s->write_msgfds and set s->write_msgfds_num to 0
				io_channel_send_full  ==>  2) errno = EAGAIN and return -1
					qio_channel_socket_writev  ==> 1) returns QIO_CHANNEL_ERR_BLOCK when ret <0 && errno == EAGAIN

Then at the above step 4) may cause undefined behaviors on the vhost-user server side because null control message is sent. 

So, we submit a patch to fix it. What's your opinion?

Regards,
-Gonglei

> -----Original Message-----
> From: linzhecheng
> Sent: Tuesday, May 29, 2018 4:20 PM
> To: qemu-devel@nongnu.org
> Cc: pbonzini@redhat.com; wangxin (U) <wangxinxin.wang@huawei.com>;
> berrange@redhat.com; peterx@redhat.com; marcandre.lureau@redhat.com;
> eblake@redhat.com; Gonglei (Arei) <arei.gonglei@huawei.com>
> Subject: RE: [PATCH] socket: dont't free msgfds if error equals EAGAIN
> 
> CC'ing Daniel P. Berrangé , Peter Xu, Marc-André Lureau, Eric Blake, Gonglei
> 
> > -----邮件原件-----
> > 发件人: linzhecheng
> > 发送时间: 2018年5月29日 10:53
> > 收件人: qemu-devel@nongnu.org
> > 抄送: pbonzini@redhat.com; wangxin (U)
> <wangxinxin.wang@huawei.com>;
> > linzhecheng <linzhecheng@huawei.com>
> > 主题: [PATCH] socket: dont't free msgfds if error equals EAGAIN
> >
> > Signed-off-by: linzhecheng <linzhecheng@huawei.com>
> >
> > diff --git a/chardev/char-socket.c b/chardev/char-socket.c index
> > 159e69c3b1..17519ec589 100644
> > --- a/chardev/char-socket.c
> > +++ b/chardev/char-socket.c
> > @@ -134,8 +134,8 @@ static int tcp_chr_write(Chardev *chr, const uint8_t
> > *buf, int len)
> >                                          s->write_msgfds,
> >                                          s->write_msgfds_num);
> >
> > -        /* free the written msgfds, no matter what */
> > -        if (s->write_msgfds_num) {
> > +        /* free the written msgfds in any cases other than errno==EAGAIN
> */
> > +        if (EAGAIN != errno && s->write_msgfds_num) {
> >              g_free(s->write_msgfds);
> >              s->write_msgfds = 0;
> >              s->write_msgfds_num = 0;
> > --
> > 2.12.2.windows.2
> >


  reply	other threads:[~2018-05-29  8:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29  8:20 [Qemu-devel] [PATCH] socket: dont't free msgfds if error equals EAGAIN linzhecheng
2018-05-29  8:41 ` Gonglei (Arei) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-29  9:33 linzhecheng
2018-05-29 19:33 ` Eric Blake
2018-05-30  9:05   ` Gonglei (Arei)
2018-05-29  2:52 linzhecheng
2018-05-29  9:11 ` Marc-André Lureau
2018-05-30  2:56 ` Peter Xu
2018-06-01 11:46 ` Daniel P. Berrangé

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=33183CC9F5247A488A2544077AF19020DA64285E@DGGEMA505-MBX.china.huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=linzhecheng@huawei.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wangxinxin.wang@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.