summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2011-07-27 13:50:41 +0530
committerAmit Shah <amit.shah@redhat.com>2011-07-28 15:10:33 +0530
commit7e10be8c743e5f1e8a46ad0d863b4fd670e163ee (patch)
tree1d49bf4fc2480a460bbb6ecc1c2ca993f834f34d
parentballoon: Reject negative balloon values (diff)
downloadqemu-kvm-7e10be8c743e5f1e8a46ad0d863b4fd670e163ee.tar.gz
qemu-kvm-7e10be8c743e5f1e8a46ad0d863b4fd670e163ee.tar.bz2
qemu-kvm-7e10be8c743e5f1e8a46ad0d863b4fd670e163ee.zip
virtio-balloon: Add exit handler, fix memleaks
Add an exit handler that will free up RAM after a virtio-balloon device is unplugged. Signed-off-by: Amit Shah <amit.shah@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/virtio-balloon.c5
-rw-r--r--hw/virtio-pci.c11
-rw-r--r--hw/virtio.h1
3 files changed, 16 insertions, 1 deletions
diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index 26ee36472..0ce00495e 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 ca5f125da..316bf92db 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 0fd0bb0ac..c1292647f 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, \