From patchwork Thu Mar 2 10:08:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9599819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D691C600CB for ; Thu, 2 Mar 2017 10:09:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0D2C2858F for ; Thu, 2 Mar 2017 10:09:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B444C2859B; Thu, 2 Mar 2017 10:09:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C41D52858F for ; Thu, 2 Mar 2017 10:09:03 +0000 (UTC) Received: from localhost ([::1]:51353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjNfS-0003hR-Lc for patchwork-qemu-devel@patchwork.kernel.org; Thu, 02 Mar 2017 05:09:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjNfB-0003eT-RR for qemu-devel@nongnu.org; Thu, 02 Mar 2017 05:08:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjNf6-0007gg-Mu for qemu-devel@nongnu.org; Thu, 02 Mar 2017 05:08:45 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35356) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjNf6-0007gW-Hp for qemu-devel@nongnu.org; Thu, 02 Mar 2017 05:08:40 -0500 Received: by mail-pf0-x241.google.com with SMTP id 67so1971809pfg.2 for ; Thu, 02 Mar 2017 02:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RxDU2ztMUMKrY44nBZ5duSg1CZtF58fZWlXo8QURdcI=; b=GFEascf2Yia7Aw+0l0hKVPyjpNZfmelLhi41H8UlZdp1Ml/97K9o2NZipGd4JznSdb XjD+BNgN483RFETXNnUMkLJ62L6ceqX7jShTIOp4KcJJczKj2cI+/m1o6zvhPsky5VQK W9g0hD+9XmQ2iaHnLoCD7sO6HljOaBRGP7L2x8lRwzVNyifu4gakd1KdarfuS7Kw3968 sTjLJhvjAcyGp/+PZ9RLYlM15F83QJgzw7e/ieQNvzlT/SQ5xam++zIY0V4LIXKE+v5G HfJswQ/+0l8nsqyV7mzTbWVxNBkh2gxyauMVw1X3ou5kRHd7e4h9S6X/WudZjuTJmgAV C64Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RxDU2ztMUMKrY44nBZ5duSg1CZtF58fZWlXo8QURdcI=; b=pmFy3av3SlHHNmSLJSe/Dv1anurH9SSAsynfe7kJE8+HXfpgPjTRWL/00iz0n3onsr wgHB0PsEkgSsceVDEM55sZIwbTNS68xmJ7sqtQha9rJf38Z8qM00DkPLwKmyotx2TV7H Y8jo8t48eZxk9fpCFkAAQiPSy2cweVkBlUpKx/AKd2MeML3UB0eioiJ/xN+aSdbdxpFK 4d17BWlwVGwR8JX28slYAw3EcpodBxxBOP79fxSUImzyzKZ1X+qPi9yYT+BR8iJj3EKe eoqnwOY2bym6qTSCW6TlVVuuZP6SHhMR3Az19LQBOPispCNyQAwuD46rblKVhBZ7XcM9 uJgQ== X-Gm-Message-State: AMke39kJrTpythegbk09FyRWZ7UdOPTIsWDbZ7+VvhdKAUAr+b47abeB0nNta6jdgrxvmg== X-Received: by 10.84.209.167 with SMTP id y36mr2897091plh.11.1488449319781; Thu, 02 Mar 2017 02:08:39 -0800 (PST) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id l22sm15951965pfk.69.2017.03.02.02.08.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 02:08:39 -0800 (PST) From: Li Qiang X-Google-Original-From: Li Qiang To: jsnow@redhat.com, qemu-devel@nongnu.org Date: Thu, 2 Mar 2017 02:08:12 -0800 Message-Id: <1488449293-80280-3-git-send-email-liqiang6-s@360.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488449293-80280-1-git-send-email-liqiang6-s@360.cn> References: <1488449293-80280-1-git-send-email-liqiang6-s@360.cn> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH 2/3] ide: core: add cleanup function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Li Qiang , ppandit@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- hw/ide/core.c | 8 ++++++++ include/hw/ide/internal.h | 1 + 2 files changed, 9 insertions(+) diff --git a/hw/ide/core.c b/hw/ide/core.c index cfa5de6..e971a94 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -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 }, diff --git a/include/hw/ide/internal.h b/include/hw/ide/internal.h index 88dc118..482a951 100644 --- a/include/hw/ide/internal.h +++ b/include/hw/ide/internal.h @@ -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);