diff options
author | Amit Shah <amit.shah@redhat.com> | 2011-07-27 13:50:41 +0530 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-08-04 16:43:10 -0500 |
commit | 855d7e259fe2a804f08698ca5c97d6b07fa79da1 (patch) | |
tree | 5cb9ed7119f6c4413995ccce2eac9e0d3e65d091 /hw/virtio-pci.c | |
parent | 514e73ecebc0aeadef218e91e36ee42b3d145c93 (diff) | |
download | qemu-855d7e259fe2a804f08698ca5c97d6b07fa79da1.zip qemu-855d7e259fe2a804f08698ca5c97d6b07fa79da1.tar.gz qemu-855d7e259fe2a804f08698ca5c97d6b07fa79da1.tar.bz2 |
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>
Diffstat (limited to 'hw/virtio-pci.c')
-rw-r--r-- | hw/virtio-pci.c | 11 |
1 files changed, 10 insertions, 1 deletions
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, |