qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Raphael Norwitz <raphael.norwitz@nutanix.com>
Cc: "peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"mreitz@redhat.com" <mreitz@redhat.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"eblake@redhat.com" <eblake@redhat.com>,
	"sgarzare@redhat.com" <sgarzare@redhat.com>
Subject: Re: [PATCH v5] Prevent vhost-user-blk-test hang
Date: Wed, 13 Oct 2021 10:20:11 +0100	[thread overview]
Message-ID: <YWaky/KVbS/KZjlV@stefanha-x1.localdomain> (raw)
In-Reply-To: <20211013062526.GA30621@raphael-debian-dev>

[-- Attachment #1: Type: text/plain, Size: 5010 bytes --]

On Wed, Oct 13, 2021 at 06:25:33AM +0000, Raphael Norwitz wrote:
> On Tue, Oct 05, 2021 at 10:31:06AM -0400, Michael S. Tsirkin wrote:
> > On Thu, Sep 30, 2021 at 10:48:09AM +0100, Stefan Hajnoczi wrote:
> > > On Thu, Sep 30, 2021 at 05:29:06AM +0000, Raphael Norwitz wrote:
> > > > On Tue, Sep 28, 2021 at 10:55:00AM +0200, Stefan Hajnoczi wrote:
> > > > > On Mon, Sep 27, 2021 at 05:17:01PM +0000, Raphael Norwitz wrote:
> > > > > > In the vhost-user-blk-test, as of now there is nothing stoping
> > > > > > vhost-user-blk in QEMU writing to the socket right after forking off the
> > > > > > storage daemon before it has a chance to come up properly, leaving the
> > > > > > test hanging forever. This intermittently hanging test has caused QEMU
> > > > > > automation failures reported multiple times on the mailing list [1].
> > > > > > 
> > > > > > This change makes the storage-daemon notify the vhost-user-blk-test
> > > > > > that it is fully initialized and ready to handle client connections by
> > > > > > creating a pidfile on initialiation. This ensures that the storage-daemon
> > > > > > backend won't miss vhost-user messages and thereby resolves the hang.
> > > > > > 
> > > > > > [1] https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_qemu-2Ddevel_CAFEAcA8kYpz9LiPNxnWJAPSjc-3Dnv532bEdyfynaBeMeohqBp3A-40mail.gmail.com_&d=DwIBAg&c=s883GpUCOChKOHiocYtGcg&r=In4gmR1pGzKB8G5p6LUrWqkSMec2L5EtXZow_FZNJZk&m=fB3Xs9HB_Joc1WbeoKGaipFGQA7TPiMQPKa9OS04FM8&s=buSM5F3BMoUQEmVsEOXaCdERM0onDwoqit7nbLblkVs&e= 
> > > > > 
> > > > 
> > > > Hey Stefan,
> > > > 
> > > > > Hi Raphael,
> > > > > I would like to understand the issue that is being worked around in the
> > > > > patch.
> > > > > 
> > > > > QEMU should be okay with listen fd passing. The qemu-storage-daemon
> > > > > documentation even contains example code for this
> > > > > (docs/tools/qemu-storage-daemon.rst) and that may need to be updated if
> > > > > listen fd passing is fundamentally broken.
> > > > > 
> > > > 
> > > > The issue is that the "client" (in this case vhost-user-blk in QEMU) can
> > > > proceed to use the socket before the storage-daemon has a chance to
> > > > properly start up and monitor it. This is nothing unique to the
> > > > storage-daemon - I've seen races like this happen happend with different
> > > > vhost-user backends before.
> > > > 
> > > > Yes - I do think the docs can be improved to explicitly state that the
> > > > storage-daemon must be allowed to properly initialize before any data is
> > > > sent over the socket. Maybe we should even perscribe the use of the pidfile
> > > > option?
> > > > 
> > > > > Can you share more details about the problem?
> > > > > 
> > > > 
> > > > Did you see my analysis [1]?
> > > > 
> > > > [1] https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_qemu-2Ddevel_20210827165253.GA14291-40raphael-2Ddebian-2Ddev_&d=DwIBAg&c=s883GpUCOChKOHiocYtGcg&r=In4gmR1pGzKB8G5p6LUrWqkSMec2L5EtXZow_FZNJZk&m=fB3Xs9HB_Joc1WbeoKGaipFGQA7TPiMQPKa9OS04FM8&s=o_S2kKO4RQnWw2QnzVi7dgOwgiPbusI9Zche7mWV22I&e= 
> > > > 
> > > > Basically QEMU sends VHOST_USER_GET_PROTOCOL_FEATURES across the vhost
> > > > socket and the storage daemon never receives it. Looking at the
> > > > QEMU state we see it is stuck waiting for a vhost-user response. Meanwhile
> > > > the storage-daemon never receives any message to begin with. AFAICT
> > > > there is nothing stopping QEMU from running first and sending a message
> > > > before vhost-user-blk comes up, and from testing we can see that waiting
> > > > for the storage-daemon to come up resolves the problem completely.
> > > 
> > > The root cause has not been determined yet. QEMU should accept the
> > > incoming connection and then read the previously-sent
> > > VHOST_USER_GET_PROTOCOL_FEATURES message. There is no reason at the
> > > Sockets API level why the message should get lost, so there is probably
> > > a QEMU bug here.
> > 
> > Right. However the test does randomly hang for people and it's
> > not really of interest to anyone. I think we should apply the
> > work-around but yes we should keep working on the root cause, too.
> >
> 
> From my end I have spent some more time looking at it but have not made
> much progress. I was hopeful that David HiIdenbrand’s libvhost-user bug
> fixes may have resolved it, but I tested and even with his patches I
> still see the hang.
> 
> I am determined to get to the bottom of it, but I’m not sure how long it
> will take. If this is impacting people than I agree with merging the
> patch as a workaround.
> 
> From my end, I will send a v6 updating the commit message and add
> comments to make it clear that the patch is a workaround and the root
> cause has not been determined yet. Sound good?

Michael is eager to merge a fix so the tests stop hanging, so that
sounds good.

If I have time I'll take a look too and share anything I find.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2021-10-13  9:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 17:17 [PATCH v5] Prevent vhost-user-blk-test hang Raphael Norwitz
2021-09-28  8:55 ` Stefan Hajnoczi
2021-09-30  5:29   ` Raphael Norwitz
2021-09-30  9:48     ` Stefan Hajnoczi
2021-10-01 20:59       ` Raphael Norwitz
2021-10-05 14:31       ` Michael S. Tsirkin
2021-10-13  6:25         ` Raphael Norwitz
2021-10-13  9:02           ` Michael S. Tsirkin
2021-10-13  9:20           ` Stefan Hajnoczi [this message]
2021-10-19 10:15 ` Stefan Hajnoczi

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=YWaky/KVbS/KZjlV@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=eblake@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=sgarzare@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).