]> git.proxmox.com Git - qemu.git/commitdiff
exec: Implement qemu_ram_free_from_ptr()
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 3 May 2011 18:48:09 +0000 (12:48 -0600)
committerAurelien Jarno <aurelien@aurel32.net>
Fri, 3 Jun 2011 20:59:15 +0000 (22:59 +0200)
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 <alex.williamson@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
cpu-common.h
exec.c

index 151c32c1f2693ad98b28cfa65cd915de4d6fb16e..9f5917224acc1e0f0c5d21526c8f9e9eefd890e7 100644 (file)
@@ -61,6 +61,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);
 void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
 /* 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 8529390cb2d230df4ae8a4710ba43971644d0ee0..6f339efb1009c20fe4e221b58302b2c3e3385701 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -2952,6 +2952,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;