@@ -2193,7 +2193,8 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
memory_region_set_size(block->mr, newsize);
if (block->resized) {
- block->resized(block->idstr, newsize, block->host);
+ block->resized(memory_region_owner(block->mr), block->idstr, newsize,
+ block->host);
}
/*
@@ -2476,9 +2477,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
static
RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
- void (*resized)(const char*,
- uint64_t length,
- void *host),
+ memory_region_resized_fn resized,
void *host, bool resizeable, bool share,
MemoryRegion *mr, Error **errp)
{
@@ -2529,10 +2528,8 @@ RAMBlock *qemu_ram_alloc(ram_addr_t size, bool share,
}
RAMBlock *qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t maxsz,
- void (*resized)(const char*,
- uint64_t length,
- void *host),
- MemoryRegion *mr, Error **errp)
+ memory_region_resized_fn resized,
+ MemoryRegion *mr, Error **errp)
{
return qemu_ram_alloc_internal(size, maxsz, resized, NULL, true,
false, mr, errp);
@@ -912,7 +912,8 @@ static void rom_insert(Rom *rom)
QTAILQ_INSERT_TAIL(&roms, rom, next);
}
-static void fw_cfg_resized(const char *id, uint64_t length, void *host)
+static void fw_cfg_resized(Object *owner, const char *id, uint64_t length,
+ void *host)
{
if (fw_cfg) {
fw_cfg_modify_file(fw_cfg, id + strlen("/rom@"), host, length);
@@ -846,6 +846,9 @@ void memory_region_init_ram_shared_nomigrate(MemoryRegion *mr,
bool share,
Error **errp);
+typedef void (*memory_region_resized_fn)(Object *owner, const char*id,
+ uint64_t length, void *host);
+
/**
* memory_region_init_resizeable_ram: Initialize memory region with resizeable
* RAM. Accesses into the region will
@@ -870,9 +873,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
const char *name,
uint64_t size,
uint64_t max_size,
- void (*resized)(const char*,
- uint64_t length,
- void *host),
+ memory_region_resized_fn resized,
Error **errp);
#ifdef CONFIG_POSIX
@@ -128,9 +128,7 @@ RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
RAMBlock *qemu_ram_alloc(ram_addr_t size, bool share, MemoryRegion *mr,
Error **errp);
RAMBlock *qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t max_size,
- void (*resized)(const char*,
- uint64_t length,
- void *host),
+ memory_region_resized_fn resized,
MemoryRegion *mr, Error **errp);
void qemu_ram_free(RAMBlock *block);
@@ -21,6 +21,7 @@
#ifndef CONFIG_USER_ONLY
#include "cpu-common.h"
+#include "exec/memory.h"
struct RAMBlock {
struct rcu_head rcu;
@@ -30,7 +31,7 @@ struct RAMBlock {
ram_addr_t offset;
ram_addr_t used_length;
ram_addr_t max_length;
- void (*resized)(const char*, uint64_t length, void *host);
+ memory_region_resized_fn resized;
uint32_t flags;
/* Protected by iothread lock. */
char idstr[256];
@@ -1535,9 +1535,7 @@ void memory_region_init_resizeable_ram(MemoryRegion *mr,
const char *name,
uint64_t size,
uint64_t max_size,
- void (*resized)(const char*,
- uint64_t length,
- void *host),
+ memory_region_resized_fn resized,
Error **errp)
{
Error *err = NULL;
Let's pass the owner in the callback. While touching it, introduce a typedef for the callback. Signed-off-by: David Hildenbrand <david@redhat.com> --- exec.c | 13 +++++-------- hw/core/loader.c | 3 ++- include/exec/memory.h | 7 ++++--- include/exec/ram_addr.h | 4 +--- include/exec/ramblock.h | 3 ++- memory.c | 4 +--- 6 files changed, 15 insertions(+), 19 deletions(-)