From: Didier Pallard <didier.pallard@6wind.com>
To: "Victor Kaplansky" <victork@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: Thibaut Collet <thibaut.collet@6wind.com>,
Jean-Mickael Guerin <jmg@6wind.com>,
pbonzini@redhat.com, QEMU <qemu-devel@nongnu.org>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/3] char: fix vhost-user socket full
Date: Wed, 09 Dec 2015 18:06:06 +0100 [thread overview]
Message-ID: <56685F7E.6020807@6wind.com> (raw)
In-Reply-To: <20151209173600-mutt-send-email-victork@redhat.com>
On 12/09/2015 04:59 PM, Victor Kaplansky wrote:
> On Mon, Dec 07, 2015 at 02:31:36PM +0100, Marc-André Lureau wrote:
>> Hi
>>
>> On Thu, Dec 3, 2015 at 10:53 AM, Didier Pallard
>> <didier.pallard@6wind.com> wrote:
>>> unix_send_msgfds is used by vhost-user control socket. qemu_chr_fe_write_all
>>> is used to send a message and retries as long as EAGAIN errno is set,
>>> but write_msgfds buffer is freed after first EAGAIN failure, causing
>>> message to be sent without proper fds attachment.
>>>
>>> In case unix_send_msgfds is called through qemu_chr_fe_write, it will be
>>> user responsability to resend message as is or to free write_msgfds
>>> using set_msgfds(0)
>>>
>>> Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
>>> Reviewed-by: Thibaut Collet <thibaut.collet@6wind.com>
>>> ---
>>> qemu-char.c | 10 ++++++++++
>>> 1 file changed, 10 insertions(+)
>>>
>>> diff --git a/qemu-char.c b/qemu-char.c
>>> index 5448b0f..26d5f2e 100644
>>> --- a/qemu-char.c
>>> +++ b/qemu-char.c
>>> @@ -2614,6 +2614,16 @@ static int unix_send_msgfds(CharDriverState *chr, const uint8_t *buf, int len)
>>> r = sendmsg(s->fd, &msgh, 0);
>>> } while (r < 0 && errno == EINTR);
>>>
>>> + /* Ancillary data are not sent if no byte is written
>>> + * so don't free msgfds buffer if return value is EAGAIN
>>> + * If called from qemu_chr_fe_write_all retry will come soon
>>> + * If called from qemu_chr_fe_write, it is the user responsibility
>>> + * to resend message or free fds using set_msgfds(0)
>>> + */
>>> + if (r < 0 && errno == EAGAIN) {
>>> + return r;
>>> + }
>>> +
>>
>> This looks reasonable to me. However, I don't know what happens with
>> partial write of ancillary data. Hopefully it's all or nothing.
>> Apparently, reading unix_stream_sendmsg() in kernel shows that as long
>> as a few bytes have been sent, the ancillary data is sent. So it looks
>> like it still does the right thing in case of a partial write.
>
> If I may put my two cents in, it looks to me very similar to an
> fd leakage on back-end side. When a new set_call_fd request
> arrives, it is very easy to forget closing the previous file
> descriptor. As result, if interrupts are actively maksed/unmasked
> by the guest, the back-end can easily reach maximum fds, which
> will cause receiving side silently drop new fds in aux data.
> --Victor
>
Hi victor,
This is not a problem of fd exausted. This was my first axe of
investigation, but fd management is correct in our vhost-user backend,
there is no fd leakage.
And i guess you are refering to the problem fixed by patches 2 and 3,
since the problem corrected by this patch is a message arriving from
qemu without ancillary data, whatever the state of the fds in the
vhost-user backend.
thanks
didier
>>
>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>>
>>> /* free the written msgfds, no matter what */
>>> if (s->write_msgfds_num) {
>>> g_free(s->write_msgfds);
>>> --
>>> 2.1.4
>>>
>>>
>>
>>
>>
>> --
>> Marc-André Lureau
>>
next prev parent reply other threads:[~2015-12-09 17:06 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 9:53 [Qemu-devel] Linux vhost-user interrupt management fixes Didier Pallard
2015-12-03 9:53 ` [Qemu-devel] [PATCH 1/3] char: fix vhost-user socket full Didier Pallard
2015-12-07 13:31 ` Marc-André Lureau
2015-12-09 15:59 ` Victor Kaplansky
2015-12-09 17:06 ` Didier Pallard [this message]
2015-12-10 12:56 ` Victor Kaplansky
2015-12-10 15:09 ` Didier Pallard
2015-12-17 14:41 ` Victor Kaplansky
2016-02-04 13:13 ` Michael S. Tsirkin
2016-02-04 14:10 ` Michael S. Tsirkin
2016-02-08 13:12 ` Didier Pallard
2016-02-09 11:37 ` Michael S. Tsirkin
2016-02-09 11:48 ` Daniel P. Berrange
2016-02-09 12:21 ` Michael S. Tsirkin
2016-02-09 16:17 ` Didier Pallard
2016-02-09 16:50 ` Michael S. Tsirkin
2016-02-09 17:04 ` Daniel P. Berrange
2016-02-10 9:35 ` Didier Pallard
2016-02-10 11:53 ` Michael S. Tsirkin
2016-02-10 12:15 ` Daniel P. Berrange
2016-02-19 9:09 ` Didier Pallard
2015-12-03 9:53 ` [Qemu-devel] [PATCH 2/3] virtio-pci: add an option to bypass guest_notifier_mask Didier Pallard
2015-12-07 13:37 ` Marc-André Lureau
2015-12-07 13:59 ` Marc-André Lureau
2015-12-09 15:06 ` Didier Pallard
2016-02-04 13:08 ` Michael S. Tsirkin
2016-02-08 13:24 ` Didier Pallard
2016-02-15 15:38 ` Victor Kaplansky
2015-12-03 9:53 ` [Qemu-devel] [PATCH 3/3] vhost-net: force guest_notifier_mask bypass in vhost-user case Didier Pallard
2016-02-04 13:06 ` Michael S. Tsirkin
2015-12-04 10:04 ` [Qemu-devel] Linux vhost-user interrupt management fixes Didier Pallard
2016-01-25 9:22 ` Victor Kaplansky
2016-01-26 9:25 ` Didier Pallard
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=56685F7E.6020807@6wind.com \
--to=didier.pallard@6wind.com \
--cc=jmg@6wind.com \
--cc=marcandre.lureau@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thibaut.collet@6wind.com \
--cc=victork@redhat.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.