From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgv6v-0007RF-WB for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgv6r-0001BU-WB for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:38:25 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:56900) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgv6r-0001BH-Nx for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:38:21 -0400 References: <1443094669-4144-1-git-send-email-marcandre.lureau@redhat.com> <1443094669-4144-28-git-send-email-marcandre.lureau@redhat.com> From: Claudio Fontana Message-ID: <560A9447.1010204@huawei.com> Date: Tue, 29 Sep 2015 15:38:15 +0200 MIME-Version: 1.0 In-Reply-To: <1443094669-4144-28-git-send-email-marcandre.lureau@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v4 27/47] ivshmem: fix pci_ivshmem_exit() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org Cc: pbonzini@redhat.com, drjones@redhat.com, cam@cs.ualberta.ca, stefanha@redhat.com On 24.09.2015 13:37, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau > > Free all objects owned by the device, making sure the device is free, > fixing hot-unplug. > > Signed-off-by: Marc-André Lureau > --- > hw/misc/ivshmem.c | 38 +++++++++++++++++++++++++++++++++++--- > 1 file changed, 35 insertions(+), 3 deletions(-) > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > index 9be4d1e..f8f74fc 100644 > --- a/hw/misc/ivshmem.c > +++ b/hw/misc/ivshmem.c > @@ -800,15 +800,47 @@ static void pci_ivshmem_realize(PCIDevice *dev, Error **errp) > static void pci_ivshmem_exit(PCIDevice *dev) > { > IVShmemState *s = IVSHMEM(dev); > + int i; > + > + fifo8_destroy(&s->incoming_fifo); > > if (s->migration_blocker) { > migrate_del_blocker(s->migration_blocker); > error_free(s->migration_blocker); > } > > - memory_region_del_subregion(&s->bar, &s->ivshmem); > - vmstate_unregister_ram(&s->ivshmem, DEVICE(dev)); > - fifo8_destroy(&s->incoming_fifo); > + if (s->shm_fd >= 0) { > + void *addr = memory_region_get_ram_ptr(&s->ivshmem); > + > + vmstate_unregister_ram(&s->ivshmem, DEVICE(dev)); > + memory_region_del_subregion(&s->bar, &s->ivshmem); > + > + if (munmap(addr, s->ivshmem_size) == -1) { > + error_report("Failed to munmap shared memory %s", strerror(errno)); > + } > + } > + > + if (s->eventfd_chr) { > + for (i = 0; i < s->vectors; i++) { > + if (s->eventfd_chr[i]) { > + qemu_chr_free(s->eventfd_chr[i]); > + } > + } > + g_free(s->eventfd_chr); > + } > + > + if (s->peers) { > + for (i = 0; i < s->nb_peers; i++) { > + close_guest_eventfds(s, i); > + } > + g_free(s->peers); > + } > + > + if (ivshmem_has_feature(s, IVSHMEM_MSI)) { > + msix_uninit_exclusive_bar(dev); > + } > + > + g_free(s->eventfd_table); > } > > static bool test_msix(void *opaque, int version_id) > missed this one last time.. eaten by a grue or something. Reviewed-by: Claudio Fontana