From patchwork Tue Jul 8 14:06:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Nikolaev X-Patchwork-Id: 368342 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A8AD41400B9 for ; Thu, 10 Jul 2014 07:30:37 +1000 (EST) Received: from localhost ([::1]:55787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4W2p-00014y-OS for incoming@patchwork.ozlabs.org; Tue, 08 Jul 2014 10:06:55 -0400 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) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=FuUeTJvxsacG2hJLwkiZ2QQNc0y5IQXvrG9t09oCCKc=; b=kpa+hdy6VkPAxy4TfH09KXJ7PeZFom/FbGGY720/OD5im7zNiXBaJGtMz+oZD5U7AE N8dkrI52tY41y5dRHbsojbNIKPCiugUKKoKuFS9KQhXnD3+plLBshwlfu8JsNE2xj4pO zODOhSU8mjfwRY1zxVWnV51x+vDCoKLlvocX6uzkszn6uUAzPOz9huf4bn1y5mE5h9HQ sS8JCXHdIkLpViB9BAY+8F4t3YXGpJWf3mVNPp9RJ/a6ms6NnaL30J2BvrRzIT91YpWx QFz4/q+2i/oHZYY/krc8ggg1ASYXtc/8JWKgYj8N4pf9n6djwFo6PzPohfZnLTHczRDU 5cFw== X-Gm-Message-State: ALoCoQkH82Bbq7gJtPNekCO4D6pZfaUzT5uFwIoirc0yLXdt53b4BmGTOrSkNCuVrGEY9bdSBhGv X-Received: by 10.194.91.228 with SMTP id ch4mr40536837wjb.59.1404828375412; Tue, 08 Jul 2014 07:06:15 -0700 (PDT) Received: from [0.0.14.236] ([82.146.27.14]) by mx.google.com with ESMTPSA id mv3sm7414741wic.21.2014.07.08.07.06.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jul 2014 07:06:14 -0700 (PDT) From: Nikolay Nikolaev To: snabb-devel@googlegroups.com, qemu-devel@nongnu.org, mst@redhat.com 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> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.170 Cc: tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com Subject: [Qemu-devel] [PATCH 2/3] vhost-user: Fix VHOST_SET_MEM_TABLE processing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;