From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbubw-00043s-G1 for qemu-devel@nongnu.org; Thu, 09 Feb 2017 14:42:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbubs-0000Xw-0z for qemu-devel@nongnu.org; Thu, 09 Feb 2017 14:42:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55822) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbubr-0000Xh-RN for qemu-devel@nongnu.org; Thu, 09 Feb 2017 14:42:27 -0500 References: <1486623844-13140-1-git-send-email-liqiang6-s@360.cn> <1486623844-13140-2-git-send-email-liqiang6-s@360.cn> From: John Snow Message-ID: Date: Thu, 9 Feb 2017 14:42:21 -0500 MIME-Version: 1.0 In-Reply-To: <1486623844-13140-2-git-send-email-liqiang6-s@360.cn> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] ide: core: add cleanup function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Li Qiang , qemu-devel@nongnu.org Cc: Li Qiang On 02/09/2017 02:04 AM, Li Qiang wrote: > 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 adds two cleanup function. > > Signed-off-by: Li Qiang > --- > hw/ide/core.c | 21 +++++++++++++++++++++ > include/hw/ide/internal.h | 2 ++ > 2 files changed, 23 insertions(+) > > diff --git a/hw/ide/core.c b/hw/ide/core.c > index 43709e5..8fe5896 100644 > --- a/hw/ide/core.c > +++ b/hw/ide/core.c > @@ -2586,6 +2586,13 @@ void ide_register_restart_cb(IDEBus *bus) > } > } > > +void ide_unregister_restart_cb(IDEBus *bus) > +{ > + if (bus->dma->ops->restart_dma) { > + qemu_del_vm_change_state_handler(bus->vmstate); > + } > +} > + Doesn't this conflict with qdev.c's idebus_unrealize call? > static IDEDMA ide_dma_nop = { > .ops = &ide_dma_nop_ops, > .aiocb = NULL, > @@ -2603,6 +2610,20 @@ void ide_init2(IDEBus *bus, qemu_irq irq) > bus->dma = &ide_dma_nop; > } > > +void ide_exit(IDEBus *bus) > +{ > + int i; > + > + for (i = 0; i < 2; i++) { > + IDEState *s = &bus->ifs[i]; > + > + 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 }, > diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h > index 88dc118..09b0404 100644 > --- a/include/hw/ide/internal.h > +++ b/include/hw/ide/internal.h > @@ -607,8 +607,10 @@ 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(IDEBus *bus); > void ide_init_ioport(IDEBus *bus, ISADevice *isa, int iobase, int iobase2); > void ide_register_restart_cb(IDEBus *bus); > +void ide_unregister_restart_cb(IDEBus *bus); > > void ide_exec_cmd(IDEBus *bus, uint32_t val); > >