[PATCH v2 3/7] system/memory: Remove the resized callback

Akihiko Odaki <[email protected]>
Newsgroups org.kernel.vger.linux-edac,org.kernel.vger.kvm,org.nongnu.qemu-arm,org.nongnu.qemu-devel,org.nongnu.qemu-riscv
Message-ID <[email protected]>
The previous change moved fw_cfg updates out of the RAMBlock resize
callback, leaving the callback pointer unused. Remove the now-unused
callback plumbing.

Signed-off-by: Akihiko Odaki <[email protected]>
---
 include/system/memory.h   |  4 ----
 include/system/ramblock.h |  7 +------
 hw/core/loader.c          |  4 +---
 system/memory.c           |  7 ++-----
 system/physmem.c          | 24 ++++++------------------
 5 files changed, 10 insertions(+), 36 deletions(-)

diff --git a/include/system/memory.h b/include/system/memory.h
index e143c9c3f396..6a2d5f5f855f 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -1407,7 +1407,6 @@ bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
  *        must be unique within any device
  * @size: used size of the region.
  * @max_size: max size of the region.
- * @resized: callback to notify owner about used size change.
  * @errp: pointer to Error*, to store an error if it happens.
  *
  * Note that this function does not do anything to cause the data in the
@@ -1420,9 +1419,6 @@ bool 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),
                                        Error **errp);
 #ifdef CONFIG_POSIX
 
diff --git a/include/system/ramblock.h b/include/system/ramblock.h
index 4435f8d55fe7..1a95fba87f0c 100644
--- a/include/system/ramblock.h
+++ b/include/system/ramblock.h
@@ -30,7 +30,6 @@ 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);
     uint32_t flags;
     /* Protected by the BQL.  */
     char idstr[256];
@@ -244,7 +243,6 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
  *  @size: the size in bytes of the ram block
  *  @max_size: the maximum size of the block after resizing
  *  @mr: the memory region where the ram block is
- *  @resized: callback after calls to qemu_ram_resize
  *  @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM,
  *              RAM_NORESERVE, RAM_PROTECTED, RAM_NAMED_FILE, RAM_READONLY,
  *              RAM_READONLY_FD, RAM_GUEST_MEMFD
@@ -257,13 +255,11 @@ static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr,
  *  On success, return a pointer to the ram block.
  *  On failure, return NULL.
  */
-typedef void (*qemu_ram_resize_cb)(const char *, uint64_t length, void *host);
-
 RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
                                    uint32_t ram_flags, const char *mem_path,
                                    off_t offset, Error **errp);
 RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram_addr_t max_size,
-                                 qemu_ram_resize_cb resized, MemoryRegion *mr,
+                                 MemoryRegion *mr,
                                  uint32_t ram_flags, int fd, off_t offset,
                                  bool grow,
                                  Error **errp);
@@ -273,7 +269,6 @@ RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
 RAMBlock *qemu_ram_alloc(ram_addr_t size, uint32_t ram_flags, MemoryRegion *mr,
                          Error **errp);
 RAMBlock *qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t max_size,
-                                    qemu_ram_resize_cb resized,
                                     MemoryRegion *mr, Error **errp);
 void qemu_ram_free(RAMBlock *block);
 
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 14d56f52e4ec..147b872031eb 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -1068,9 +1068,7 @@ static void *rom_set_mr(Rom *rom, Object *owner, const char *name, bool ro)
 
     rom->mr = g_malloc(sizeof(*rom->mr));
     memory_region_init_resizeable_ram(rom->mr, owner, name,
-                                      rom->romsize, rom->romsize,
-                                      NULL,
-                                      &error_fatal);
+                                      rom->romsize, rom->romsize, &error_fatal);
     memory_region_set_readonly(rom->mr, ro);
     vmstate_register_ram_global(rom->mr);
 
diff --git a/system/memory.c b/system/memory.c
index 8436668c181d..6ec4b4ebb20e 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1610,16 +1610,13 @@ bool 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),
                                        Error **errp)
 {
     RAMBlock *rb;
 
     memory_region_init(mr, owner, name, size);
     mr->ram = true;
-    rb = qemu_ram_alloc_resizeable(size, max_size, resized, mr, errp);
+    rb = qemu_ram_alloc_resizeable(size, max_size, mr, errp);
     return memory_region_set_ram_block(mr, rb);
 }
 
@@ -1650,7 +1647,7 @@ bool memory_region_init_ram_from_fd(MemoryRegion *mr, Object *owner,
     memory_region_init(mr, owner, name, size);
     mr->ram = true;
     mr->readonly = !!(ram_flags & RAM_READONLY);
-    rb = qemu_ram_alloc_from_fd(size, size, NULL, mr, ram_flags, fd, offset,
+    rb = qemu_ram_alloc_from_fd(size, size, mr, ram_flags, fd, offset,
                                 false, errp);
     return memory_region_set_ram_block(mr, rb);
 }
diff --git a/system/physmem.c b/system/physmem.c
index 9e5b50c5b1ca..54fe820ce828 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -2032,9 +2032,6 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
          */
         if (unaligned_size != memory_region_size(block->mr)) {
             memory_region_set_size(block->mr, unaligned_size);
-            if (block->resized) {
-                block->resized(block->idstr, unaligned_size, block->host);
-            }
         }
         return 0;
     }
@@ -2065,9 +2062,6 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
     physical_memory_set_dirty_range(block->offset, block->used_length,
                                         DIRTY_CLIENTS_ALL);
     memory_region_set_size(block->mr, unaligned_size);
-    if (block->resized) {
-        block->resized(block->idstr, unaligned_size, block->host);
-    }
     return 0;
 }
 
@@ -2297,7 +2291,7 @@ out_free:
 
 #if defined(CONFIG_POSIX) && !defined(EMSCRIPTEN)
 RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram_addr_t max_size,
-                                 qemu_ram_resize_cb resized, MemoryRegion *mr,
+                                 MemoryRegion *mr,
                                  uint32_t ram_flags, int fd, off_t offset,
                                  bool grow,
                                  Error **errp)
@@ -2356,7 +2350,6 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram_addr_t max_size,
     new_block->mr = mr;
     new_block->used_length = size;
     new_block->max_length = max_size;
-    new_block->resized = resized;
     new_block->flags = ram_flags;
     new_block->guest_memfd = -1;
     new_block->host = file_ram_alloc(new_block, max_size, fd,
@@ -2413,7 +2406,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
         return NULL;
     }
 
-    block = qemu_ram_alloc_from_fd(size, size, NULL, mr, ram_flags, fd, offset,
+    block = qemu_ram_alloc_from_fd(size, size, mr, ram_flags, fd, offset,
                                    false, errp);
     if (!block) {
         if (created) {
@@ -2458,7 +2451,6 @@ static int qemu_ram_get_shared_fd(const char *name, bool *reused, Error **errp)
 
 static
 RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
-                                  qemu_ram_resize_cb resized,
                                   void *host, uint32_t ram_flags,
                                   MemoryRegion *mr, Error **errp)
 {
@@ -2504,7 +2496,7 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
              * region if necessary.  The extra space will be usable after a
              * guest reset.
              */
-            new_block = qemu_ram_alloc_from_fd(size, max_size, resized, mr,
+            new_block = qemu_ram_alloc_from_fd(size, max_size, mr,
                                                ram_flags, fd, 0, reused, NULL);
             if (new_block) {
                 trace_qemu_ram_alloc_shared(name, new_block->used_length,
@@ -2527,7 +2519,6 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
 
     new_block = g_malloc0(sizeof(*new_block));
     new_block->mr = mr;
-    new_block->resized = resized;
     new_block->used_length = size;
     new_block->max_length = max_size;
     new_block->fd = -1;
@@ -2547,8 +2538,7 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
 RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
                                    MemoryRegion *mr, Error **errp)
 {
-    return qemu_ram_alloc_internal(size, size, NULL, host, RAM_PREALLOC, mr,
-                                   errp);
+    return qemu_ram_alloc_internal(size, size, host, RAM_PREALLOC, mr, errp);
 }
 
 RAMBlock *qemu_ram_alloc(ram_addr_t size, uint32_t ram_flags,
@@ -2556,15 +2546,13 @@ RAMBlock *qemu_ram_alloc(ram_addr_t size, uint32_t ram_flags,
 {
     assert((ram_flags & ~(RAM_SHARED | RAM_NORESERVE | RAM_GUEST_MEMFD |
                           RAM_PRIVATE)) == 0);
-    return qemu_ram_alloc_internal(size, size, NULL, NULL, ram_flags, mr, errp);
+    return qemu_ram_alloc_internal(size, size, NULL, ram_flags, mr, errp);
 }
 
 RAMBlock *qemu_ram_alloc_resizeable(ram_addr_t size, ram_addr_t maxsz,
-                                    qemu_ram_resize_cb resized,
                                     MemoryRegion *mr, Error **errp)
 {
-    return qemu_ram_alloc_internal(size, maxsz, resized, NULL,
-                                   RAM_RESIZEABLE, mr, errp);
+    return qemu_ram_alloc_internal(size, maxsz, NULL, RAM_RESIZEABLE, mr, errp);
 }
 
 static void reclaim_ramblock(RAMBlock *block)

-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.