Received: from eggs.gnu.org ([2001:4830:134:3::10]:53297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGpon-0007pq-PU for qemu-devel@nongnu.org; Tue, 03 Sep 2013 08:34:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGpof-0006b8-CN for qemu-devel@nongnu.org; Tue, 03 Sep 2013 08:34:49 -0400 Received: from mail-ea0-x230.google.com ([2a00:1450:4013:c01::230]:64522) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGpof-0006ap-1Y for qemu-devel@nongnu.org; Tue, 03 Sep 2013 08:34:41 -0400 Received: by mail-ea0-f176.google.com with SMTP id q16so2917021ead.7 for ; Tue, 03 Sep 2013 05:34:40 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 3 Sep 2013 14:33:26 +0200 Message-Id: <1378211609-16121-36-git-send-email-pbonzini@redhat.com> In-Reply-To: <1378211609-16121-1-git-send-email-pbonzini@redhat.com> References: <1378211609-16121-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 35/38] virtio-pci: reclaim memory in instance_finalize instead of exit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: mst@redhat.com Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-pci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index ff6bed5..8ed6d52 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -997,8 +997,14 @@ static void virtio_pci_exit(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev); virtio_pci_stop_ioeventfd(proxy); - memory_region_destroy(&proxy->bar); msix_uninit_exclusive_bar(pci_dev); +} + +static void virtio_pci_instance_finalize(Object *obj) +{ + PCIDevice *pci_dev = PCI_DEVICE(obj); + VirtIOPCIProxy *proxy = VIRTIO_PCI(obj); + memory_region_destroy(&proxy->bar); msix_free(pci_dev); } @@ -1031,6 +1037,7 @@ static const TypeInfo virtio_pci_info = { .instance_size = sizeof(VirtIOPCIProxy), .class_init = virtio_pci_class_init, .class_size = sizeof(VirtioPCIClass), + .instance_finalize = virtio_pci_instance_finalize, .abstract = true, }; -- 1.8.3.1