qemu/hw
Michael Roth 04162f8f4b qdev: store DeviceState's canonical path to use when unparenting
device_unparent(dev, ...) is called when a device is unparented,
either directly, or as a result of a parent device being
finalized, and handles some final cleanup for the device. Part
of this includes emiting a DEVICE_DELETED QMP event to notify
management, which includes the device's path in the composition
tree as provided by object_get_canonical_path().

object_get_canonical_path() assumes the device is still connected
to the machine/root container, and will assert otherwise, but
in some situations this isn't the case:

If the parent is finalized as a result of object_unparent(), it
will still be attached to the composition tree at the time any
children are unparented as a result of that same call to
object_unparent(). However, in some cases, object_unparent()
will complete without finalizing the parent device, due to
lingering references that won't be released till some time later.
One such example is if the parent has MemoryRegion children (which
take a ref on their parent), who in turn have AddressSpace's (which
take a ref on their regions), since those AddressSpaces get cleaned
up asynchronously by the RCU thread.

In this case qdev:device_unparent() may be called for a child Device
that no longer has a path to the root/machine container, causing
object_get_canonical_path() to assert.

Fix this by storing the canonical path during realize() so the
information will still be available for device_unparent() in such
cases.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20171016222315.407-2-mdroth@linux.vnet.ibm.com>
[Clear dev->canonical_path at the post_realize_fail label, which is
 cleaner.  Suggested by David Gibson. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-10-18 10:34:17 +02:00
..
9pfs 9pfs: check the size of transport buffer before marshaling 2017-09-20 08:48:52 +02:00
acpi tco: add trace events 2017-10-16 18:03:52 +02:00
adc
alpha cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
arm hw/arm/xlnx-zynqmp: Mark the "xlnx, zynqmp" device with user_creatable = false 2017-10-06 16:46:47 +01:00
audio migration: pre_save return int 2017-09-27 11:35:59 +01:00
block hw/block/onenand: Remove dead code block 2017-10-06 16:28:58 +02:00
bt bt: stop the sdp memory allocation craziness 2017-08-01 17:27:33 +02:00
char s390x/3270: handle writes of arbitrary length 2017-10-06 10:53:02 +02:00
core qdev: store DeviceState's canonical path to use when unparenting 2017-10-18 10:34:17 +02:00
cpu cpu: don't allow negative core id 2017-08-02 18:30:13 -03:00
cris cris: replace cpu_cris_init() with cpu_generic_init() 2017-09-01 11:54:24 -03:00
display migration: Route more error paths 2017-09-27 11:44:18 +01:00
dma xilinx_axidma: Convert to DEFINE_PROP_LINK 2017-09-07 13:54:51 +01:00
gpio hw/gpio/omap_gpio.c: Don't use old_mmio 2017-09-21 16:34:27 +01:00
i2c migration: pre_save return int 2017-09-27 11:35:59 +01:00
i386 pc: make sure that plugged CPUs are of the same type 2017-10-12 12:10:38 +02:00
ide ide: support reporting of rotation rate 2017-10-12 12:10:37 +02:00
input virtio-input: send rel-wheel events for wheel buttons 2017-09-29 10:36:33 +02:00
intc nvic: Add missing code for writing SHCSR.HARDFAULTPENDED bit 2017-10-06 16:46:49 +01:00
ipack
ipmi qom: enforce readonly nature of link's check callback 2017-07-14 12:04:42 +02:00
isa hw/isa/pc87312: Mark the device with user_creatable = false 2017-09-26 09:11:23 +03:00
lm32 cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
m68k cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
mem qmp: introduce query-memory-size-summary command 2017-09-14 15:52:10 +01:00
microblaze hw: Use new memory_region_init_{ram, rom, rom_device}() functions 2017-07-14 17:59:42 +01:00
mips mips: replace cpu_mips_init() with cpu_generic_init() 2017-09-21 13:25:37 +01:00
misc macio: use object link between MACIO_IDE and MAC_DBDMA object 2017-09-27 13:05:41 +10:00
moxie cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
net migration: pre_save return int 2017-09-27 11:35:59 +01:00
nios2 nios2: replace cpu_nios2_init() with cpu_generic_init() 2017-09-01 11:54:24 -03:00
nvram pc, pci, virtio: patches queued before 2.10 2017-09-08 16:04:42 +01:00
openrisc cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
pci net: Add SunGEM device emulation as found on Apple UniNorth 2017-09-15 10:29:48 +10:00
pci-bridge hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port 2017-09-08 16:15:17 +03:00
pci-host migration: pre_save return int 2017-09-27 11:35:59 +01:00
pcmcia
ppc Migration pull 2017-09-27 2017-09-27 22:44:51 +01:00
s390x hw/s390x: Mark the "sclpquiesce" device with user_creatable = false 2017-10-06 10:53:02 +02:00
scsi scsi-disk: support reporting of rotation rate 2017-10-12 12:10:37 +02:00
sd hw/sd: fix out-of-bounds check for multi block reads 2017-10-06 16:46:47 +01:00
sh4 cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
smbios stubs: move smbios stubs to hw/smbios 2017-01-16 17:52:35 +01:00
sparc cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
sparc64 sun4u: use sunhme as default on-board NIC 2017-09-21 08:38:42 +01:00
ssi msf2: Add Smartfusion2 SPI controller 2017-09-21 16:36:56 +01:00
timer migration: pre_save return int 2017-09-27 11:35:59 +01:00
tpm
tricore cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
unicore32 cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
usb usb: fix host-stub.c build race 2017-10-05 11:03:25 +02:00
vfio s390x: sort some devices into categories 2017-10-06 10:53:02 +02:00
virtio migration: Route more error paths 2017-09-27 11:44:18 +01:00
watchdog watchdog: Allow setting action on the fly 2017-10-02 13:09:09 +02:00
xen xen/pt: allow QEMU to request MSI unmasking at bind time 2017-09-20 19:05:27 -07:00
xenpv xenfb: remove xen_init_display "temporary" hack 2017-07-07 11:10:03 -07:00
xtensa cpu: make cpu_generic_init() abort QEMU on error 2017-09-19 09:09:32 -03:00
Makefile.objs 9pfs: fix dependencies 2017-08-30 18:23:25 +02:00