From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Jag Raman <jag.raman@oracle.com>
Cc: elena.ufimtseva@oracle.com, fam@euphon.net, thuth@redhat.com,
john.g.johnson@oracle.com, ehabkost@redhat.com,
konrad.wilk@oracle.com, quintela@redhat.com, berrange@redhat.com,
mst@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com,
ross.lagerwall@citrix.com, mreitz@redhat.com,
kanth.ghatraju@oracle.com, kraxel@redhat.com,
stefanha@redhat.com, pbonzini@redhat.com, liran.alon@oracle.com,
marcandre.lureau@gmail.com, kwolf@redhat.com, rth@twiddle.net
Subject: Re: [Qemu-devel] [RFC v3 PATCH 01/45] multi-process: memory: alloc RAM from file at offset
Date: Thu, 5 Sep 2019 16:17:56 +0100 [thread overview]
Message-ID: <20190905151756.GM2700@work-vm> (raw)
In-Reply-To: <2b0b3ce0-06d6-e953-66fd-ead53110c0a9@oracle.com>
* Jag Raman (jag.raman@oracle.com) wrote:
>
>
> On 9/4/2019 4:11 AM, Dr. David Alan Gilbert wrote:
> > * Jagannathan Raman (jag.raman@oracle.com) wrote:
> > > Allow RAM MemoryRegion to be created from an offset in a file, instead
> > > of allocating at offset of 0 by default. This is needed to synchronize
> > > RAM between QEMU & remote process.
> > > This will be needed for the following patches.
> > >
> > > Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
> > > Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
> > > Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
> > > ---
> > > exec.c | 11 +++++++----
> > > include/exec/ram_addr.h | 2 +-
> > > include/qemu/mmap-alloc.h | 3 ++-
> > > memory.c | 2 +-
> > > util/mmap-alloc.c | 7 ++++---
> > > util/oslib-posix.c | 2 +-
> > > 6 files changed, 16 insertions(+), 11 deletions(-)
> >
> > I'm surprised this doesn't change something in
> > vhost-user.c:vhost_user_set_mem_table so that the vhost-user client
> > knows what it's mapping?
>
> Hi Dave,
>
> vhost-user does not use the functions addressed in this patch for
> mapping the RAM onto the remote process. It calls mmap() for this
> purpose (vu_set_mem_table_exec()).
It should at least check that the file it's sending over set-mem-table
has a 0 offset, otherwise things could get confused if someone tries
to run a vhost-user device on a system that's also running multi-process
(which should be a whole world of fun!)
dave
> Thanks!
> --
> Jag
>
> >
> > Dave
> >
> > > diff --git a/exec.c b/exec.c
> > > index 3e78de3..b3f1aa9 100644
> > > --- a/exec.c
> > > +++ b/exec.c
> > > @@ -1885,6 +1885,7 @@ static void *file_ram_alloc(RAMBlock *block,
> > > ram_addr_t memory,
> > > int fd,
> > > bool truncate,
> > > + off_t offset,
> > > Error **errp)
> > > {
> > > MachineState *ms = MACHINE(qdev_get_machine());
> > > @@ -1936,7 +1937,8 @@ static void *file_ram_alloc(RAMBlock *block,
> > > }
> > > area = qemu_ram_mmap(fd, memory, block->mr->align,
> > > - block->flags & RAM_SHARED, block->flags & RAM_PMEM);
> > > + block->flags & RAM_SHARED, block->flags & RAM_PMEM,
> > > + offset);
> > > if (area == MAP_FAILED) {
> > > error_setg_errno(errp, errno,
> > > "unable to map backing store for guest RAM");
> > > @@ -2325,7 +2327,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared)
> > > #ifdef CONFIG_POSIX
> > > RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
> > > uint32_t ram_flags, int fd,
> > > - Error **errp)
> > > + off_t offset, Error **errp)
> > > {
> > > RAMBlock *new_block;
> > > Error *local_err = NULL;
> > > @@ -2370,7 +2372,8 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
> > > new_block->used_length = size;
> > > new_block->max_length = size;
> > > new_block->flags = ram_flags;
> > > - new_block->host = file_ram_alloc(new_block, size, fd, !file_size, errp);
> > > + new_block->host = file_ram_alloc(new_block, size, fd, !file_size, offset,
> > > + errp);
> > > if (!new_block->host) {
> > > g_free(new_block);
> > > return NULL;
> > > @@ -2400,7 +2403,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
> > > return NULL;
> > > }
> > > - block = qemu_ram_alloc_from_fd(size, mr, ram_flags, fd, errp);
> > > + block = qemu_ram_alloc_from_fd(size, mr, ram_flags, fd, 0, errp);
> > > if (!block) {
> > > if (created) {
> > > unlink(mem_path);
> > > diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
> > > index b7b2e60..15837a1 100644
> > > --- a/include/exec/ram_addr.h
> > > +++ b/include/exec/ram_addr.h
> > > @@ -164,7 +164,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
> > > Error **errp);
> > > RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr,
> > > uint32_t ram_flags, int fd,
> > > - Error **errp);
> > > + off_t offset, Error **errp);
> > > RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
> > > MemoryRegion *mr, Error **errp);
> > > diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h
> > > index e786266..4f57985 100644
> > > --- a/include/qemu/mmap-alloc.h
> > > +++ b/include/qemu/mmap-alloc.h
> > > @@ -25,7 +25,8 @@ void *qemu_ram_mmap(int fd,
> > > size_t size,
> > > size_t align,
> > > bool shared,
> > > - bool is_pmem);
> > > + bool is_pmem,
> > > + off_t start);
> > > void qemu_ram_munmap(int fd, void *ptr, size_t size);
> > > diff --git a/memory.c b/memory.c
> > > index 5d8c9a9..debed5e 100644
> > > --- a/memory.c
> > > +++ b/memory.c
> > > @@ -1622,7 +1622,7 @@ void memory_region_init_ram_from_fd(MemoryRegion *mr,
> > > mr->destructor = memory_region_destructor_ram;
> > > mr->ram_block = qemu_ram_alloc_from_fd(size, mr,
> > > share ? RAM_SHARED : 0,
> > > - fd, &err);
> > > + fd, 0, &err);
> > > mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;
> > > if (err) {
> > > mr->size = int128_zero();
> > > diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
> > > index f7f177d..4b727bd 100644
> > > --- a/util/mmap-alloc.c
> > > +++ b/util/mmap-alloc.c
> > > @@ -86,7 +86,8 @@ void *qemu_ram_mmap(int fd,
> > > size_t size,
> > > size_t align,
> > > bool shared,
> > > - bool is_pmem)
> > > + bool is_pmem,
> > > + off_t start)
> > > {
> > > int flags;
> > > int map_sync_flags = 0;
> > > @@ -147,7 +148,7 @@ void *qemu_ram_mmap(int fd,
> > > offset = QEMU_ALIGN_UP((uintptr_t)guardptr, align) - (uintptr_t)guardptr;
> > > ptr = mmap(guardptr + offset, size, PROT_READ | PROT_WRITE,
> > > - flags | map_sync_flags, fd, 0);
> > > + flags | map_sync_flags, fd, start);
> > > if (ptr == MAP_FAILED && map_sync_flags) {
> > > if (errno == ENOTSUP) {
> > > @@ -172,7 +173,7 @@ void *qemu_ram_mmap(int fd,
> > > * we will remove these flags to handle compatibility.
> > > */
> > > ptr = mmap(guardptr + offset, size, PROT_READ | PROT_WRITE,
> > > - flags, fd, 0);
> > > + flags, fd, start);
> > > }
> > > if (ptr == MAP_FAILED) {
> > > diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> > > index fe0309c..f6a243f 100644
> > > --- a/util/oslib-posix.c
> > > +++ b/util/oslib-posix.c
> > > @@ -204,7 +204,7 @@ void *qemu_memalign(size_t alignment, size_t size)
> > > void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared)
> > > {
> > > size_t align = QEMU_VMALLOC_ALIGN;
> > > - void *ptr = qemu_ram_mmap(-1, size, align, shared, false);
> > > + void *ptr = qemu_ram_mmap(-1, size, align, shared, false, 0);
> > > if (ptr == MAP_FAILED) {
> > > return NULL;
> > > --
> > > 1.8.3.1
> > >
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> >
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2019-09-05 15:20 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-03 20:37 [Qemu-devel] [RFC v3 PATCH 00/45] Initial support of multi-process qemu Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 01/45] multi-process: memory: alloc RAM from file at offset Jagannathan Raman
2019-09-04 8:11 ` Dr. David Alan Gilbert
2019-09-05 15:07 ` Jag Raman
2019-09-05 15:17 ` Dr. David Alan Gilbert [this message]
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 02/45] multi-process: util: Add qemu_thread_cancel() to cancel running thread Jagannathan Raman
2019-09-04 9:11 ` Daniel P. Berrangé
2019-09-05 15:10 ` Jag Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 03/45] multi-process: add a command line option for debug file Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 04/45] multi-process: Add stub functions to facilate build of multi-process Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 05/45] multi-process: Add config option for multi-process QEMU Jagannathan Raman
2019-09-12 14:31 ` Stefan Hajnoczi
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 06/45] multi-process: build system for remote device process Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 07/45] multi-process: define proxy-link object Jagannathan Raman
2019-09-04 8:22 ` Daniel P. Berrangé
2019-09-05 14:37 ` Eric Blake
2019-09-05 15:20 ` Jag Raman
2019-09-12 15:34 ` Stefan Hajnoczi
2019-10-09 13:37 ` Stefan Hajnoczi
2019-10-09 17:58 ` Elena Ufimtseva
2019-10-10 20:21 ` Jag Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 08/45] multi-process: add functions to synchronize proxy and remote endpoints Jagannathan Raman
2019-09-12 15:45 ` Stefan Hajnoczi
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 09/45] multi-process: setup PCI host bridge for remote device Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 10/45] multi-process: setup a machine object for remote device process Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 11/45] multi-process: setup memory manager for remote device Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 12/45] multi-process: remote process initialization Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 13/45] multi-process: introduce proxy object Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 14/45] mutli-process: build remote command line args Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 15/45] multi-process: add support of device id to communication channel Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 16/45] multi-process: PCI BAR read/write handling for proxy & remote endpoints Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 17/45] multi-process: modify BARs read/write to support dev_id Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 18/45] multi-process: support dev id in config read/write Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 19/45] multi-process: Add LSI device proxy object Jagannathan Raman
2019-09-05 10:22 ` Gerd Hoffmann
2019-09-05 15:22 ` Jag Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 20/45] multi-process: Synchronize remote memory Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 21/45] multi-process: create IOHUB object to handle irq Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 22/45] multi-process: configure remote side devices Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 23/45] multi-process: add qdev_proxy_add to create proxy devices Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 24/45] multi-process: remote: add setup_devices and setup_drive msg processing Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 25/45] multi-process: remote: use fd for socket from parent process Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 26/45] multi-process: remote: add create_done condition Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 27/45] multi-process: add processing of remote drive and device command line Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 28/45] multi-process: Introduce build flags to separate remote process code Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 29/45] multi-process: refractor vl.c code to re-use in remote Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 30/45] multi-process: add remote option Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 31/45] multi-process: add remote options parser Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 32/45] multi-process: add parse_cmdline in remote process Jagannathan Raman
2019-09-03 20:37 ` [Qemu-devel] [RFC v3 PATCH 33/45] multi-process: add support for multiple devices Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 34/45] multi-process: add heartbeat timer and signal handler Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 35/45] multi-process: handle heartbeat messages in remote process Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 36/45] multi-process: Use separate MMIO communication channel Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 37/45] multi-process: perform device reset in the remote process Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 38/45] multi-process/mon: stub functions to enable QMP module for " Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 39/45] multi-process/mon: build system for QMP module in " Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 40/45] multi-process/mon: Refactor monitor/chardev functions out of vl.c Jagannathan Raman
2019-09-04 8:37 ` Dr. David Alan Gilbert
2019-09-05 15:23 ` Jag Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 41/45] multi-process/mon: trim HMP command set for remote storage processes Jagannathan Raman
2019-09-04 8:56 ` Dr. David Alan Gilbert
2019-09-05 15:54 ` Jag Raman
2019-09-05 15:57 ` Dr. David Alan Gilbert
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 42/45] multi-process/mon: Initialize QMP module for remote processes Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 43/45] multi-process: prevent duplicate memory initialization in remote Jagannathan Raman
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 44/45] multi-process: add the concept description to docs/devel/qemu-multiprocess Jagannathan Raman
2019-09-05 10:10 ` Gerd Hoffmann
2019-09-05 10:16 ` Peter Maydell
2019-09-05 16:08 ` Elena Ufimtseva
2019-09-03 20:38 ` [Qemu-devel] [RFC v3 PATCH 45/45] multi-process: add configure and usage information Jagannathan Raman
2019-09-04 9:18 ` [Qemu-devel] [RFC v3 PATCH 00/45] Initial support of multi-process qemu Daniel P. Berrangé
2019-09-04 16:29 ` Jag Raman
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=20190905151756.GM2700@work-vm \
--to=dgilbert@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=elena.ufimtseva@oracle.com \
--cc=fam@euphon.net \
--cc=jag.raman@oracle.com \
--cc=john.g.johnson@oracle.com \
--cc=kanth.ghatraju@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=liran.alon@oracle.com \
--cc=marcandre.lureau@gmail.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=ross.lagerwall@citrix.com \
--cc=rth@twiddle.net \
--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).