From nobody Wed May 1 02:07:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489625709616475.2759470986165; Wed, 15 Mar 2017 17:55:09 -0700 (PDT) Received: from localhost ([::1]:40189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coJh6-00077y-G0 for importer@patchew.org; Wed, 15 Mar 2017 20:55:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coJf8-00067i-OM for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coJf7-0006n1-56 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48242) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1coJf6-0006ms-VC for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6110C05AA65; Thu, 16 Mar 2017 00:53:04 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id A10CA60F8E; Thu, 16 Mar 2017 00:53:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D6110C05AA65 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jsnow@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D6110C05AA65 From: John Snow To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 20:52:57 -0400 Message-Id: <20170316005259.21970-2-jsnow@redhat.com> In-Reply-To: <20170316005259.21970-1-jsnow@redhat.com> References: <20170316005259.21970-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 16 Mar 2017 00:53:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-rc1 1/3] ide: qdev: register ide bus unrealize 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: peter.maydell@linaro.org, Li Qiang , jsnow@redhat.com, Li Qiang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Li Qiang we have an idebus unrealize function, but it was being registered as the unrealize function for the IDE Device, so it was not getting invoked on device teardown because nothing is "unrealizing" the IDE devices themselves. Suggested-by: John Snow Signed-off-by: Li Qiang Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 1488449293-80280-2-git-send-email-liqiang6-s@360.cn Signed-off-by: John Snow --- hw/ide/qdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 4383cd1..299e592 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -31,7 +31,7 @@ /* --------------------------------- */ =20 static char *idebus_get_fw_dev_path(DeviceState *dev); -static void idebus_unrealize(DeviceState *qdev, Error **errp); +static void idebus_unrealize(BusState *qdev, Error **errp); =20 static Property ide_props[] =3D { DEFINE_PROP_UINT32("unit", IDEDevice, unit, -1), @@ -43,14 +43,15 @@ static void ide_bus_class_init(ObjectClass *klass, void= *data) BusClass *k =3D BUS_CLASS(klass); =20 k->get_fw_dev_path =3D idebus_get_fw_dev_path; + k->unrealize =3D idebus_unrealize; } =20 -static void idebus_unrealize(DeviceState *qdev, Error **errp) +static void idebus_unrealize(BusState *bus, Error **errp) { - IDEBus *bus =3D DO_UPCAST(IDEBus, qbus, qdev->parent_bus); + IDEBus *ibus =3D IDE_BUS(bus); =20 - if (bus->vmstate) { - qemu_del_vm_change_state_handler(bus->vmstate); + if (ibus->vmstate) { + qemu_del_vm_change_state_handler(ibus->vmstate); } } =20 @@ -370,7 +371,6 @@ static void ide_device_class_init(ObjectClass *klass, v= oid *data) k->init =3D ide_qdev_init; set_bit(DEVICE_CATEGORY_STORAGE, k->categories); k->bus_type =3D TYPE_IDE_BUS; - k->unrealize =3D idebus_unrealize; k->props =3D ide_props; } =20 --=20 2.9.3 From nobody Wed May 1 02:07:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148962563227099.9300727339878; Wed, 15 Mar 2017 17:53:52 -0700 (PDT) Received: from localhost ([::1]:40185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coJfq-000682-Ai for importer@patchew.org; Wed, 15 Mar 2017 20:53:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coJf8-00067k-PN for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coJf7-0006nB-Sw for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1coJf7-0006mx-Mi for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A7DC201FB; Thu, 16 Mar 2017 00:53:05 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 021F460E3F; Thu, 16 Mar 2017 00:53:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9A7DC201FB Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jsnow@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9A7DC201FB From: John Snow To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 20:52:58 -0400 Message-Id: <20170316005259.21970-3-jsnow@redhat.com> In-Reply-To: <20170316005259.21970-1-jsnow@redhat.com> References: <20170316005259.21970-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 16 Mar 2017 00:53:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-rc1 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: peter.maydell@linaro.org, Li Qiang , jsnow@redhat.com, Li Qiang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Li Qiang 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 Message-id: 1488449293-80280-3-git-send-email-liqiang6-s@360.cn Signed-off-by: John Snow --- 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 db509b3..0b48b64 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 =3D &ide_dma_nop; } =20 +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[] =3D { { 0, 8, 1, .read =3D ide_ioport_read, .write =3D ide_ioport_write }, { 0, 1, 2, .read =3D ide_data_readw, .write =3D 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, IDED= riveKind 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); =20 --=20 2.9.3 From nobody Wed May 1 02:07:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489625769488584.5361182413477; Wed, 15 Mar 2017 17:56:09 -0700 (PDT) Received: from localhost ([::1]:40198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coJi4-0007iZ-EB for importer@patchew.org; Wed, 15 Mar 2017 20:56:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coJf9-00067l-CL for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coJf8-0006nK-JS for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48280) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1coJf8-0006n7-Dg for qemu-devel@nongnu.org; Wed, 15 Mar 2017 20:53:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D5B5C208063; Thu, 16 Mar 2017 00:53:06 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-221.bos.redhat.com [10.18.17.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA3A560F86; Thu, 16 Mar 2017 00:53:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D5B5C208063 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jsnow@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D5B5C208063 From: John Snow To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 20:52:59 -0400 Message-Id: <20170316005259.21970-4-jsnow@redhat.com> In-Reply-To: <20170316005259.21970-1-jsnow@redhat.com> References: <20170316005259.21970-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 16 Mar 2017 00:53:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-rc1 3/3] ide: ahci: call cleanup function in ahci unit 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: peter.maydell@linaro.org, Li Qiang , jsnow@redhat.com, Li Qiang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Li Qiang This can avoid memory leak when hotunplug the ahci device. Signed-off-by: Li Qiang Message-id: 1488449293-80280-4-git-send-email-liqiang6-s@360.cn Signed-off-by: John Snow --- hw/ide/ahci.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 6a17acf..f60826d 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1485,6 +1485,18 @@ void ahci_realize(AHCIState *s, DeviceState *qdev, A= ddressSpace *as, int ports) =20 void ahci_uninit(AHCIState *s) { + int i, j; + + for (i =3D 0; i < s->ports; i++) { + AHCIDevice *ad =3D &s->dev[i]; + + for (j =3D 0; j < 2; j++) { + IDEState *s =3D &ad->port.ifs[j]; + + ide_exit(s); + } + } + g_free(s->dev); } =20 --=20 2.9.3