Received: from eggs.gnu.org ([2001:4830:134:3::10]:35080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOUUP-0001uD-2s for qemu-devel@nongnu.org; Thu, 19 Feb 2015 12:02:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOUUK-0003Pu-UT for qemu-devel@nongnu.org; Thu, 19 Feb 2015 12:02:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOUUK-0003Pm-Ny for qemu-devel@nongnu.org; Thu, 19 Feb 2015 12:02:08 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1JH27DU024996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 19 Feb 2015 12:02:08 -0500 From: Markus Armbruster References: <1424362481-54561-1-git-send-email-pbonzini@redhat.com> Date: Thu, 19 Feb 2015 18:02:05 +0100 In-Reply-To: <1424362481-54561-1-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Thu, 19 Feb 2015 17:14:41 +0100") Message-ID: <871tllesxe.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] scsi: give device a parent before setting properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Paolo Bonzini writes: > This mimics what is done in qdev_device_add, and lets the device be > freed in case something goes wrong. Otherwise, object_unparent returns > immediately without freeing the device, which is on the other hand left > in the parent bus's list of children. > > scsi_bus_legacy_handle_cmdline then returns an error, and the HBA is > destroyed as well with object_unparent. But the lingering device that > was not removed in scsi_bus_legacy_add_drive cannot be removed now either, > and bus_unparent gets stuck in an infinite loop trying to empty the list > of children. > > The right fix of course would be to assert in bus_add_child that the > device already has a bus, and remove the "safety net" that adds the > drive to the QOM tree in device_set_realized. I am not yet sure whether > that would entail changing all callers to qdev_create (as well as > isa_create and usb_create and the corresponding _try_create versions). > > Reported-by: Markus Armbruster > Signed-off-by: Paolo Bonzini Tested-by: Markus Armbruster