memory: Remove memory_region_init_ram_nomigrate()
Convert the last remaining use outside of memory.c in vga to use memory_region_init_ram_flags_nomigrate() instead and inline and remove the memory_region_init_ram_nomigrate() variant. This leaves memory_region_init_ram_flags_nomigrate() as the only nomigrate variant that is still needed at a few places. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Link: https://lore.kernel.org/r/d913d0694b792bc3aed3fbb432e63d00c556de39.1772924151.git.balaton@eik.bme.hu Signed-off-by: Peter Xu <peterx@redhat.com>
BALATON Zoltan committed
Mar 8, 2026 at 00:06 UTC
787495878f859bc9bfd683b385e91155f7ac14c2
5 files changed
+7
-60
docs/devel/memory.rst
+3
-5
@@ -110,11 +110,9 @@ migrated:
110
111
For most devices and boards this is the correct thing. If you
112
have a special case where you need to manage the migration of
113
-the backing memory yourself, you can call the functions:
114
-
115
-- memory_region_init_ram_nomigrate()
116
-
117
-which only initialize the MemoryRegion and leave handling
113
+the backing memory yourself, you can call the function
114
+memory_region_init_ram_flags_nomigrate()
115
+which only initializes the MemoryRegion and leaves handling
116
migration to the caller.
117
118
The functions:
hw/display/vga.c
+2
-2
@@ -2235,8 +2235,8 @@ bool vga_common_init(VGACommonState *s, Object *obj, Error **errp)
2235
return false;
2236
}
2237
2238
- memory_region_init_ram_nomigrate(&s->vram, obj, "vga.vram", s->vram_size,
2239
- &local_err);
2238
+ memory_region_init_ram_flags_nomigrate(&s->vram, obj, "vga.vram",
2239
+ s->vram_size, 0, &local_err);
2240
if (local_err) {
2241
error_propagate(errp, local_err);
2242
return false;
include/system/memory.h
-23
@@ -1374,29 +1374,6 @@ void memory_region_init_io(MemoryRegion *mr,
1374
const char *name,
1375
uint64_t size);
1376
1377
-/**
1378
- * memory_region_init_ram_nomigrate: Initialize RAM memory region. Accesses
1379
- * into the region will modify memory
1380
- * directly.
1381
- *
1382
- * @mr: the #MemoryRegion to be initialized.
1383
- * @owner: the object that tracks the region's reference count
1384
- * @name: Region name, becomes part of RAMBlock name used in migration stream
1385
- * must be unique within any device
1386
- * @size: size of the region.
1387
- * @errp: pointer to Error*, to store an error if it happens.
1388
- *
1389
- * Note that this function does not do anything to cause the data in the
1390
- * RAM memory region to be migrated; that is the responsibility of the caller.
1391
- *
1392
- * Return: true on success, else false setting @errp with error.
1393
- */
1394
-bool memory_region_init_ram_nomigrate(MemoryRegion *mr,
1395
- Object *owner,
1396
- const char *name,
1397
- uint64_t size,
1398
- Error **errp);
1399
-
1377
/**
1378
* memory_region_init_ram_flags_nomigrate: Initialize RAM memory region.
1379
* Accesses into the region will
scripts/coccinelle/memory-region-housekeeping.cocci
-19
@@ -26,15 +26,9 @@ symbol true;
26
expression E1, E2, E3, E4, E5;
27
position p;
28
@@
29
-(
29
memory_region_init_ram@p(E1, E2, E3, E4, E5);
30
...
31
memory_region_set_readonly(E1, true);
33
-|
34
- memory_region_init_ram_nomigrate@p(E1, E2, E3, E4, E5);
35
- ...
36
- memory_region_set_readonly(E1, true);
37
-)
32
@script:python@
33
p << possible_memory_region_init_rom.p;
34
@@
@@ -52,23 +46,10 @@ expression ALIAS, E5, E6, E7, E8;
46
- memory_region_set_readonly(ALIAS, true);
47
48
55
-// Replace by-hand memory_region_init_ram_nomigrate/vmstate_register_ram
56
-// code sequences with use of the new memory_region_init_ram function.
57
-// Similarly for the _rom and _rom_device functions.
49
// We don't try to replace sequences with a non-NULL owner, because
50
// there are none in the tree that can be automatically converted
51
// (and only a handful that can be manually converted).
52
@@
62
-expression MR;
63
-expression NAME;
64
-expression SIZE;
65
-expression ERRP;
66
-@@
67
--memory_region_init_ram_nomigrate(MR, NULL, NAME, SIZE, ERRP);
68
-+memory_region_init_ram(MR, NULL, NAME, SIZE, ERRP);
69
- ...
70
--vmstate_register_ram_global(MR);
71
-@@
53
typedef DeviceState;
54
identifier device_fn, dev, obj;
55
expression E1, E2, E3, E4, E5;
system/memory.c
+2
-11
@@ -1579,16 +1579,6 @@ void memory_region_init_io(MemoryRegion *mr,
1579
memory_region_set_ops(mr, ops, opaque);
1580
}
1581
1582
-bool memory_region_init_ram_nomigrate(MemoryRegion *mr,
1583
- Object *owner,
1584
- const char *name,
1585
- uint64_t size,
1586
- Error **errp)
1587
-{
1588
- return memory_region_init_ram_flags_nomigrate(mr, owner, name,
1589
- size, 0, errp);
1590
-}
1591
-
1582
bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
1583
Object *owner,
1584
const char *name,
@@ -3695,7 +3685,8 @@ bool memory_region_init_ram(MemoryRegion *mr,
3685
{
3686
DeviceState *owner_dev;
3687
3698
- if (!memory_region_init_ram_nomigrate(mr, owner, name, size, errp)) {
3688
+ if (!memory_region_init_ram_flags_nomigrate(mr, owner, name,
3689
+ size, 0, errp)) {
3690
return false;
3691
}
3692
/* This will assert if owner is neither NULL nor a DeviceState.