From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkZeh-0001T1-4u for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:32:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkZeb-00083X-S1 for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:32:23 -0400 References: <1444401407-7849-1-git-send-email-armbru@redhat.com> <1444401407-7849-12-git-send-email-armbru@redhat.com> From: =?UTF-8?Q?Andreas_F=c3=a4rber?= Message-ID: <5617DDFB.1070005@suse.de> Date: Fri, 9 Oct 2015 17:32:11 +0200 MIME-Version: 1.0 In-Reply-To: <1444401407-7849-12-git-send-email-armbru@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PULL v3 11/12] qdev: Protect device-list-properties against broken devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: Peter Maydell , Eduardo Habkost , Richard Henderson , Bastian Koppelmann , Anthony Green , Mark Cave-Ayland , Alexander Graf , qemu-stable@nongnu.org, Blue Swirl , Max Filippov , Michael Walle , qemu-ppc@nongnu.org, Paolo Bonzini , "Edgar E. Iglesias" , Guan Xuetao , Leon Alrae , Aurelien Jarno , Jia Liu Am 09.10.2015 um 16:36 schrieb Markus Armbruster: > Several devices don't survive object_unref(object_new(T)): they crash > or hang during cleanup, or they leave dangling pointers behind. >=20 > This breaks at least device-list-properties, because > qmp_device_list_properties() needs to create a device to find its > properties. Broken in commit f4eb32b "qmp: show QOM properties in > device-list-properties", v2.1. Example reproducer: >=20 > $ qemu-system-aarch64 -nodefaults -display none -machine none -S -q= mp stdio > {"QMP": {"version": {"qemu": {"micro": 50, "minor": 4, "major": 2},= "package": ""}, "capabilities": []}} > { "execute": "qmp_capabilities" } > {"return": {}} > { "execute": "device-list-properties", "arguments": { "typename": "= pxa2xx-pcmcia" } } > qemu-system-aarch64: /home/armbru/work/qemu/memory.c:1307: memory_r= egion_finalize: Assertion `((&mr->subregions)->tqh_first =3D=3D ((void *)= 0))' failed. > Aborted (core dumped) > [Exit 134 (SIGABRT)] >=20 > Unfortunately, I can't fix the problems in these devices right now. > Instead, add DeviceClass member cannot_destroy_with_object_finalize_yet > to mark them: >=20 > * Hang during cleanup (didn't debug, so I can't say why): > "realview_pci", "versatile_pci". >=20 > * Dangling pointer in cpus: most CPUs, plus "allwinner-a10", "digic", > "fsl,imx25", "fsl,imx31", "xlnx,zynqmp", because they create such > CPUs >=20 > * Assert kvm_enabled(): "host-x86_64-cpu", host-i386-cpu", > "host-powerpc64-cpu", "host-embedded-powerpc-cpu", > "host-powerpc-cpu" (the powerpc ones can't currently reach the > assertion, because the CPUs are only registered when KVM is enabled, > but the assertion is arguably in the wrong place all the same) >=20 > Make qmp_device_list_properties() fail cleanly when the device is so > marked. This improves device-list-properties from "crashes, hangs or > leaves dangling pointers behind" to "fails". Not a complete fix, just > a better-than-nothing work-around. In the above reproducer, > device-list-properties now fails with "Can't list properties of device > 'pxa2xx-pcmcia'". >=20 > This also protects -device FOO,help, which uses the same machinery > since commit ef52358 "qdev-monitor: include QOM properties in -device > FOO, help output", v2.2. Example reproducer: >=20 > $ qemu-system-aarch64 -machine none -device pxa2xx-pcmcia,help >=20 > Before: >=20 > qemu-system-aarch64: .../memory.c:1307: memory_region_finalize: Ass= ertion `((&mr->subregions)->tqh_first =3D=3D ((void *)0))' failed. >=20 > After: >=20 > Can't list properties of device 'pxa2xx-pcmcia' >=20 > Cc: "Andreas F=C3=A4rber" In case a v4 comes up, ;) Acked-by: Andreas F=C3=A4rber Thanks for updating, Andreas --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Felix Imend=C3=B6rffer, Jane Smithard, Graham Norton; HRB 21284 (AG N= =C3=BCrnberg)