[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 30/38] ivshmem: Simplify memory regions for BAR
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 30/38] ivshmem: Simplify memory regions for BAR 2 (shared memory) |
Date: |
Tue, 1 Mar 2016 16:15:12 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 01/03/2016 15:06, Markus Armbruster wrote:
> Paolo Bonzini <address@hidden> 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().
Unfortunately you can't, because the guest might be using it at the time
of hot-unplug (e.g. DMAing from disk to it). Unrealize is the place
where you hide stuff, and in this case the PCI core does it for you;
finalize is the place where you free stuff.
This is mentioned (though not really in these terms) in docs/memory.txt.
Paolo
>> 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!
>