From patchwork Sun May 20 09:57:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianjun Kong X-Patchwork-Id: 160252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 25557B6FB4 for ; Sun, 20 May 2012 19:57:50 +1000 (EST) Received: from localhost ([::1]:55957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SW2tX-0006Mi-H2 for incoming@patchwork.ozlabs.org; Sun, 20 May 2012 05:57:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SW2tR-0006Mc-7t for qemu-devel@nongnu.org; Sun, 20 May 2012 05:57:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SW2tP-0007Ht-F0 for qemu-devel@nongnu.org; Sun, 20 May 2012 05:57:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SW2tP-0007HS-77 for qemu-devel@nongnu.org; Sun, 20 May 2012 05:57:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4K9valp021773 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 20 May 2012 05:57:36 -0400 Received: from dhcp-8-167.nay.redhat.com (dhcp-8-167.nay.redhat.com [10.66.8.167]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q4K9vX2C002130; Sun, 20 May 2012 05:57:34 -0400 From: Amos Kong To: qemu-devel@nongnu.org, mst@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com Date: Sun, 20 May 2012 17:57:45 +0800 Message-Id: <1337507865-28504-1-git-send-email-kongjianjun@gmail.com> In-Reply-To: <20120511145725.16518.77110.stgit@t> References: <20120511145725.16518.77110.stgit@t> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Amos Kong Subject: [Qemu-devel] [PATCH v3] pci: call object_unparent() before free_qdev() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Start VM with 8 multiple-function block devs, hot-removing those block devs by 'device_del ...' would cause qemu abort. | (qemu) device_del virti0-0-0 | (qemu) ** |ERROR:qom/object.c:389:object_delete: assertion failed: (obj->ref == 0) It's a regression introduced by commit 57c9fafe The whole PCI slot should be removed once. Currently only one func is cleaned in pci_unplug_device(), if you try to remove a single func by monitor cmd. free_qdev() are called for all functions in slot, but unparent_delete() is only called for one function. Signed-off-by: XXXX --- aliguori has a better resolution, better to do it in 1.2 v2: fix warning: too many arguments for format v3: move object_unparent() to acpi_piix_eject_slot() Signed-off-by: Amos Kong --- hw/acpi_piix4.c | 1 + hw/pci.c | 1 - 2 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 585da4e..0345490 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -299,6 +299,7 @@ static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned slots) if (pc->no_hotplug) { slot_free = false; } else { + object_unparent(OBJECT(dev)); qdev_free(qdev); } } diff --git a/hw/pci.c b/hw/pci.c index b706e69..c1ebdde 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1527,7 +1527,6 @@ static int pci_unplug_device(DeviceState *qdev) qerror_report(QERR_DEVICE_NO_HOTPLUG, object_get_typename(OBJECT(dev))); return -1; } - object_unparent(OBJECT(dev)); return dev->bus->hotplug(dev->bus->hotplug_qdev, dev, PCI_HOTPLUG_DISABLED); }