qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Stefano Garzarella" <sgarzare@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Roman Kiryanov" <rkir@google.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	alex.bennee@linaro.org, "QEMU Developers" <qemu-devel@nongnu.org>,
	"JP Cottin" <jpcottin@google.com>,
	"Erwin Jansen" <jansene@google.com>,
	"Mehdi Alizadeh" <mett@google.com>
Subject: Re: Hermetic virtio-vsock in QEMU
Date: Wed, 8 May 2024 13:51:33 +0100	[thread overview]
Message-ID: <Zjt1VdKQ3KIZChg9@redhat.com> (raw)
In-Reply-To: <30baeb56-64d2-4ea3-8e53-6a5c50999979@redhat.com>

On Wed, May 08, 2024 at 02:37:52PM +0200, Paolo Bonzini wrote:
> On 5/8/24 11:38, Stefano Garzarella wrote:
> > On Wed, May 08, 2024 at 01:13:09PM GMT, Marc-André Lureau wrote:
> > > Hi
> > > 
> > > On Wed, May 8, 2024 at 11:50 AM Stefano Garzarella
> > > <sgarzare@redhat.com> wrote:
> > > > 
> > > > Hi Roman,
> > > > 
> > > > On Tue, May 07, 2024 at 11:20:50PM GMT, Roman Kiryanov wrote:
> > > > >Hi Stefano,
> > > > >
> > > > >On Tue, May 7, 2024 at 1:10 AM Stefano Garzarella
> > > > <sgarzare@redhat.com> wrote:
> > > > >> I have no experience with Windows, but what we need for
> > > > vhost-user is:
> > > > >>
> > > > >> - AF_UNIX and be able to send file descriptors using ancillary data
> > > > >>    (i.e. SCM_RIGHTS)
> > > > >
> > > > >As far as I understand, Windows does NOT support SCM_RIGHTS
> > > > over AF_UNIX.
> > > > 
> > > > Thank you for the information. This is unfortunate and does not allow
> > > > us to use vhost-user as it is on Windows.
> > > > 
> > > 
> > > fwiw, Windows has other mechanisms to share resources between processes.
> > > 
> > > To share/pass sockets, you can use WSADuplicateSocket. For shared
> > > memory and other resources, DuplicateHandle API.
> > 
> > Cool, thanks for sharing that. So it could be done, but I think we need
> > to extend the vhost-user protocol to work with Windows.
> 
> It would be possible to implement the memfd backend for Windows, using the
> CreateFileMapping() API.
> 
> However, the vhost-user protocol's VHOST_USER_SET_MEM_TABLE requests do not
> have any padding that can be used to pass the handle to the target. An
> extended version would be necessary.
> 
> One difference between Unix and Windows is that, if the vhost-server messes
> up the handling of messages from the socket, and therefore it does not close
> the handle, it is leaked forever.  This is not a huge deal per se, but I
> think it means that QEMU is not allowed to "open" a privileged vhost-user
> server process with PROCESS_DUP_HANDLE rights (translation: QEMU cannot
> provide duplicate handles to a privileged vhost-user server process).
> 
> Also I'm not sure what the cost of DuplicateHandle() is, and whether it's a
> good idea to do it for every region on every VHOST_USER_SET_MEM_TABLE
> request.  But VHOST_USER_SET_MEM_TABLE is not a fast path, so perhaps it's
> okay.
> 
> I think a virtio-vsock implementation in QEMU would be easier, lacking
> another usecase for vhost-user on Windows.
> 
> The main design question is whether multiple virtio-vsock devices for the
> same guest should share the CID space or not (I think it should, but I'm not
> 100% sure).  To connect host<->guest you could have a QOM object, here I am
> naming it vsock-forward as an example:

Designwise, a native VSOCK backend in QEMU really should implement the
same approach defined by firecracker, so that we have interoperability
with systemd, firecracker and cloud-hypervisor. See

  https://gitlab.com/qemu-project/qemu/-/issues/2095
  https://github.com/firecracker-microvm/firecracker/blob/main/docs/vsock.md#firecracker-virtio-vsock-design

This involves multiple UNIX sockets on the host

  1 * /some/path   - QEMU listens on this, and accepts connections
                     from other host processes. The client sends
                     "PORT <num>" to indicate that guest port it
                     is connecting to

  n * /some/path_$PORT - QEMU connect to this for outgoing connections
                         from the guest. Other host processes need
                         to listen on whatever path_$PORT need to be
                         serviced

IOW, from a CLI pov, QEMU should need nothing more than

    -object vsock-forward,prefix=/some/path


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2024-05-08 12:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 21:30 Hermetic virtio-vsock in QEMU Roman Kiryanov
2024-04-15 11:20 ` Daniel P. Berrangé
2024-04-17 19:31   ` Roman Kiryanov
2024-04-18  9:34     ` Daniel P. Berrangé
2024-05-07  8:10       ` Stefano Garzarella
2024-05-08  6:20         ` Roman Kiryanov
2024-05-08  7:49           ` Stefano Garzarella
2024-05-08  9:13             ` Marc-André Lureau
2024-05-08  9:38               ` Stefano Garzarella
2024-05-08 12:37                 ` Paolo Bonzini
2024-05-08 12:51                   ` Daniel P. Berrangé [this message]
2024-05-08 13:00                     ` Paolo Bonzini
2024-05-08 13:32                       ` 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=Zjt1VdKQ3KIZChg9@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=jansene@google.com \
    --cc=jpcottin@google.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mett@google.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rkir@google.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).