Paolo Bonzini <pbonz...@redhat.com> writes: > On 29/02/2016 19:40, Markus Armbruster wrote: >> - memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s), >> + s->ivshmem_bar2 = g_new(MemoryRegion, 1); >> + memory_region_init_ram_ptr(s->ivshmem_bar2, OBJECT(s), >> "ivshmem.bar2", s->ivshmem_size, ptr); >> - qemu_set_ram_fd(s->ivshmem.ram_addr, fd); >> - vmstate_register_ram(&s->ivshmem, DEVICE(s)); >> - memory_region_add_subregion(&s->bar, 0, &s->ivshmem); >> + qemu_set_ram_fd(s->ivshmem_bar2->ram_addr, fd); > > This is missing an instance_finalize callback to do > > if (s->ivshmem_bar2) { > object_unparent(s->ivshmem_bar2); > g_free(s->ivshmem_bar2); > }
Since it's allocated within ivshmem_realize(), I guess I could free it in ivshmem_exit(). > or, alternatively just use a flag (e.g. s->bar2_mapped) and allocate it > directly in the IVShmemState struct. I'll see what comes out nicer. Thanks!