]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
ide: core: add cleanup function
authorLi Qiang <liq3ea@gmail.com>
Thu, 16 Mar 2017 00:50:14 +0000 (20:50 -0400)
committerJohn Snow <jsnow@redhat.com>
Thu, 16 Mar 2017 00:50:14 +0000 (20:50 -0400)
As the pci ahci can be hotplug and unplug, in the ahci unrealize
function it should free all the resource once allocated in the
realized function. This patch add ide_exit to free the resource.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Message-id: 1488449293-80280-3-git-send-email-liqiang6-s@360.cn
Signed-off-by: John Snow <jsnow@redhat.com>
hw/ide/core.c
include/hw/ide/internal.h

index db509b3e15b0db1ca047d4f73f2a9e1bd4b30756..0b48b64d3ae6bb5aa43a26fbcc17973dea9525ca 100644 (file)
@@ -2603,6 +2603,14 @@ void ide_init2(IDEBus *bus, qemu_irq irq)
     bus->dma = &ide_dma_nop;
 }
 
+void ide_exit(IDEState *s)
+{
+    timer_del(s->sector_write_timer);
+    timer_free(s->sector_write_timer);
+    qemu_vfree(s->smart_selftest_data);
+    qemu_vfree(s->io_buffer);
+}
+
 static const MemoryRegionPortio ide_portio_list[] = {
     { 0, 8, 1, .read = ide_ioport_read, .write = ide_ioport_write },
     { 0, 1, 2, .read = ide_data_readw, .write = ide_data_writew },
index 88dc11808b9e1626becf711d70a846a8984b4de1..482a9512bea93bede102ce85e85a33bbd1803e41 100644 (file)
@@ -607,6 +607,7 @@ int ide_init_drive(IDEState *s, BlockBackend *blk, IDEDriveKind kind,
                    uint32_t cylinders, uint32_t heads, uint32_t secs,
                    int chs_trans);
 void ide_init2(IDEBus *bus, qemu_irq irq);
+void ide_exit(IDEState *s);
 void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2);
 void ide_register_restart_cb(IDEBus *bus);