From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Xu" <peterx@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH v4 03/13] system/memory: constify section arguments
Date: Mon, 04 May 2026 16:30:09 +0400 [thread overview]
Message-ID: <20260504-rdm5-v4-3-bdf61e57c1e1@redhat.com> (raw)
In-Reply-To: <20260504-rdm5-v4-0-bdf61e57c1e1@redhat.com>
The sections shouldn't be modified.
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/hw/vfio/vfio-container.h | 2 +-
include/hw/vfio/vfio-cpr.h | 2 +-
include/system/ram-discard-manager.h | 14 +++++++-------
hw/vfio/cpr-legacy.c | 4 ++--
hw/vfio/listener.c | 10 +++++-----
hw/virtio/virtio-mem.c | 10 +++++-----
migration/ram.c | 6 +++---
system/memory_mapping.c | 4 ++--
system/ram-block-attributes.c | 8 ++++----
system/ram-discard-manager.c | 10 +++++-----
10 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/include/hw/vfio/vfio-container.h b/include/hw/vfio/vfio-container.h
index a7d5c5ed679..b2e7f4312c3 100644
--- a/include/hw/vfio/vfio-container.h
+++ b/include/hw/vfio/vfio-container.h
@@ -277,7 +277,7 @@ struct VFIOIOMMUClass {
};
VFIORamDiscardListener *vfio_find_ram_discard_listener(
- VFIOContainer *bcontainer, MemoryRegionSection *section);
+ VFIOContainer *bcontainer, const MemoryRegionSection *section);
void vfio_container_region_add(VFIOContainer *bcontainer,
MemoryRegionSection *section, bool cpr_remap);
diff --git a/include/hw/vfio/vfio-cpr.h b/include/hw/vfio/vfio-cpr.h
index 4606da500a7..ecabe0c747d 100644
--- a/include/hw/vfio/vfio-cpr.h
+++ b/include/hw/vfio/vfio-cpr.h
@@ -69,7 +69,7 @@ void vfio_cpr_giommu_remap(struct VFIOContainer *bcontainer,
MemoryRegionSection *section);
bool vfio_cpr_ram_discard_replay_populated(
- struct VFIOContainer *bcontainer, MemoryRegionSection *section);
+ struct VFIOContainer *bcontainer, const MemoryRegionSection *section);
void vfio_cpr_save_vector_fd(struct VFIOPCIDevice *vdev, const char *name,
int nr, int fd);
diff --git a/include/system/ram-discard-manager.h b/include/system/ram-discard-manager.h
index da55658169f..b188e09a30f 100644
--- a/include/system/ram-discard-manager.h
+++ b/include/system/ram-discard-manager.h
@@ -26,9 +26,9 @@ DECLARE_OBJ_CHECKERS(RamDiscardSource, RamDiscardSourceClass,
typedef struct RamDiscardListener RamDiscardListener;
typedef int (*NotifyRamPopulate)(RamDiscardListener *rdl,
- MemoryRegionSection *section);
+ const MemoryRegionSection *section);
typedef void (*NotifyRamDiscard)(RamDiscardListener *rdl,
- MemoryRegionSection *section);
+ const MemoryRegionSection *section);
struct RamDiscardListener {
/*
@@ -86,7 +86,7 @@ static inline void ram_discard_listener_init(RamDiscardListener *rdl,
*
* Returns 0 on success, or a negative error if failed.
*/
-typedef int (*ReplayRamDiscardState)(MemoryRegionSection *section,
+typedef int (*ReplayRamDiscardState)(const MemoryRegionSection *section,
void *opaque);
/*
@@ -151,7 +151,7 @@ struct RamDiscardSourceClass {
* Returns 0 on success, or a negative error if any notification failed.
*/
int (*replay_populated)(const RamDiscardSource *rds,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn, void *opaque);
/**
@@ -168,7 +168,7 @@ struct RamDiscardSourceClass {
* Returns 0 on success, or a negative error if any notification failed.
*/
int (*replay_discarded)(const RamDiscardSource *rds,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn, void *opaque);
};
@@ -237,7 +237,7 @@ bool ram_discard_manager_is_populated(const RamDiscardManager *rdm,
* Returns 0 on success, or a negative error if any notification failed.
*/
int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn,
void *opaque);
@@ -255,7 +255,7 @@ int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
* Returns 0 on success, or a negative error if any notification failed.
*/
int ram_discard_manager_replay_discarded(const RamDiscardManager *rdm,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn,
void *opaque);
diff --git a/hw/vfio/cpr-legacy.c b/hw/vfio/cpr-legacy.c
index 033a546c301..cca7dd08dfc 100644
--- a/hw/vfio/cpr-legacy.c
+++ b/hw/vfio/cpr-legacy.c
@@ -226,7 +226,7 @@ void vfio_cpr_giommu_remap(VFIOContainer *bcontainer,
memory_region_iommu_replay(giommu->iommu_mr, &giommu->n);
}
-static int vfio_cpr_rdm_remap(MemoryRegionSection *section, void *opaque)
+static int vfio_cpr_rdm_remap(const MemoryRegionSection *section, void *opaque)
{
RamDiscardListener *rdl = opaque;
@@ -242,7 +242,7 @@ static int vfio_cpr_rdm_remap(MemoryRegionSection *section, void *opaque)
* directly, which calls vfio_legacy_cpr_dma_map.
*/
bool vfio_cpr_ram_discard_replay_populated(VFIOContainer *bcontainer,
- MemoryRegionSection *section)
+ const MemoryRegionSection *section)
{
RamDiscardManager *rdm = memory_region_get_ram_discard_manager(section->mr);
VFIORamDiscardListener *vrdl =
diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c
index 31c3113f8fb..e784868f62a 100644
--- a/hw/vfio/listener.c
+++ b/hw/vfio/listener.c
@@ -201,7 +201,7 @@ out:
}
static void vfio_ram_discard_notify_discard(RamDiscardListener *rdl,
- MemoryRegionSection *section)
+ const MemoryRegionSection *section)
{
VFIORamDiscardListener *vrdl = container_of(rdl, VFIORamDiscardListener,
listener);
@@ -219,7 +219,7 @@ static void vfio_ram_discard_notify_discard(RamDiscardListener *rdl,
}
static int vfio_ram_discard_notify_populate(RamDiscardListener *rdl,
- MemoryRegionSection *section)
+ const MemoryRegionSection *section)
{
VFIORamDiscardListener *vrdl = container_of(rdl, VFIORamDiscardListener,
listener);
@@ -461,7 +461,7 @@ static void vfio_device_error_append(VFIODevice *vbasedev, Error **errp)
}
VFIORamDiscardListener *vfio_find_ram_discard_listener(
- VFIOContainer *bcontainer, MemoryRegionSection *section)
+ VFIOContainer *bcontainer, const MemoryRegionSection *section)
{
VFIORamDiscardListener *vrdl = NULL;
@@ -1143,8 +1143,8 @@ out:
}
}
-static int vfio_ram_discard_query_dirty_bitmap(MemoryRegionSection *section,
- void *opaque)
+static int vfio_ram_discard_query_dirty_bitmap(const MemoryRegionSection *section,
+ void *opaque)
{
const hwaddr size = int128_get64(section->size);
const hwaddr iova = section->offset_within_address_space;
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index be149ee9441..ec165503205 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -262,7 +262,7 @@ static int virtio_mem_for_each_plugged_range(VirtIOMEM *vmem, void *arg,
typedef int (*virtio_mem_section_cb)(MemoryRegionSection *s, void *arg);
static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
- MemoryRegionSection *s,
+ const MemoryRegionSection *s,
void *arg,
virtio_mem_section_cb cb)
{
@@ -294,7 +294,7 @@ static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
}
static int virtio_mem_for_each_unplugged_section(const VirtIOMEM *vmem,
- MemoryRegionSection *s,
+ const MemoryRegionSection *s,
void *arg,
virtio_mem_section_cb cb)
{
@@ -1680,7 +1680,7 @@ static int virtio_mem_rds_replay_cb(MemoryRegionSection *s, void *arg)
}
static int virtio_mem_rds_replay_populated(const RamDiscardSource *rds,
- MemoryRegionSection *s,
+ const MemoryRegionSection *s,
ReplayRamDiscardState replay_fn,
void *opaque)
{
@@ -1692,11 +1692,11 @@ static int virtio_mem_rds_replay_populated(const RamDiscardSource *rds,
g_assert(s->mr == &vmem->memdev->mr);
return virtio_mem_for_each_plugged_section(vmem, s, &data,
- virtio_mem_rds_replay_cb);
+ virtio_mem_rds_replay_cb);
}
static int virtio_mem_rds_replay_discarded(const RamDiscardSource *rds,
- MemoryRegionSection *s,
+ const MemoryRegionSection *s,
ReplayRamDiscardState replay_fn,
void *opaque)
{
diff --git a/migration/ram.c b/migration/ram.c
index 2046f16caa2..3f69b8733eb 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -860,7 +860,7 @@ static inline bool migration_bitmap_clear_dirty(RAMState *rs,
return ret;
}
-static int dirty_bitmap_clear_section(MemoryRegionSection *section,
+static int dirty_bitmap_clear_section(const MemoryRegionSection *section,
void *opaque)
{
const hwaddr offset = section->offset_within_region;
@@ -1595,7 +1595,7 @@ static inline void populate_read_range(RAMBlock *block, ram_addr_t offset,
}
}
-static inline int populate_read_section(MemoryRegionSection *section,
+static inline int populate_read_section(const MemoryRegionSection *section,
void *opaque)
{
const hwaddr size = int128_get64(section->size);
@@ -1670,7 +1670,7 @@ void ram_write_tracking_prepare(void)
}
}
-static inline int uffd_protect_section(MemoryRegionSection *section,
+static inline int uffd_protect_section(const MemoryRegionSection *section,
void *opaque)
{
const hwaddr size = int128_get64(section->size);
diff --git a/system/memory_mapping.c b/system/memory_mapping.c
index da708a08ab7..cacef504f68 100644
--- a/system/memory_mapping.c
+++ b/system/memory_mapping.c
@@ -196,7 +196,7 @@ typedef struct GuestPhysListener {
} GuestPhysListener;
static void guest_phys_block_add_section(GuestPhysListener *g,
- MemoryRegionSection *section)
+ const MemoryRegionSection *section)
{
const hwaddr target_start = section->offset_within_address_space;
const hwaddr target_end = target_start + int128_get64(section->size);
@@ -248,7 +248,7 @@ static void guest_phys_block_add_section(GuestPhysListener *g,
#endif
}
-static int guest_phys_ram_populate_cb(MemoryRegionSection *section,
+static int guest_phys_ram_populate_cb(const MemoryRegionSection *section,
void *opaque)
{
GuestPhysListener *g = opaque;
diff --git a/system/ram-block-attributes.c b/system/ram-block-attributes.c
index a72924eea7d..79c7e97d9a1 100644
--- a/system/ram-block-attributes.c
+++ b/system/ram-block-attributes.c
@@ -37,7 +37,7 @@ typedef int (*ram_block_attributes_section_cb)(MemoryRegionSection *s,
static int
ram_block_attributes_for_each_populated_section(const RamBlockAttributes *attr,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
void *arg,
ram_block_attributes_section_cb cb)
{
@@ -78,7 +78,7 @@ ram_block_attributes_for_each_populated_section(const RamBlockAttributes *attr,
static int
ram_block_attributes_for_each_discarded_section(const RamBlockAttributes *attr,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
void *arg,
ram_block_attributes_section_cb cb)
{
@@ -161,7 +161,7 @@ ram_block_attributes_rds_is_populated(const RamDiscardSource *rds,
static int
ram_block_attributes_rds_replay_populated(const RamDiscardSource *rds,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn,
void *opaque)
{
@@ -175,7 +175,7 @@ ram_block_attributes_rds_replay_populated(const RamDiscardSource *rds,
static int
ram_block_attributes_rds_replay_discarded(const RamDiscardSource *rds,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn,
void *opaque)
{
diff --git a/system/ram-discard-manager.c b/system/ram-discard-manager.c
index 3d8c85617d7..1c9ff7fda58 100644
--- a/system/ram-discard-manager.c
+++ b/system/ram-discard-manager.c
@@ -28,7 +28,7 @@ static bool ram_discard_source_is_populated(const RamDiscardSource *rds,
}
static int ram_discard_source_replay_populated(const RamDiscardSource *rds,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn,
void *opaque)
{
@@ -39,7 +39,7 @@ static int ram_discard_source_replay_populated(const RamDiscardSource *rds,
}
static int ram_discard_source_replay_discarded(const RamDiscardSource *rds,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn,
void *opaque)
{
@@ -74,7 +74,7 @@ bool ram_discard_manager_is_populated(const RamDiscardManager *rdm,
}
int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn,
void *opaque)
{
@@ -83,7 +83,7 @@ int ram_discard_manager_replay_populated(const RamDiscardManager *rdm,
}
int ram_discard_manager_replay_discarded(const RamDiscardManager *rdm,
- MemoryRegionSection *section,
+ const MemoryRegionSection *section,
ReplayRamDiscardState replay_fn,
void *opaque)
{
@@ -164,7 +164,7 @@ void ram_discard_manager_notify_discard_all(RamDiscardManager *rdm)
}
}
-static int rdm_populate_cb(MemoryRegionSection *section, void *opaque)
+static int rdm_populate_cb(const MemoryRegionSection *section, void *opaque)
{
RamDiscardListener *rdl = opaque;
--
2.54.0
next prev parent reply other threads:[~2026-05-04 12:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 12:30 [PATCH v4 00/13] Make RamDiscardManager work with multiple sources & virtio-mem Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 01/13] system/memory: split RamDiscardManager into source and manager Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 02/13] system/memory: move RamDiscardManager to separate compilation unit Marc-André Lureau
2026-05-04 12:30 ` Marc-André Lureau [this message]
2026-05-04 12:30 ` [PATCH v4 04/13] system/ram-discard-manager: implement replay via is_populated iteration Marc-André Lureau
2026-05-13 20:40 ` Peter Xu
2026-05-04 12:30 ` [PATCH v4 05/13] virtio-mem: remove replay_populated/replay_discarded implementation Marc-André Lureau
2026-05-13 20:40 ` Peter Xu
2026-05-04 12:30 ` [PATCH v4 06/13] system/ram-discard-manager: drop replay from source interface Marc-André Lureau
2026-05-13 20:40 ` Peter Xu
2026-05-04 12:30 ` [PATCH v4 07/13] system/memory: implement RamDiscardManager multi-source aggregation Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 08/13] system/physmem: destroy ram block attributes before RCU-deferred reclaim Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 09/13] system/memory: add RamDiscardManager reference counting and cleanup Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 10/13] tests: add unit tests for RamDiscardManager multi-source aggregation Marc-André Lureau
2026-05-04 12:30 ` [PATCH v4 11/13] system/physmem: make ram_block_discard_range() handle guest_memfd Marc-André Lureau
2026-05-13 20:37 ` Peter Xu
2026-05-04 12:30 ` [PATCH v4 12/13] monitor: add 'info ramblock-attributes' command Marc-André Lureau
2026-05-13 20:39 ` Peter Xu
2026-05-04 12:30 ` [PATCH v4 13/13] RFC: hw/virtio: start virtio-mem guest_memfd regions as shared Marc-André Lureau
2026-05-13 20:47 ` Peter Xu
2026-05-14 7:32 ` Chenyi Qiang
2026-05-13 20:53 ` [PATCH v4 00/13] Make RamDiscardManager work with multiple sources & virtio-mem Peter Xu
2026-05-14 5:15 ` Chenyi Qiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260504-rdm5-v4-3-bdf61e57c1e1@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=clg@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.