From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab4bb-0007O0-R7 for qemu-devel@nongnu.org; Wed, 02 Mar 2016 06:06:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ab4bW-0003zO-5I for qemu-devel@nongnu.org; Wed, 02 Mar 2016 06:06:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ab4bV-0003zB-WA for qemu-devel@nongnu.org; Wed, 02 Mar 2016 06:06:06 -0500 From: Markus Armbruster References: <1456771254-17511-1-git-send-email-armbru@redhat.com> <1456771254-17511-31-git-send-email-armbru@redhat.com> <56D5811C.7090108@redhat.com> <87y4a2gumw.fsf@blackfin.pond.sub.org> <56D5B200.2020505@redhat.com> Date: Wed, 02 Mar 2016 12:06:03 +0100 In-Reply-To: <56D5B200.2020505@redhat.com> (Paolo Bonzini's message of "Tue, 1 Mar 2016 16:15:12 +0100") Message-ID: <87twkpm95w.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 30/38] ivshmem: Simplify memory regions for BAR 2 (shared memory) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: mlureau@redhat.com, cam@cs.ualberta.ca, claudio.fontana@huawei.com, qemu-devel@nongnu.org, david.marchand@6wind.com Paolo Bonzini writes: > On 01/03/2016 15:06, Markus Armbruster wrote: >> Paolo Bonzini 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. You mean I'm supposed to have read and understood that?!? ;-} Thanks! [...]