exec: Implement qemu_ram_free_from_ptr()
Required for regions mapped via qemu_ram_alloc_from_ptr(). VFIO and ivshmem will make use of this to remove mappings when devices are hot unplugged. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
c83066d4c4
commit
1f2e98b62d
@ -61,6 +61,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
|
|||||||
ram_addr_t size, void *host);
|
ram_addr_t size, void *host);
|
||||||
ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
|
ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
|
||||||
void qemu_ram_free(ram_addr_t addr);
|
void qemu_ram_free(ram_addr_t addr);
|
||||||
|
void qemu_ram_free_from_ptr(ram_addr_t addr);
|
||||||
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
|
void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
|
||||||
/* This should only be used for ram local to a device. */
|
/* This should only be used for ram local to a device. */
|
||||||
void *qemu_get_ram_ptr(ram_addr_t addr);
|
void *qemu_get_ram_ptr(ram_addr_t addr);
|
||||||
|
13
exec.c
13
exec.c
@ -2952,6 +2952,19 @@ ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size)
|
|||||||
return qemu_ram_alloc_from_ptr(dev, name, size, NULL);
|
return qemu_ram_alloc_from_ptr(dev, name, size, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qemu_ram_free_from_ptr(ram_addr_t addr)
|
||||||
|
{
|
||||||
|
RAMBlock *block;
|
||||||
|
|
||||||
|
QLIST_FOREACH(block, &ram_list.blocks, next) {
|
||||||
|
if (addr == block->offset) {
|
||||||
|
QLIST_REMOVE(block, next);
|
||||||
|
qemu_free(block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void qemu_ram_free(ram_addr_t addr)
|
void qemu_ram_free(ram_addr_t addr)
|
||||||
{
|
{
|
||||||
RAMBlock *block;
|
RAMBlock *block;
|
||||||
|
Loading…
Reference in New Issue
Block a user