From: Dominique Martinet <asmadeus@codewreck.org>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: vfio hang when unbinding after using qemu as user + vhost_net
Date: Fri, 5 Feb 2016 16:48:07 +0100 [thread overview]
Message-ID: <20160205154807.GA23744@nautica> (raw)
In-Reply-To: <20160205065959.5a3596ac@t450s.home>
Alex Williamson wrote on Fri, Feb 05, 2016:
> I just debugged your case earlier in the week and the bug is with the
> test case.
Thank you for the extra information and sorry for double work.
Getting technical informations through support is hard...
> When vhost is used it takes a reference to the process mm (qemu).
> That reference includes the mmap regions on the vfio device file.
> vhost releases those references when the vhostfd file descriptor
> is released.
> So in the scenario you have here, killing qemu doesn't release the
> vhostfd file descriptor because it's still opened in the script. The
> vfio device is not released because there's still a reference to the
> mmap. You've essentially put yourself into a deadlock
> The solution is to close the vhostfd file descriptor in your test
> script after launching qemu (echo 10<&-). Then qemu will hold the
> last reference to vhostfd and killing qemu will release that file
> descriptor and everything is released as intended.
doh, I was sure I also had the hang when giving /dev/vhost-net to qemu
and letting it open the fd so I wasn't looking at it at all, but you've
got it.
(I think I didn't have the hang as root because I didn't bother with
vhostfd then either, the devil is in the details...)
Closing the fd even after qemu has stopped will free the resource and
let me unbind, so I will just make sure to order vhost-net-related to be
closed before vfio stuff for now.
Really not an obvious lock at first glance though, not sure how this
could be 'fixed' now you've explained it so I'll just let you guys
decide how to handle it. This has been very helpful.
> I don't believe standard management tools like libvirt have this
> problem.
I'm pretty sure this would have been pointed at ages ago if libvirt had
the problem :)
Thank you for your time,
--
Dominique Martinet
next prev parent reply other threads:[~2016-02-05 15:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 12:36 vfio hang when unbinding after using qemu as user + vhost_net Dominique Martinet
2016-02-05 13:59 ` Alex Williamson
2016-02-05 15:48 ` Dominique Martinet [this message]
2016-02-05 16:31 ` Alex Williamson
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=20160205154807.GA23744@nautica \
--to=asmadeus@codewreck.org \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.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