From: "Michael S. Tsirkin" <mst@redhat.com>
To: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
"Damjan Marion (damarion)" <damarion@cisco.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] vhost-user: broken mem regions
Date: Wed, 25 Jun 2014 17:16:51 +0300 [thread overview]
Message-ID: <20140625141651.GB15234@redhat.com> (raw)
In-Reply-To: <CADDJ2=N2vxsy7tgvu0UWuzwBLZQ=KVh_KxACk67ZPjjJNRT71Q@mail.gmail.com>
On Wed, Jun 25, 2014 at 05:13:21PM +0300, Nikolay Nikolaev wrote:
>
>
>
> On Wed, Jun 25, 2014 at 5:06 PM, Damjan Marion (damarion) <damarion@cisco.com>
> wrote:
>
>
> On 25 Jun 2014, at 15:53, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> > On Wed, Jun 25, 2014 at 01:45:09PM +0000, Damjan Marion (damarion) wrote:
> >>
> >> Michael,
> >>
> >> there is another issue with commited vhost-user code.
> >
> > I'm answering just this once, but I have a policy against
> > answering off-list mail.
> > Pls send follow-ups to the list.
>
> ok, sorry, adding list...
>
> >
> >> If there is bigger mem allocation (i.e. 4G or 6G of RAM) then
> >> we have memory gap and then it happens that buffer pointer points to
> >> memory which is not mmaped. I already filled bug report:
> >>
> >> https://bugs.launchpad.net/qemu/+bug/1333688
> >
> > FYI I mostly ignore launchpad.
> > Because of the unfortunate association with Ubuntu, most bugs
> > there are distro-specific.
> >
> >> Bellow is my proposed change to the code. Two things:
> >> - it will require changes on the user side also
> >
> > why would it?
> > format seems unchanged, right?
>
> yes, but it will happen that multiple regions have same FD so call to mmap
> ()
> should look different, I’m still playing with this on user side...
>
> but then you shoudl somehow accumulate the sizes and send just a single fd,
> something along these lines.
Not going to work, these regions might not be contigious
(e.g. if a higher priority region hides RAM).
Just deal with the fact that same fd can appear
multiple times. I don't see why it's a big deal anyway.
>
> >
> >> - not sure if qemu_get_ram_fd() is the best way to get FD
> >
> > Paolo, what do you think?
> >
> >> Any comments or better idea how to fix this?
> >>
> >> Thanks,
> >>
> >> Damjan
> >>
> >> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> >> index 0df6a93..89fe5c7 100644
> >> --- a/hw/virtio/vhost-user.c
> >> +++ b/hw/virtio/vhost-user.c
> >> @@ -14,6 +14,7 @@
> >> #include "sysemu/kvm.h"
> >> #include "qemu/error-report.h"
> >> #include "qemu/sockets.h"
> >> +#include "exec/ram_addr.h"
> >>
> >> #include <fcntl.h>
> >> #include <unistd.h>
> >> @@ -183,10 +184,10 @@ static int vhost_user_call(struct vhost_dev *dev,
> unsigned long int request,
> >> {
> >> VhostUserMsg msg;
> >> VhostUserRequest msg_request;
> >> - RAMBlock *block = 0;
> >> struct vhost_vring_file *file = 0;
> >> int need_reply = 0;
> >> int fds[VHOST_MEMORY_MAX_NREGIONS];
> >> + int i, fd;
> >> size_t fd_num = 0;
> >>
> >> assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
> >> @@ -212,14 +213,14 @@ static int vhost_user_call(struct vhost_dev *dev,
> unsigned long int request,
> >> break;
> >>
> >> case VHOST_SET_MEM_TABLE:
> >> - QTAILQ_FOREACH(block, &ram_list.blocks, next)
> >> - {
> >> - if (block->fd > 0) {
> >> - msg.memory.regions[fd_num].userspace_addr =
> >> - (uintptr_t) block->host;
> >> - msg.memory.regions[fd_num].memory_size = block->length;
> >> - msg.memory.regions[fd_num].guest_phys_addr = block->
> offset;
> >> - fds[fd_num++] = block->fd;
> >> + for (i = 0; i < dev->mem->nregions; ++i) {
> >> + struct vhost_memory_region *reg = dev->mem->regions + i;
> >> + fd = qemu_get_ram_fd(reg->guest_phys_addr);
> >> + if (fd > 0) {
> >> + msg.memory.regions[fd_num].userspace_addr = reg->
> userspace_addr;
> >> + msg.memory.regions[fd_num].memory_size = reg->
> memory_size;
> >> + msg.memory.regions[fd_num].guest_phys_addr = reg->
> memory_size;
> >> + fds[fd_num++] = fd;
> >> }
> >> }
> >>
>
>
>
next prev parent reply other threads:[~2014-06-25 14:16 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <A459CE38-2929-47A2-8683-8D7EAF0325C0@cisco.com>
[not found] ` <20140625135207.GC14578@redhat.com>
2014-06-25 14:06 ` [Qemu-devel] vhost-user: broken mem regions Damjan Marion (damarion)
2014-06-25 14:13 ` Nikolay Nikolaev
2014-06-25 14:16 ` Michael S. Tsirkin [this message]
2014-06-25 14:20 ` Damjan Marion (damarion)
2014-06-25 14:27 ` Michael S. Tsirkin
2014-06-25 14:57 ` Damjan Marion (damarion)
2014-06-25 15:29 ` Michael S. Tsirkin
2014-06-25 15:46 ` Damjan Marion (damarion)
2014-06-25 15:50 ` Michael S. Tsirkin
2014-06-25 16:30 ` Damjan Marion (damarion)
2014-06-25 16:44 ` Paolo Bonzini
2014-06-25 16:56 ` Nikolay Nikolaev
2014-06-25 17:05 ` Paolo Bonzini
2014-06-25 18:11 ` Michael S. Tsirkin
2014-06-25 18:07 ` Michael S. Tsirkin
2014-06-25 18:13 ` Nikolay Nikolaev
2014-06-25 18:18 ` Michael S. Tsirkin
2014-06-25 21:37 ` Damjan Marion (damarion)
2014-06-26 10:03 ` Nikolay Nikolaev
2014-06-25 17:06 ` Nikolay Nikolaev
2014-06-25 18:00 ` Paolo Bonzini
2014-06-25 21:52 ` Damjan Marion (damarion)
2014-06-26 7:13 ` Michael S. Tsirkin
2014-06-26 7:44 ` Damjan Marion (damarion)
2014-06-26 7:56 ` Michael S. Tsirkin
2014-06-26 8:26 ` Damjan Marion (damarion)
[not found] ` <CADDJ2=M3=mxjHO3=gNq5xKseDyrJkaBVFLkb=SsFr0_d9UUBsQ@mail.gmail.com>
2014-06-25 14:16 ` Damjan Marion (damarion)
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=20140625141651.GB15234@redhat.com \
--to=mst@redhat.com \
--cc=damarion@cisco.com \
--cc=n.nikolaev@virtualopensystems.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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).