Message ID | 20140708140601.7314.97988.stgit@3820 |
---|---|
State | New |
Headers | show |
Il 08/07/2014 16:06, Nikolay Nikolaev ha scritto: > @@ -216,6 +216,10 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, > case VHOST_SET_MEM_TABLE: > for (i = 0; i < dev->mem->nregions; ++i) { > struct vhost_memory_region *reg = dev->mem->regions + i; > + if (!qemu_is_ram_block(reg->guest_phys_addr)) { > + /* this is non-RAM region - skip it */ > + continue; > + } > fd = qemu_get_ram_fd(reg->guest_phys_addr); > if (fd > 0) { > msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr; This is wrong. qemu_get_ram_fd doesn't accept a guest physical address. ram_addr_t are opaque values that are assigned in qemu_ram_alloc. In fact, RAM regions are filtered by static bool vhost_section(MemoryRegionSection *section) { return memory_region_is_ram(section->mr); } You can find the ram_addr_t corresponding to the userspace_addr using qemu_ram_addr_from_host, and then call qemu_get_ram_fd on it. Paolo
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 38e5806..876b080 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -216,6 +216,10 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, case VHOST_SET_MEM_TABLE: for (i = 0; i < dev->mem->nregions; ++i) { struct vhost_memory_region *reg = dev->mem->regions + i; + if (!qemu_is_ram_block(reg->guest_phys_addr)) { + /* this is non-RAM region - skip it */ + continue; + } fd = qemu_get_ram_fd(reg->guest_phys_addr); if (fd > 0) { msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr;
For each memory region we use qemu_get_ram_fd to get the RAMBlock associated file descriptor. It uses qemu_get_ram_block to find the proper structure. The latter aborts with "Bad ram offset" when the address is not found. We'll use the new qemu_is_ram_block to indentify non-RAM regions and avoid qemu_get_ram_fd call on them. Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com> --- hw/virtio/vhost-user.c | 4 ++++ 1 file changed, 4 insertions(+)