From patchwork Thu Jul 28 06:17:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 107178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 740C5B6F69 for ; Thu, 28 Jul 2011 16:17:59 +1000 (EST) Received: from localhost ([::1]:57370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmJuu-0002bM-P6 for incoming@patchwork.ozlabs.org; Thu, 28 Jul 2011 02:17:56 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmJuf-0002Mu-IS for qemu-devel@nongnu.org; Thu, 28 Jul 2011 02:17:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QmJue-0006Ro-C7 for qemu-devel@nongnu.org; Thu, 28 Jul 2011 02:17:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmJud-0006Rf-TO for qemu-devel@nongnu.org; Thu, 28 Jul 2011 02:17:40 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6S6HdJv004414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Jul 2011 02:17:39 -0400 Received: from localhost (ovpn-113-73.phx2.redhat.com [10.3.113.73]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6S6HaLM002181; Thu, 28 Jul 2011 02:17:38 -0400 From: Amit Shah To: qemu list Date: Thu, 28 Jul 2011 11:47:15 +0530 Message-Id: <5daa3ce7cc77ed1bbec75f96361362e3e627cd6d.1311833521.git.amit.shah@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Amit Shah , Markus Armbruster , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH v2 4/5] virtio-balloon: Add exit handler, fix memleaks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add an exit handler that will free up RAM and unregister the savevm section after a virtio-balloon device is unplugged. Signed-off-by: Amit Shah --- hw/virtio-balloon.c | 5 +++++ hw/virtio-pci.c | 11 ++++++++++- hw/virtio.h | 1 + 3 files changed, 16 insertions(+), 1 deletions(-) diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index 26ee364..0ce0049 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -297,3 +297,8 @@ VirtIODevice *virtio_balloon_init(DeviceState *dev) return &s->vdev; } + +void virtio_balloon_exit(VirtIODevice *vdev) +{ + virtio_cleanup(vdev); +} diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index ca5f125..316bf92 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -795,6 +795,15 @@ static int virtio_balloon_init_pci(PCIDevice *pci_dev) return 0; } +static int virtio_balloon_exit_pci(PCIDevice *pci_dev) +{ + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); + + virtio_pci_stop_ioeventfd(proxy); + virtio_balloon_exit(proxy->vdev); + return virtio_exit_pci(pci_dev); +} + static PCIDeviceInfo virtio_info[] = { { .qdev.name = "virtio-blk-pci", @@ -869,7 +878,7 @@ static PCIDeviceInfo virtio_info[] = { .qdev.alias = "virtio-balloon", .qdev.size = sizeof(VirtIOPCIProxy), .init = virtio_balloon_init_pci, - .exit = virtio_exit_pci, + .exit = virtio_balloon_exit_pci, .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET, .device_id = PCI_DEVICE_ID_VIRTIO_BALLOON, .revision = VIRTIO_PCI_ABI_VERSION, diff --git a/hw/virtio.h b/hw/virtio.h index 0fd0bb0..c129264 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -213,6 +213,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf); void virtio_net_exit(VirtIODevice *vdev); void virtio_blk_exit(VirtIODevice *vdev); void virtio_serial_exit(VirtIODevice *vdev); +void virtio_balloon_exit(VirtIODevice *vdev); #define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \ DEFINE_PROP_BIT("indirect_desc", _state, _field, \