From nobody Mon May 6 17:51:03 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.zohomail.com; dkim=fail; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543505809798148.23711416602555; Thu, 29 Nov 2018 07:36:49 -0800 (PST) Received: from localhost ([::1]:54862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSOMm-00083W-MZ for importer@patchew.org; Thu, 29 Nov 2018 10:36:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSOCe-0000Qm-7p for qemu-devel@nongnu.org; Thu, 29 Nov 2018 10:26:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSOCa-0001DY-Ri for qemu-devel@nongnu.org; Thu, 29 Nov 2018 10:26:08 -0500 Received: from m12-13.163.com ([220.181.12.13]:34922) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSOCY-000173-CV for qemu-devel@nongnu.org; Thu, 29 Nov 2018 10:26:04 -0500 Received: from ubuntu.localdomain (unknown [125.120.102.86]) by smtp9 (Coremail) with SMTP id DcCowACHSxUBBQBcpc6ZCQ--.64240S2; Thu, 29 Nov 2018 23:25:54 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=5s1PwEEO5IAk/yvmoG c4OZiUeUa9bljtaTzy3hi8HrA=; b=TJC9Gwa1CM4ZeT1Z4d5Ovwq0OyGNM7cpx9 gHpL1qd9eBOfbVDIrLVNMxe4R/Y+BtxFnmIfgwMuN4TmZ3M91W+EoywIZVzJ60gI UllQ79oYiZf9HrOLCNnNEHS9441oBOs3geAiKNeFZZvEEBvjWqvfQPmeGe+Tablt 4rwrFTyYA= From: Li Qiang To: pbonzini@redhat.com, famz@redhat.com Date: Thu, 29 Nov 2018 07:25:52 -0800 Message-Id: <20181129152552.14363-1-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: DcCowACHSxUBBQBcpc6ZCQ--.64240S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFW7Zw1rJr1UAF45urWDCFg_yoWruw1fpr 1UGF15CrW8Ka4DuFW2yw45JryDAF1DKw12yr13CryxCFs8GF1avFW2yrWrK3ZrJrZakr47 WF1DtwsrKr4DJaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UC1v3UUUUU= X-Originating-IP: [125.120.102.86] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBax4ObVettCkYqQABsB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH] hw: scsi: dc390: add device 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: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently the dc390 device has no unrealize function. This can cause memory leak when hotplug/unplug device. Also more serious, it will trigger an assert when rehotplug.=20 The backtrack is following: qemu-system-x86_64: migration/savevm.c:734: vmstate_register_with_alias_id:= Assertion `!se->compat || se->instance_id =3D=3D 0' failed. Thread 1 "qemu-system-x86" received signal SIGABRT, Aborted. [Switching to Thread 0x7ffff7fce280 (LWP 5721)] __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linux/raise.c:51 51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt 0 __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linux/raise.c:51 1 0x00007ffff5a10801 in __GI_abort () at abort.c:79 2 0x00007ffff5a0039a in __assert_fail_base (fmt=3D0x7ffff5b877d8 "%s%s%s:%= u: %s%sAssertion `%s' failed.\n%n", assertion=3Dassertion@entry=3D0x555555f67f68 "!se->compat || se->instan= ce_id =3D=3D 0", file=3Dfile@entry=3D0x555555f67d07 "migration/savevm.c", line=3Dline@en= try=3D734, function=3Dfunction@entry=3D0x555555f68e50 <__PRETTY_FUNCTION__.32111> = "vmstate_register_with_alias_id") at assert.c:92 3 0x00007ffff5a00412 in __GI___assert_fail (assertion=3D0x555555f67f68 "!s= e->compat || se->instance_id =3D=3D 0", file=3D0x555555f67d07 "migration/savevm.c", line=3D734, function=3D0x555555f68e50 <__PRETTY_FUNCTION__.32111> "vmstate_register= _with_alias_id") at assert.c:101 4 0x0000555555bfc1d2 in vmstate_register_with_alias_id (dev=3D0x5555577fff= 60, instance_id=3D-1, vmsd=3D0x555556533840 , opaque=3D0x555556e82ad0, alias_= id=3D-1, required_for_version=3D0, errp=3D0x0) at migration/savevm.c:734 5 0x0000555555b3ab79 in vmstate_register (dev=3D0x5555577fff60, instance_i= d=3D0, vmsd=3D0x555556533840 , opaque=3D0x555556e82ad0) at /home/test/qemu/include/migration/vmstate.h= :1067 6 0x0000555555b3b106 in eeprom93xx_new (dev=3D0x5555577fff60, nwords=3D64)= at hw/nvram/eeprom93xx.c:323 7 0x0000555555b8b587 in dc390_scsi_realize (dev=3D0x5555577fff60, errp=3D0= x7fffffffd9f8) at hw/scsi/esp-pci.c:482 8 0x0000555555b4b62e in pci_qdev_realize (qdev=3D0x5555577fff60, errp=3D0x= 7fffffffda70) at hw/pci/pci.c:2038 9 0x0000555555a89cb2 in device_set_realized (obj=3D0x5555577fff60, value= =3Dtrue, errp=3D0x7fffffffdc40) at hw/core/qdev.c:826 10 0x0000555555c7fbe8 in property_set_bool (obj=3D0x5555577fff60, v=3D0x555= 5567d9c50, name=3D0x555555edda12 "realized", opaque=3D0x5555575a6170, errp=3D0x7fffffffdc40) at qom/object.c:1991 11 0x0000555555c7de64 in object_property_set (obj=3D0x5555577fff60, v=3D0x5= 555567d9c50, name=3D0x555555edda12 "realized", errp=3D0x7fffffffdc40) at qom/object.c:1183 12 0x0000555555c80f2a in object_property_set_qobject (obj=3D0x5555577fff60,= value=3D0x555556e84be0, name=3D0x555555edda12 "realized", errp=3D0x7fffffffdc40) at qom/qom-qob= ject.c:27 13 0x0000555555c7e149 in object_property_set_bool (obj=3D0x5555577fff60, va= lue=3Dtrue, name=3D0x555555edda12 "realized", errp=3D0x7fffffffdc40) at qom/object.c:1249 14 0x00005555559d3207 in qdev_device_add (opts=3D0x5555573aab00, errp=3D0x7= fffffffdcb0) at qdev-monitor.c:642 15 0x00005555559d39f0 in qmp_device_add (qdict=3D0x555556a15000, ret_data= =3D0x0, errp=3D0x7fffffffdcf0) ---Type to continue, or q to quit--- at qdev-monitor.c:822 16 0x0000555555a01e2a in hmp_device_add (mon=3D0x5555568b8000, qdict=3D0x55= 5556a15000) at hmp.c:2067 Signed-off-by: Li Qiang --- hw/scsi/esp-pci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index 419fc668ac..09d1331395 100644 --- a/hw/scsi/esp-pci.c +++ b/hw/scsi/esp-pci.c @@ -463,6 +463,14 @@ static void dc390_write_config(PCIDevice *dev, } } =20 +static void dc390_scsi_uninit(PCIDevice *dev) +{ + DC390State *pci =3D DC390(dev); + + eeprom93xx_free(&dev->qdev, pci->eeprom); + esp_pci_scsi_uninit(dev); +} + static void dc390_scsi_realize(PCIDevice *dev, Error **errp) { DC390State *pci =3D DC390(dev); @@ -510,6 +518,7 @@ static void dc390_class_init(ObjectClass *klass, void *= data) PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 k->realize =3D dc390_scsi_realize; + k->exit =3D dc390_scsi_uninit; k->config_read =3D dc390_read_config; k->config_write =3D dc390_write_config; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); --=20 2.17.1