qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RESEND2 PATCH] exec: Implement qemu_ram_free_from_ptr()
@ 2011-05-03 18:48 Alex Williamson
  2011-06-03 21:05 ` Aurelien Jarno
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Williamson @ 2011-05-03 18:48 UTC (permalink / raw)
  To: qemu-devel, anthony; +Cc: 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.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

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(-)

diff --git a/cpu-common.h b/cpu-common.h
index 96c02ae..db98b6b 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -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);
diff --git a/exec.c b/exec.c
index a0678a4..1870ee7 100644
--- a/exec.c
+++ b/exec.c
@@ -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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [RESEND2 PATCH] exec: Implement qemu_ram_free_from_ptr()
  2011-05-03 18:48 [Qemu-devel] [RESEND2 PATCH] exec: Implement qemu_ram_free_from_ptr() Alex Williamson
@ 2011-06-03 21:05 ` Aurelien Jarno
  0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2011-06-03 21:05 UTC (permalink / raw)
  To: Alex Williamson; +Cc: qemu-devel

On Tue, May 03, 2011 at 12:48:09PM -0600, Alex Williamson wrote:
> 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>
> ---
> 
> 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.

> diff --git a/cpu-common.h b/cpu-common.h
> index 96c02ae..db98b6b 100644
> --- a/cpu-common.h
> +++ b/cpu-common.h
> @@ -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);
> diff --git a/exec.c b/exec.c
> index a0678a4..1870ee7 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -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;
> 
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-03 21:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-03 18:48 [Qemu-devel] [RESEND2 PATCH] exec: Implement qemu_ram_free_from_ptr() Alex Williamson
2011-06-03 21:05 ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).