From patchwork Fri Oct 29 16:56:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 69614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2606AB6F11 for ; Sat, 30 Oct 2010 04:24:42 +1100 (EST) Received: from localhost ([127.0.0.1]:52816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBsGB-0001HX-ER for incoming@patchwork.ozlabs.org; Fri, 29 Oct 2010 12:56:59 -0400 Received: from [140.186.70.92] (port=34479 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBsFR-0000DD-CA for qemu-devel@nongnu.org; Fri, 29 Oct 2010 12:56:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PBsFP-0005aI-5r for qemu-devel@nongnu.org; Fri, 29 Oct 2010 12:56:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10610) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PBsFO-0005aB-Vk for qemu-devel@nongnu.org; Fri, 29 Oct 2010 12:56:11 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9TGu8JP014125 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 29 Oct 2010 12:56:08 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9TGu6EP003701; Fri, 29 Oct 2010 12:56:07 -0400 From: Alex Williamson To: qemu-devel@nongnu.org, anthony@codemonkey.ws Date: Fri, 29 Oct 2010 10:56:06 -0600 Message-ID: <20101029165545.5070.50804.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: chrisw@redhat.com, alex.williamson@redhat.com, ddutile@redhat.com, kvm@vger.kernel.org, mst@redhat.com Subject: [Qemu-devel] [PATCH] exec: Implement qemu_ram_free_from_ptr() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Required for regions mapped via qemu_ram_alloc_from_ptr(). VFIO will make use of this to remove mappings when devices are hot unplugged. (Current callers of qemu_ram_alloc_from_ptr() should probably need this too) Signed-off-by: Alex Williamson --- cpu-common.h | 1 + exec.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/cpu-common.h b/cpu-common.h index a543b5d..8a3d1da 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -43,6 +43,7 @@ ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr); ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, ram_addr_t size, void *host); ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size); +void qemu_ram_free_from_ptr(ram_addr_t addr); void qemu_ram_free(ram_addr_t addr); /* This should only be used for ram local to a device. */ void *qemu_get_ram_ptr(ram_addr_t addr); diff --git a/exec.c b/exec.c index 631d8c5..2b3b9ba 100644 --- a/exec.c +++ b/exec.c @@ -2882,6 +2882,19 @@ ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size) return qemu_ram_alloc_from_ptr(dev, name, size, NULL); } +void qemu_ram_free_from_ptr(ram_addr_t addr) +{ + RAMBlock *block; + + QLIST_FOREACH(block, &ram_list.blocks, next) { + if (addr == block->offset) { + QLIST_REMOVE(block, next); + qemu_free(block); + return; + } + } +} + void qemu_ram_free(ram_addr_t addr) { RAMBlock *block;