qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: qemu list <qemu-devel@nongnu.org>
Cc: Amit Shah <amit.shah@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH v2 4/5] virtio-balloon: Add exit handler, fix memleaks
Date: Thu, 28 Jul 2011 11:47:15 +0530	[thread overview]
Message-ID: <5daa3ce7cc77ed1bbec75f96361362e3e627cd6d.1311833521.git.amit.shah@redhat.com> (raw)
In-Reply-To: <cover.1311833521.git.amit.shah@redhat.com>
In-Reply-To: <cover.1311833521.git.amit.shah@redhat.com>

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 <amit.shah@redhat.com>
---
 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, \
-- 
1.7.6

  parent reply	other threads:[~2011-07-28  6:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28  6:17 [Qemu-devel] [PATCH v2 0/5] balloon: fix memleaks, invalid arguments, unplug Amit Shah
2011-07-28  6:17 ` [Qemu-devel] [PATCH v2 1/5] balloon: Don't allow multiple balloon handler registrations Amit Shah
2011-07-28  6:17 ` [Qemu-devel] [PATCH v2 2/5] virtio-balloon: Check if balloon registration failed Amit Shah
2011-07-28  6:17 ` [Qemu-devel] [PATCH v2 3/5] balloon: Ignore negative balloon values Amit Shah
2011-07-28  7:31   ` Markus Armbruster
2011-07-28  9:36     ` Amit Shah
2011-07-28  6:17 ` Amit Shah [this message]
2011-07-28  6:28   ` [Qemu-devel] [PATCH v2 4/5] virtio-balloon: Add exit handler, fix memleaks Amit Shah
2011-07-28  7:39     ` Markus Armbruster
2011-07-28  9:37       ` Amit Shah
2011-07-28  7:35   ` Markus Armbruster
2011-07-28  6:17 ` [Qemu-devel] [PATCH v2 5/5] virtio-balloon: Unregister savevm section on device unplug Amit Shah
2011-07-28  7:45   ` Markus Armbruster
2011-07-28  9:37     ` Amit Shah
2011-07-28 11:06     ` Michael S. Tsirkin
2011-07-28 12:21       ` Markus Armbruster
2011-07-28 12:27         ` Michael S. Tsirkin
2011-07-28  7:46 ` [Qemu-devel] [PATCH v2 0/5] balloon: fix memleaks, invalid arguments, unplug Markus Armbruster
2011-07-28  8:49 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5daa3ce7cc77ed1bbec75f96361362e3e627cd6d.1311833521.git.amit.shah@redhat.com \
    --to=amit.shah@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).