From 050a0ddf39cf5555ecf9b22a918b2a2b00bdbe34 Mon Sep 17 00:00:00 2001 From: Anthony PERARD Date: Thu, 16 Sep 2010 13:57:49 +0100 Subject: Introduce qemu_put_ram_ptr This function allows to unlock a ram_ptr give by qemu_get_ram_ptr. After a call to qemu_put_ram_ptr, the pointer may be unmap from QEMU when used with Xen. Signed-off-by: Anthony PERARD Acked-by: Alexander Graf Signed-off-by: Alexander Graf --- cpu-common.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cpu-common.h') diff --git a/cpu-common.h b/cpu-common.h index 6410cccda5..151c32c1f2 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -67,6 +67,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr); /* Same but slower, to use for migration, where the order of * RAMBlocks must not change. */ void *qemu_safe_ram_ptr(ram_addr_t addr); +void qemu_put_ram_ptr(void *addr); /* This should not be used by devices. */ int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr); ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr); -- cgit v1.2.3-55-g7522 From 1f2e98b62d62205de9d52e81aca78e78712af973 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Tue, 3 May 2011 12:48:09 -0600 Subject: exec: Implement qemu_ram_free_from_ptr() 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 Signed-off-by: Aurelien Jarno --- cpu-common.h | 1 + exec.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'cpu-common.h') diff --git a/cpu-common.h b/cpu-common.h index 151c32c1f2..9f5917224a 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -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 8529390cb2..6f339efb10 100644 --- 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; -- cgit v1.2.3-55-g7522