From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4W2J-0000va-SE for qemu-devel@nongnu.org; Tue, 08 Jul 2014 10:06:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4W2D-0003wR-45 for qemu-devel@nongnu.org; Tue, 08 Jul 2014 10:06:23 -0400 Received: from mail-we0-f170.google.com ([74.125.82.170]:33554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4W2C-0003wF-V3 for qemu-devel@nongnu.org; Tue, 08 Jul 2014 10:06:17 -0400 Received: by mail-we0-f170.google.com with SMTP id w61so6040146wes.15 for ; Tue, 08 Jul 2014 07:06:16 -0700 (PDT) From: Nikolay Nikolaev Date: Tue, 08 Jul 2014 17:06:08 +0300 Message-ID: <20140708140601.7314.97988.stgit@3820> In-Reply-To: <20140708140447.7314.87628.stgit@3820> References: <20140708140447.7314.87628.stgit@3820> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2/3] vhost-user: Fix VHOST_SET_MEM_TABLE processing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: snabb-devel@googlegroups.com, qemu-devel@nongnu.org, mst@redhat.com Cc: tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com 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 --- hw/virtio/vhost-user.c | 4 ++++ 1 file changed, 4 insertions(+) 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;