On Mon, Jul 09, 2018 at 11:03:00PM +0200, Thomas Huth wrote: > When trying to "device_add bcm2837" on a machine that is not suitable for > this device, you can quickly crash QEMU afterwards, e.g. with "info qtree": > > echo "{'execute':'qmp_capabilities'} {'execute':'device_add', " \ > "'arguments':{'driver':'bcm2837'}} {'execute': 'human-monitor-command', " \ > "'arguments': {'command-line': 'info qtree'}}" | \ > aarch64-softmmu/qemu-system-aarch64 -M integratorcp,accel=qtest -S -qmp stdio
Interesting, how did you find this bug? Running "info qtree" and other queries on device-crash-test sounds like a good idea. I will add it to my TODO list. > > {"QMP": {"version": {"qemu": {"micro": 50, "minor": 12, "major": 2}, > "package": "build-all"}, "capabilities": []}} > {"return": {}} > {"error": {"class": "GenericError", "desc": "Device 'bcm2837' can not be > hotplugged on this machine"}} > Segmentation fault (core dumped) > > The problem is that qdev_set_parent_bus() from instance_init adds a link > to the child devices which is not valid anymore after the device init > failed. Thus the qdev_set_parent_bus() must rather be done in the realize > function instead. > > Signed-off-by: Thomas Huth <th...@redhat.com> [...] -- Eduardo