Skip to contentSkip to conversation

exec: Implement qemu_ram_free_from_ptr()

PATCH Applied Alex Williamson 2 participants 2 messages May 3, 2011 – Jun 3, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

Trying to clean out my patch queuer;, I've proposed this twice, Cam has proposed this once, it's an obvious missing interface. Please apply.

 cpu-common.h |    1 +
 exec.c       |   13 +++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
cpu-common.h +1 -0
index 96c02ae..db98b6b 100644
@@ -50,6 +50,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);
exec.c +13 -0
index a0678a4..1870ee7 100644
@@ -2954,6 +2954,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;
#1 lore raw
Quoted 7 lines · Alex Williamson

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.

---

Quoted 7 lines

Trying to clean out my patch queuer;, I've proposed this twice, Cam has proposed this once, it's an obvious missing interface. Please apply.

 cpu-common.h |    1 +
 exec.c       |   13 +++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

Thanks, applied.

Quoted 39 lines
cpu-common.h +1 -0
index 96c02ae..db98b6b 100644
@@ -50,6 +50,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);
exec.c +13 -0
index a0678a4..1870ee7 100644
@@ -2954,6 +2954,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;
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net