Received: from eggs.gnu.org ([2001:4830:134:3::10]:45244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOQnc-0001QG-JS for qemu-devel@nongnu.org; Thu, 19 Feb 2015 08:05:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOQnZ-0008Tk-9Q for qemu-devel@nongnu.org; Thu, 19 Feb 2015 08:05:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOQnZ-0008TS-2X for qemu-devel@nongnu.org; Thu, 19 Feb 2015 08:05:45 -0500 From: Markus Armbruster References: <87r3tmi3ig.fsf@blackfin.pond.sub.org> <54E5D6A4.1050307@suse.de> Date: Thu, 19 Feb 2015 14:05:38 +0100 In-Reply-To: <54E5D6A4.1050307@suse.de> ("Andreas =?utf-8?Q?F=C3=A4rber=22?= =?utf-8?Q?'s?= message of "Thu, 19 Feb 2015 13:27:16 +0100") Message-ID: <87mw4agifx.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] bus_unparent() can go into infinite loop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: Peter Maydell , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Alexander Graf , Bandan Das , Paolo Bonzini Andreas F=C3=A4rber writes: > Am 19.02.2015 um 11:45 schrieb Markus Armbruster: >> Reproducer (don't ask): >>=20 >> $ qemu-system-arm -M virt -S -display none -drive >> if=3Dscsi,id=3Dfoo,bus=3D1,file=3Dtmp.qcow2 -device nec-usb-xhci -device >> usb-storage,drive=3Dfoo -device virtio-scsi-pci >> qemu-system-arm: -drive if=3Dscsi,id=3Dfoo,bus=3D1,file=3Dtmp.qcow2: >> Property 'scsi-disk.drive' can't take value 'foo', it's in use >> qemu-system-arm: -drive if=3Dscsi,id=3Dfoo,bus=3D1,file=3Dtmp.qcow2: >> Setting drive property failed >> qemu-system-arm: -device virtio-scsi-pci: Setting drive property fai= led >>=20 >> Nevermind the silly error reporting, I got patches to clean that up. > > I'm actually more confused about the use of PCI devices with the virt > machine. Does that now feature Alex' PCI controller by default? > Otherwise there would be no bus for those devices. "info qtree" shows a PCIE bus: dev: gpex-pcihost, id "" gpio-out "sysbus-irq" 4 mmio ffffffffffffffff/0000000010000000 mmio ffffffffffffffff/ffffffffffffffff mmio 000000003eff0000/0000000000010000 bus: pcie.0 type PCIE dev: gpex-root, id "" addr =3D 00.0 romfile =3D "" rombar =3D 1 (0x1) multifunction =3D false command_serr_enable =3D true class Host bridge, addr 00:00.0, pci id 1b36:0008 (sub 1af4:1100) > Is this on master or on top of your PCI realize changes or anything? Unadulterated master (commit cd2d554). >> Stuck in bus_unparent()'s loop: >>=20 >> while ((kid =3D QTAILQ_FIRST(&bus->children)) !=3D NULL) { >> DeviceState *dev =3D kid->child; >> object_unparent(OBJECT(dev)); >> } > > Logically speaking, unparenting on QOM level has nothing to with the bus > children list. > The parent may well be /machine/{unassigned,peripheral{,-anon}} > container objects rather than some BusState object, the latter usually > has link<> properties only for its qdev-level "children". > > However I vaguely recall that we shoehorned the unparenting callback to > invoke unrealizing the device. What might happen here is that after > realizing the device failed, realized =3D=3D false; realized =3D false in= the > unparenting path becomes a no-op then. I.e., the realize error handling > may need to be reviewed to not just return but to undo any changes such > as attaching to some bus (or MemoryRegion, VMState, etc.). (gdb) p *dev $2 =3D {parent_obj =3D {class =3D 0x555556282140, free =3D 0x7ffff64dcf70 <= g_free>,=20 properties =3D {tqh_first =3D 0x55555669d860, tqh_last =3D 0x5555566a1d= 90},=20 ref =3D 1, parent =3D 0x0}, id =3D 0x0, realized =3D false,=20 pending_deleted_event =3D false, opts =3D 0x0, hotplugged =3D 0,=20 parent_bus =3D 0x555556450060, gpios =3D {lh_first =3D 0x0}, child_bus = =3D { lh_first =3D 0x0}, num_child_bus =3D 0, instance_id_alias =3D -1,=20 alias_required_for_version =3D 0} This is right before object_unparent().