qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Stefano Garzarella <sgarzare@redhat.com>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-block@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Eric Blake" <eblake@redhat.com>, "Coiby Xu" <Coiby.Xu@gmail.com>,
	slp@redhat.com, "Eduardo Habkost" <eduardo@habkost.net>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Raphael Norwitz" <raphael@enfabrica.net>,
	"Kevin Wolf" <kwolf@redhat.com>,
	stefanha@redhat.com, gmaglione@redhat.com
Subject: Re: [PATCH 9/9] hostmem-file: support POSIX shm_open()
Date: Wed, 28 Feb 2024 13:01:55 +0100	[thread overview]
Message-ID: <1dbd722f-d8e2-43a2-a76d-7889e002f7d8@redhat.com> (raw)
In-Reply-To: <20240228114759.44758-10-sgarzare@redhat.com>

On 28.02.24 12:47, Stefano Garzarella wrote:
> Add a new `shm` bool option for `-object memory-backend-file`.
> 
> When this option is set to true, the POSIX shm_open(3) is used instead
> of open(2).
> 
> So a file will not be created in the filesystem, but a "POSIX shared
> memory object" will be instantiated. In Linux this turns into a file
> in /dev/shm, but in other OSes this may not happen (for example in
> macOS or FreeBSD nothing is shown in any filesystem).
> 
> This new feature is useful when we need to share guest memory with
> another process (e.g. vhost-user backend), but we don't have
> memfd_create() or any special filesystems (e.g. /dev/shm) available
> as in macOS.
> 
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> I am not sure this is the best way to support shm_open() in QEMU.
> 
> Other solutions I had in mind were:
> 
> - create a new memory-backend-shm
> 
> - extend memory-backend-memfd to use shm_open() on systems where memfd is
> not available (problem: shm_open wants a name to assign to the object, but
> we can do a workaround by using a random name and do the unlink right away)
> 
> Any preference/suggestion?

Both sound like reasonable options, and IMHO better than hostmem-file 
with things that are not necessarily "real" files.

Regarding memory-backend-memfd, we similarly have to pass a name to 
memfd_create(), although for different purpose: "The  name  supplied in 
name is used as a filename and will be displayed as the target of the 
corresponding symbolic link in the directory /proc/self/fd/".

So we simply pass TYPE_MEMORY_BACKEND_MEMFD.

Likely, memory-backend-shm that directly maps to shm_open() and only 
provides properties reasonable for shm_open() is the cleanest approach. 
So that would currently be my preference :)

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-02-28 12:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 11:47 [PATCH 0/9] vhost-user: support any POSIX system (tested on macOS and FreeBSD) Stefano Garzarella
2024-02-28 11:47 ` [PATCH 1/9] libvhost-user: set msg.msg_control to NULL when it is empty Stefano Garzarella
2024-02-28 11:47 ` [PATCH 2/9] libvhost-user: fail vu_message_write() if sendmsg() is failing Stefano Garzarella
2024-02-28 11:47 ` [PATCH 3/9] libvhost-user: mask F_INFLIGHT_SHMFD if memfd is not supported Stefano Garzarella
2024-02-28 11:47 ` [PATCH 4/9] vhost-user-server: don't abort if we can't set fd non-blocking Stefano Garzarella
2024-02-28 11:47 ` [PATCH 5/9] contrib/vhost-user-blk: fix bind() using the right size of the address Stefano Garzarella
2024-02-28 11:47 ` [PATCH 6/9] vhost-user: enable frontends on any POSIX system Stefano Garzarella
2024-02-28 11:47 ` [PATCH 7/9] libvhost-user: enable it " Stefano Garzarella
2024-02-28 11:47 ` [PATCH 8/9] contrib/vhost-user-blk: enabled " Stefano Garzarella
2024-02-28 11:47 ` [PATCH 9/9] hostmem-file: support POSIX shm_open() Stefano Garzarella
2024-02-28 12:01   ` David Hildenbrand [this message]
2024-02-29  8:46     ` Stefano Garzarella
2024-02-28 12:08   ` Daniel P. Berrangé
2024-02-29  8:49     ` Stefano Garzarella
2024-02-28 12:32   ` Markus Armbruster
2024-02-29  8:57     ` Stefano Garzarella
2024-02-29 10:28       ` Markus Armbruster
2024-02-29 11:01         ` Stefano Garzarella
2024-02-28 11:51 ` [PATCH 0/9] vhost-user: support any POSIX system (tested on macOS and FreeBSD) Stefano Garzarella

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=1dbd722f-d8e2-43a2-a76d-7889e002f7d8@redhat.com \
    --to=david@redhat.com \
    --cc=Coiby.Xu@gmail.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=gmaglione@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael@enfabrica.net \
    --cc=sgarzare@redhat.com \
    --cc=slp@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=thuth@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).