Add parameter errp to memory_region_init_ram_ptr and update all call sites to pass in &error_abort.
Reviewed-by: Peter Crosthwaite <peter.crosthwa...@xilinx.com> Signed-off-by: Hu Tao <hu...@cn.fujitsu.com> --- hw/display/g364fb.c | 2 +- hw/i386/kvm/pci-assign.c | 3 ++- hw/misc/ivshmem.c | 5 +++-- hw/misc/vfio.c | 3 ++- hw/ppc/spapr.c | 2 +- include/exec/memory.h | 4 +++- memory.c | 5 +++-- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c index 46f7b41..cce33ae 100644 --- a/hw/display/g364fb.c +++ b/hw/display/g364fb.c @@ -487,7 +487,7 @@ static void g364fb_init(DeviceState *dev, G364State *s) memory_region_init_io(&s->mem_ctrl, NULL, &g364fb_ctrl_ops, s, "ctrl", 0x180000); memory_region_init_ram_ptr(&s->mem_vram, NULL, "vram", - s->vram_size, s->vram); + s->vram_size, s->vram, &error_abort); vmstate_register_ram(&s->mem_vram, dev); memory_region_set_coalescing(&s->mem_vram); } diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index 13b9de0..b37d606 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -456,7 +456,8 @@ static void assigned_dev_register_regions(PCIRegion *io_regions, object_get_typename(OBJECT(pci_dev)), i); memory_region_init_ram_ptr(&pci_dev->v_addrs[i].real_iomem, OBJECT(pci_dev), name, - cur_region->size, virtbase); + cur_region->size, virtbase, + &error_abort); vmstate_register_ram(&pci_dev->v_addrs[i].real_iomem, &pci_dev->dev.qdev); } diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index bd9d718..906a6b5 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -352,7 +352,7 @@ static void create_shared_memory_BAR(IVShmemState *s, int fd) { ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s), "ivshmem.bar2", - s->ivshmem_size, ptr); + s->ivshmem_size, ptr, &error_abort); vmstate_register_ram(&s->ivshmem, DEVICE(s)); memory_region_add_subregion(&s->bar, 0, &s->ivshmem); @@ -480,7 +480,8 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) map_ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, incoming_fd, 0); memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s), - "ivshmem.bar2", s->ivshmem_size, map_ptr); + "ivshmem.bar2", s->ivshmem_size, map_ptr, + &error_abort); vmstate_register_ram(&s->ivshmem, DEVICE(s)); IVSHMEM_DPRINTF("guest h/w addr = %p, size = %" PRIu64 "\n", diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 40dcaa6..abb8d1b 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -2910,7 +2910,8 @@ static int vfio_mmap_bar(VFIODevice *vdev, VFIOBAR *bar, goto empty_region; } - memory_region_init_ram_ptr(submem, OBJECT(vdev), name, size, *map); + memory_region_init_ram_ptr(submem, OBJECT(vdev), name, size, *map, + &error_abort); } else { empty_region: /* Create a zero sized sub-region to make cleanup easy. */ diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 2ab4460..3c4aaf0 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1402,7 +1402,7 @@ static void ppc_spapr_init(MachineState *machine) if (rma_alloc_size && rma) { rma_region = g_new(MemoryRegion, 1); memory_region_init_ram_ptr(rma_region, NULL, "ppc_spapr.rma", - rma_alloc_size, rma); + rma_alloc_size, rma, &error_abort); vmstate_register_ram_global(rma_region); memory_region_add_subregion(sysmem, 0, rma_region); } diff --git a/include/exec/memory.h b/include/exec/memory.h index fd4131b..dcb35a2 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -351,12 +351,14 @@ void memory_region_init_ram_from_file(MemoryRegion *mr, * @name: the name of the region. * @size: size of the region. * @ptr: memory to be mapped; must contain at least @size bytes. + * @errp: pointer to Error*, to store an error if it happens. */ void memory_region_init_ram_ptr(MemoryRegion *mr, struct Object *owner, const char *name, uint64_t size, - void *ptr); + void *ptr, + Error **errp); /** * memory_region_init_alias: Initialize a memory region that aliases all or a diff --git a/memory.c b/memory.c index 95fbaf8..ffe24ff 100644 --- a/memory.c +++ b/memory.c @@ -1173,13 +1173,14 @@ void memory_region_init_ram_ptr(MemoryRegion *mr, Object *owner, const char *name, uint64_t size, - void *ptr) + void *ptr, + Error **errp) { memory_region_init(mr, owner, name, size); mr->ram = true; mr->terminates = true; mr->destructor = memory_region_destructor_ram_from_ptr; - mr->ram_addr = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_abort); + mr->ram_addr = qemu_ram_alloc_from_ptr(size, ptr, mr, errp); } void memory_region_init_alias(MemoryRegion *mr, -- 1.9.3