qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Albert Esteve <aesteve@redhat.com>, qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	hi@alyssa.is, "Alex Bennée" <alex.bennee@linaro.org>,
	"Laurent Vivier" <lvivier@redhat.com>,
	slp@redhat.com, "Stefano Garzarella" <sgarzare@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	jasowang@redhat.com, stefanha@redhat.com, dbassey@redhat.com,
	stevensd@chromium.org
Subject: Re: [PATCH v6 1/8] vhost-user: Add VirtIO Shared Memory map request
Date: Mon, 18 Aug 2025 09:37:31 +0200	[thread overview]
Message-ID: <6fe9163d-5690-4572-98d1-f0a9cfc3cd80@redhat.com> (raw)
In-Reply-To: <20250814083749.1317197-2-aesteve@redhat.com>


> +    /* Map the shared memory region */
> +    mapped_addr = mmap(NULL, len, prot_flags, MAP_SHARED, fd, fd_offset);
> +    if (mapped_addr == MAP_FAILED) {
> +        error_report("Failed to map shared memory region: %s", strerror(errno));
> +        return NULL;
> +    }
> +
> +    /* Create the VhostUserShmemObject */
> +    shmem_obj = VHOST_USER_SHMEM_OBJECT(
> +        object_new(TYPE_VHOST_USER_SHMEM_OBJECT));
> +
> +    /* Set up object properties */
> +    shmem_obj->shmid = shmid;
> +    shmem_obj->fd = fd;
> +    shmem_obj->fd_offset = fd_offset;
> +    shmem_obj->shm_offset = shm_offset;
> +    shmem_obj->len = len;
> +    shmem_obj->flags = flags;
> +    shmem_obj->mapped_addr = mapped_addr;
> +
> +    /* Create MemoryRegion as a child of this object */
> +    mr = g_new0(MemoryRegion, 1);
> +    g_string_printf(mr_name, "vhost-user-shmem-%d-%" PRIx64, shmid, shm_offset);
> +
> +    /* Initialize MemoryRegion with the mapped memory */
> +    memory_region_init_ram_device_ptr(mr, OBJECT(shmem_obj), mr_name->str,
> +                                      len, mapped_addr);

Oh, why did we go from memory_region_init_ram_from_fd() back to 
memory_region_init_ram_device_ptr() in this series?

I thought having a wrapper object around the memory region would have 
been sufficient to handle the race?

-- 
Cheers

David / dhildenb



  parent reply	other threads:[~2025-08-18  7:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14  8:37 [PATCH v6 0/8] vhost-user: Add SHMEM_MAP/UNMAP requests Albert Esteve
2025-08-14  8:37 ` [PATCH v6 1/8] vhost-user: Add VirtIO Shared Memory map request Albert Esteve
2025-08-18  7:05   ` Albert Esteve
2025-08-18  7:37   ` David Hildenbrand [this message]
2025-08-18  8:51     ` Albert Esteve
2025-08-14  8:37 ` [PATCH v6 2/8] vhost_user.rst: Align VhostUserMsg excerpt members Albert Esteve
2025-08-14  8:37 ` [PATCH v6 3/8] vhost_user.rst: Add SHMEM_MAP/_UNMAP to spec Albert Esteve
2025-08-14  8:37 ` [PATCH v6 4/8] vhost_user: Add frontend get_shmem_config command Albert Esteve
2025-08-14  8:37 ` [PATCH v6 5/8] vhost_user.rst: Add GET_SHMEM_CONFIG message Albert Esteve
2025-08-14  8:37 ` [PATCH v6 6/8] tests/qtest: Add GET_SHMEM validation test Albert Esteve
2025-08-14  8:37 ` [PATCH v6 7/8] qmp: add shmem feature map Albert Esteve
2025-08-14  8:37 ` [PATCH v6 8/8] vhost-user-device: Add shared memory BAR Albert Esteve

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=6fe9163d-5690-4572-98d1-f0a9cfc3cd80@redhat.com \
    --to=david@redhat.com \
    --cc=aesteve@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=dbassey@redhat.com \
    --cc=farosas@suse.de \
    --cc=hi@alyssa.is \
    --cc=jasowang@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=slp@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=stevensd@chromium.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;
as well as URLs for NNTP newsgroup(s).