qemu-patch-raspberry4/hw/core
Thomas Huth 03fcbd9dc5 qdev: Check for the availability of a hotplug controller before adding a device
The qdev_unplug() function contains a g_assert(hotplug_ctrl) statement,
so QEMU crashes when the user tries to device_add + device_del a device
that does not have a corresponding hotplug controller. This could be
provoked for a couple of devices in the past (see commit 4c93950659
or 84ebd3e8c7 for example), and can currently for example also be
triggered like this:

$ s390x-softmmu/qemu-system-s390x -M none -nographic
QEMU 2.10.50 monitor - type 'help' for more information
(qemu) device_add qemu-s390x-cpu,id=x
(qemu) device_del x
**
ERROR:qemu/qdev-monitor.c:872:qdev_unplug: assertion failed: (hotplug_ctrl)
Aborted (core dumped)

So devices clearly need a hotplug controller when they should be usable
with device_add.
The code in qdev_device_add() already checks whether the bus has a proper
hotplug controller, but for devices that do not have a corresponding bus,
there is no appropriate check available yet. In that case we should check
whether the machine itself provides a suitable hotplug controller and
refuse to plug the device if none is available.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1509617407-21191-3-git-send-email-thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2018-01-19 11:18:51 -02:00
..
bus.c bus: do not unref hotplug handler 2017-03-01 11:51:28 +04:00
empty_slot.c hw/core: Clean up includes 2016-01-29 15:07:25 +00:00
fw-path-provider.c hw/core: Clean up includes 2016-01-29 15:07:25 +00:00
generic-loader.c hw/core/generic-loader: Fix crash when running without CPU 2017-05-10 10:19:23 +03:00
hotplug.c qdev: hotplug: drop HotplugHandler.post_plug callback 2016-11-15 17:20:37 +02:00
irq.c tcg: drop global lock during TCG code execution 2017-02-24 10:32:45 +00:00
loader-fit.c loader: Support Flattened Image Trees (FIT images) 2017-02-21 23:47:40 +00:00
loader.c fw_cfg: add write callback 2017-10-15 05:54:40 +03:00
machine.c machine: Replace has_dynamic_sysbus with list of allowed devices 2018-01-19 11:18:51 -02:00
Makefile.objs hw/core: nmi.c can be compiled as common-obj nowadays 2017-06-05 17:23:36 +03:00
nmi.c nmi: remove x86 specific nmi handling 2016-05-23 16:53:46 +02:00
null-machine.c hw/core/null-machine: Print error message when using the -kernel parameter 2017-04-20 15:22:41 -03:00
or-irq.c qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable 2017-05-17 10:37:00 -03:00
platform-bus.c platform-bus: use get_uint() for "addr" property 2017-06-20 14:31:32 +02:00
ptimer.c qemu-timer: do not include sysemu/cpus.h from util/qemu-timer.h 2017-03-14 13:28:18 +01:00
qdev-properties-system.c Pull request 2017-12-20 11:30:55 +00:00
qdev-properties.c qdev-properties: add UUID property type 2017-12-05 19:13:45 +02:00
qdev.c qdev: Check for the availability of a hotplug controller before adding a device 2018-01-19 11:18:51 -02:00
register.c register: display register prefix (name) since it is available 2017-06-04 18:42:55 +03:00
reset.c hw: move reset handlers from vl.c to hw/core 2017-01-16 17:52:35 +01:00
stream.c hw/core: Clean up includes 2016-01-29 15:07:25 +00:00
sysbus.c sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE 2017-05-17 10:37:01 -03:00
uboot_image.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00