hw/misc/macio: Fix crash when listing device properties of macio device
authorThomas Huth <thuth@redhat.com>
Mon, 19 Mar 2018 14:00:46 +0000 (15:00 +0100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 10 Apr 2018 00:05:38 +0000 (10:05 +1000)
commitddd835f32a18c087d3161213f47e89566ce05cc8
tree4d21dc9f327db3f9fc26adcf1bea67aa1eece449
parente69ba2b489d9cc6e976a29a58726d45361d85b9d
hw/misc/macio: Fix crash when listing device properties of macio device

The macio-newworld device can currently be used to abort QEMU unexpectedly:

$ ppc-softmmu/qemu-system-ppc -S -M ref405ep,accel=qtest -qmp stdio
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 11, "major": 2},
 "package": "build-all"}, "capabilities": []}}
{ 'execute': 'qmp_capabilities' }
{"return": {}}
{ 'execute': 'device-list-properties',
  'arguments': {'typename': 'macio-newworld'}}
Unexpected error in qemu_chr_fe_init() at chardev/char-fe.c:222:
Device 'serial0' is in use
Aborted (core dumped)

qdev properties should be set during realize(), not during instance_init(),
so move the related code there to fix this problem.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/misc/macio/macio.c