From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58380 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PSFXO-0006GW-LQ for qemu-devel@nongnu.org; Mon, 13 Dec 2010 16:02:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PSFXN-0002bS-FA for qemu-devel@nongnu.org; Mon, 13 Dec 2010 16:02:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PSFXN-0002bG-8Q for qemu-devel@nongnu.org; Mon, 13 Dec 2010 16:02:25 -0500 From: Alex Williamson Date: Mon, 13 Dec 2010 14:02:10 -0700 Message-ID: <20101213210119.28681.7329.stgit@s20.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [RESEND PATCH] exec: Implement qemu_ram_free_from_ptr() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, cam@cs.ualberta.ca, kvm@vger.kernel.org Required for regions mapped via qemu_ram_alloc_from_ptr(). VFIO and ivshmem will make use of this to remove mappings when devices are hot unplugged. Signed-off-by: Alex Williamson --- No comments on original patch. Obvious missing function. Cam has since requested the same function for ivshmem. 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 6d4a898..9b763d0 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -49,6 +49,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 a338495..eea7ea7 100644 --- a/exec.c +++ b/exec.c @@ -2875,6 +2875,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;