From patchwork Tue Nov 30 21:03:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cam Macdonell X-Patchwork-Id: 368701 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAULAljx014382 for ; Tue, 30 Nov 2010 21:10:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752953Ab0K3VKo (ORCPT ); Tue, 30 Nov 2010 16:10:44 -0500 Received: from smtp.srv.ualberta.ca ([129.128.5.19]:54403 "EHLO mail10.srv.ualberta.ca" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751785Ab0K3VKo (ORCPT ); Tue, 30 Nov 2010 16:10:44 -0500 Received: from localhost.localdomain (st-brides.cs.ualberta.ca [129.128.23.21]) (authenticated bits=0) by mail10.srv.ualberta.ca (8.14.3/8.13.8) with ESMTP id oAUL41tF025644 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 30 Nov 2010 14:04:14 -0700 (MST) From: Cam Macdonell To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Cam Macdonell Subject: [PATCH 1/2] add qemu_ram_free_from_ptr Date: Tue, 30 Nov 2010 14:03:58 -0700 Message-Id: <1291151039-10966-2-git-send-email-cam@cs.ualberta.ca> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1291151039-10966-1-git-send-email-cam@cs.ualberta.ca> References: <1291151039-10966-1-git-send-email-cam@cs.ualberta.ca> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 30 Nov 2010 21:10:48 +0000 (UTC) diff --git a/cpu-common.h b/cpu-common.h index a543b5d..3f802e1 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -44,6 +44,7 @@ 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(ram_addr_t addr); +void qemu_ram_free_from_ptr(ram_addr_t addr); /* This should only be used for ram local to a device. */ void *qemu_get_ram_ptr(ram_addr_t addr); /* This should not be used by devices. */ diff --git a/exec.c b/exec.c index db9ff55..1f5c8f8 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;