mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
memory: expose alignment used for allocating RAM as MemoryRegion API
introduce memory_region_get_alignment() that returns underlying memory block alignment or 0 if it's not relevant/implemented for backend. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
92a37a04d6
commit
a2b257d621
8 changed files with 22 additions and 8 deletions
|
@ -124,7 +124,7 @@ void *qemu_memalign(size_t alignment, size_t size)
|
|||
}
|
||||
|
||||
/* alloc shared memory pages */
|
||||
void *qemu_anon_ram_alloc(size_t size)
|
||||
void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment)
|
||||
{
|
||||
size_t align = QEMU_VMALLOC_ALIGN;
|
||||
size_t total = size + align - getpagesize();
|
||||
|
@ -136,6 +136,9 @@ void *qemu_anon_ram_alloc(size_t size)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (alignment) {
|
||||
*alignment = align;
|
||||
}
|
||||
ptr += offset;
|
||||
total -= offset;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue