qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>,
	Felipe Franciosi <felipe@nutanix.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Marc-André Lureau" <mlureau@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Marc-Andre Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] libvhost-user: Start VQs on SET_VRING_CALL
Date: Thu, 19 Jan 2017 11:26:45 +0100	[thread overview]
Message-ID: <de787d49-c238-8e30-7b37-f1e238a3dcdc@redhat.com> (raw)
In-Reply-To: <20170117205832-mutt-send-email-mst@kernel.org>



On 17/01/2017 20:00, Michael S. Tsirkin wrote:
>>> vhost user is not supposed to use maskfd at all.
>>>
>>> We have this code:
>>>        if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
>>>            dev->use_guest_notifier_mask = false;
>>>        }
>>>
>>> isn't it effective?
>>
>> I'm observing this problem when using vhost-user-scsi, not -net. So the code above is not in effect. Anyway, I'd expect the race I described to also happen on vhost-scsi.
>
> maskfd is just racy for vhost-user ATM.  I'm guessing vhost-scsi should
> just set use_guest_notifier_mask, that will fix it.  Alternatively,
> rework masking to support sync with the backend - but I doubt it's
> useful.

I agree with Michael that this is a QEMU bug, not a libvhost-user bug.

Thanks,

Paolo

>>>
>>>
>>>
>>>> Qemu sends the new callfd to the application
>>>>
>>>> It's not hard to repro. How could this situation be avoided?
>>>>
>>>> Cheers,
>>>> Felipe
>>>>
>>>>
>>>>>
>>>>>>
>>>>>>>
>>>>>>>>>
>>>>>>>>> Perhaps it's best for now to delay the callfd notification with a flag until it is received?
>>>>>>>>
>>>>>>>> The other idea is to always kick when we receive the callfd. I remember discussing that alternative with you before libvhost-user went in. The protocol says both the driver and the backend must handle spurious kicks. This approach also fixes the bug.
>>>>>>>>
>>>>>>>> I'm happy with whatever alternative you want, as long it makes libvhost-user usable for storage devices.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Felipe
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
>>>>>>>>>> ---
>>>>>>>>>> contrib/libvhost-user/libvhost-user.c | 26 +++++++++++++-------------
>>>>>>>>>> 1 file changed, 13 insertions(+), 13 deletions(-)
>>>>>>>>>>
>>>>>>>>>> diff --git a/contrib/libvhost-user/libvhost-user.c
>>>>>>>>>> b/contrib/libvhost-user/libvhost-user.c
>>>>>>>>>> index af4faad..a46ef90 100644
>>>>>>>>>> --- a/contrib/libvhost-user/libvhost-user.c
>>>>>>>>>> +++ b/contrib/libvhost-user/libvhost-user.c
>>>>>>>>>> @@ -607,19 +607,6 @@ vu_set_vring_kick_exec(VuDev *dev, VhostUserMsg *vmsg)
>>>>>>>>>>      DPRINT("Got kick_fd: %d for vq: %d\n", vmsg->fds[0], index);
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>> -    dev->vq[index].started = true;
>>>>>>>>>> -    if (dev->iface->queue_set_started) {
>>>>>>>>>> -        dev->iface->queue_set_started(dev, index, true);
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>> -    if (dev->vq[index].kick_fd != -1 && dev->vq[index].handler) {
>>>>>>>>>> -        dev->set_watch(dev, dev->vq[index].kick_fd, VU_WATCH_IN,
>>>>>>>>>> -                       vu_kick_cb, (void *)(long)index);
>>>>>>>>>> -
>>>>>>>>>> -        DPRINT("Waiting for kicks on fd: %d for vq: %d\n",
>>>>>>>>>> -               dev->vq[index].kick_fd, index);
>>>>>>>>>> -    }
>>>>>>>>>> -
>>>>>>>>>>  return false;
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> @@ -661,6 +648,19 @@ vu_set_vring_call_exec(VuDev *dev, VhostUserMsg *vmsg)
>>>>>>>>>>
>>>>>>>>>>  DPRINT("Got call_fd: %d for vq: %d\n", vmsg->fds[0], index);
>>>>>>>>>>
>>>>>>>>>> +    dev->vq[index].started = true;
>>>>>>>>>> +    if (dev->iface->queue_set_started) {
>>>>>>>>>> +        dev->iface->queue_set_started(dev, index, true);
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>> +    if (dev->vq[index].kick_fd != -1 && dev->vq[index].handler) {
>>>>>>>>>> +        dev->set_watch(dev, dev->vq[index].kick_fd, VU_WATCH_IN,
>>>>>>>>>> +                       vu_kick_cb, (void *)(long)index);
>>>>>>>>>> +
>>>>>>>>>> +        DPRINT("Waiting for kicks on fd: %d for vq: %d\n",
>>>>>>>>>> +               dev->vq[index].kick_fd, index);
>>>>>>>>>> +    }
>>>>>>>>>> +
>>>>>>>>>>  return false;
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> 1.9.4
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
> 
> 

  reply	other threads:[~2017-01-19 10:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-13  1:14 [Qemu-devel] [PATCH] libvhost-user: Start VQs on SET_VRING_CALL Felipe Franciosi
2017-01-13 15:03 ` Marc-André Lureau
2017-01-13 15:09   ` Felipe Franciosi
2017-01-13 17:04     ` Michael S. Tsirkin
2017-01-13 17:15       ` Felipe Franciosi
2017-01-13 18:18         ` Michael S. Tsirkin
2017-01-13 22:29           ` Felipe Franciosi
2017-01-17 18:41             ` Michael S. Tsirkin
2017-01-17 18:53               ` Felipe Franciosi
2017-01-17 19:00                 ` Michael S. Tsirkin
2017-01-19 10:26                   ` Paolo Bonzini [this message]
2017-01-16 18:22 ` Michael S. Tsirkin
2017-01-16 18:27   ` Felipe Franciosi
2017-01-17 18:43     ` Michael S. Tsirkin

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=de787d49-c238-8e30-7b37-f1e238a3dcdc@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=felipe@nutanix.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mlureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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 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).