mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
system/ramblock: Constify various RAMBlock arguments
Mark the RAMBlock structure const when is only accessed read-only. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/20260309183536.88976-2-philmd@linaro.org Signed-off-by: Peter Xu <peterx@redhat.com>
This commit is contained in:
committed by
Peter Xu
parent
554671c1ec
commit
f016021ff5
@@ -154,26 +154,26 @@ RAMBlock *qemu_ram_block_by_name(const char *name);
|
||||
*/
|
||||
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
|
||||
ram_addr_t *offset);
|
||||
ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
|
||||
ram_addr_t qemu_ram_block_host_offset(const RAMBlock *rb, void *host);
|
||||
void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
|
||||
void qemu_ram_unset_idstr(RAMBlock *block);
|
||||
const char *qemu_ram_get_idstr(RAMBlock *rb);
|
||||
void *qemu_ram_get_host_addr(RAMBlock *rb);
|
||||
ram_addr_t qemu_ram_get_offset(RAMBlock *rb);
|
||||
ram_addr_t qemu_ram_get_fd_offset(RAMBlock *rb);
|
||||
ram_addr_t qemu_ram_get_used_length(RAMBlock *rb);
|
||||
ram_addr_t qemu_ram_get_max_length(RAMBlock *rb);
|
||||
bool qemu_ram_is_shared(RAMBlock *rb);
|
||||
bool qemu_ram_is_noreserve(RAMBlock *rb);
|
||||
bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
|
||||
const char *qemu_ram_get_idstr(const RAMBlock *rb);
|
||||
void *qemu_ram_get_host_addr(const RAMBlock *rb);
|
||||
ram_addr_t qemu_ram_get_offset(const RAMBlock *rb);
|
||||
ram_addr_t qemu_ram_get_fd_offset(const RAMBlock *rb);
|
||||
ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb);
|
||||
ram_addr_t qemu_ram_get_max_length(const RAMBlock *rb);
|
||||
bool qemu_ram_is_shared(const RAMBlock *rb);
|
||||
bool qemu_ram_is_noreserve(const RAMBlock *rb);
|
||||
bool qemu_ram_is_uf_zeroable(const RAMBlock *rb);
|
||||
void qemu_ram_set_uf_zeroable(RAMBlock *rb);
|
||||
bool qemu_ram_is_migratable(RAMBlock *rb);
|
||||
bool qemu_ram_is_migratable(const RAMBlock *rb);
|
||||
void qemu_ram_set_migratable(RAMBlock *rb);
|
||||
void qemu_ram_unset_migratable(RAMBlock *rb);
|
||||
bool qemu_ram_is_named_file(RAMBlock *rb);
|
||||
int qemu_ram_get_fd(RAMBlock *rb);
|
||||
bool qemu_ram_is_named_file(const RAMBlock *rb);
|
||||
int qemu_ram_get_fd(const RAMBlock *rb);
|
||||
|
||||
size_t qemu_ram_pagesize(RAMBlock *block);
|
||||
size_t qemu_ram_pagesize(const RAMBlock *block);
|
||||
size_t qemu_ram_pagesize_largest(void);
|
||||
#include "exec/target_page.h"
|
||||
#include "exec/hwaddr.h"
|
||||
|
||||
@@ -7,7 +7,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int qemu_ram_get_fd(RAMBlock *rb)
|
||||
int qemu_ram_get_fd(const RAMBlock *rb)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
#include "system/ramblock.h"
|
||||
#include "system/memory.h"
|
||||
|
||||
void *qemu_ram_get_host_addr(RAMBlock *rb)
|
||||
void *qemu_ram_get_host_addr(const RAMBlock *rb)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ram_addr_t qemu_ram_get_offset(RAMBlock *rb)
|
||||
ram_addr_t qemu_ram_get_offset(const RAMBlock *rb)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ram_addr_t qemu_ram_get_used_length(RAMBlock *rb)
|
||||
ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1859,48 +1859,48 @@ static void qemu_ram_setup_dump(void *addr, ram_addr_t size)
|
||||
}
|
||||
}
|
||||
|
||||
const char *qemu_ram_get_idstr(RAMBlock *rb)
|
||||
const char *qemu_ram_get_idstr(const RAMBlock *rb)
|
||||
{
|
||||
return rb->idstr;
|
||||
}
|
||||
|
||||
void *qemu_ram_get_host_addr(RAMBlock *rb)
|
||||
void *qemu_ram_get_host_addr(const RAMBlock *rb)
|
||||
{
|
||||
return rb->host;
|
||||
}
|
||||
|
||||
ram_addr_t qemu_ram_get_offset(RAMBlock *rb)
|
||||
ram_addr_t qemu_ram_get_offset(const RAMBlock *rb)
|
||||
{
|
||||
return rb->offset;
|
||||
}
|
||||
|
||||
ram_addr_t qemu_ram_get_fd_offset(RAMBlock *rb)
|
||||
ram_addr_t qemu_ram_get_fd_offset(const RAMBlock *rb)
|
||||
{
|
||||
return rb->fd_offset;
|
||||
}
|
||||
|
||||
ram_addr_t qemu_ram_get_used_length(RAMBlock *rb)
|
||||
ram_addr_t qemu_ram_get_used_length(const RAMBlock *rb)
|
||||
{
|
||||
return rb->used_length;
|
||||
}
|
||||
|
||||
ram_addr_t qemu_ram_get_max_length(RAMBlock *rb)
|
||||
ram_addr_t qemu_ram_get_max_length(const RAMBlock *rb)
|
||||
{
|
||||
return rb->max_length;
|
||||
}
|
||||
|
||||
bool qemu_ram_is_shared(RAMBlock *rb)
|
||||
bool qemu_ram_is_shared(const RAMBlock *rb)
|
||||
{
|
||||
return rb->flags & RAM_SHARED;
|
||||
}
|
||||
|
||||
bool qemu_ram_is_noreserve(RAMBlock *rb)
|
||||
bool qemu_ram_is_noreserve(const RAMBlock *rb)
|
||||
{
|
||||
return rb->flags & RAM_NORESERVE;
|
||||
}
|
||||
|
||||
/* Note: Only set at the start of postcopy */
|
||||
bool qemu_ram_is_uf_zeroable(RAMBlock *rb)
|
||||
bool qemu_ram_is_uf_zeroable(const RAMBlock *rb)
|
||||
{
|
||||
return rb->flags & RAM_UF_ZEROPAGE;
|
||||
}
|
||||
@@ -1910,7 +1910,7 @@ void qemu_ram_set_uf_zeroable(RAMBlock *rb)
|
||||
rb->flags |= RAM_UF_ZEROPAGE;
|
||||
}
|
||||
|
||||
bool qemu_ram_is_migratable(RAMBlock *rb)
|
||||
bool qemu_ram_is_migratable(const RAMBlock *rb)
|
||||
{
|
||||
return rb->flags & RAM_MIGRATABLE;
|
||||
}
|
||||
@@ -1925,12 +1925,12 @@ void qemu_ram_unset_migratable(RAMBlock *rb)
|
||||
rb->flags &= ~RAM_MIGRATABLE;
|
||||
}
|
||||
|
||||
bool qemu_ram_is_named_file(RAMBlock *rb)
|
||||
bool qemu_ram_is_named_file(const RAMBlock *rb)
|
||||
{
|
||||
return rb->flags & RAM_NAMED_FILE;
|
||||
}
|
||||
|
||||
int qemu_ram_get_fd(RAMBlock *rb)
|
||||
int qemu_ram_get_fd(const RAMBlock *rb)
|
||||
{
|
||||
return rb->fd;
|
||||
}
|
||||
@@ -1987,7 +1987,7 @@ static char *cpr_name(MemoryRegion *mr)
|
||||
}
|
||||
}
|
||||
|
||||
size_t qemu_ram_pagesize(RAMBlock *rb)
|
||||
size_t qemu_ram_pagesize(const RAMBlock *rb)
|
||||
{
|
||||
return rb->page_size;
|
||||
}
|
||||
@@ -2772,7 +2772,7 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr)
|
||||
}
|
||||
|
||||
/* Return the offset of a hostpointer within a ramblock */
|
||||
ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
|
||||
ram_addr_t qemu_ram_block_host_offset(const RAMBlock *rb, void *host)
|
||||
{
|
||||
ram_addr_t res = (uint8_t *)host - (uint8_t *)rb->host;
|
||||
assert((uintptr_t)host >= (uintptr_t)rb->host);
|
||||
|
||||
Reference in New Issue
Block a user