qemu/include/hw
Paul Durrant 3809f7583b xen: perform XenDevice clean-up in XenBus watch handler
Cleaning up offline XenDevice objects directly in
xen_device_backend_changed() is dangerous as xen_device_unrealize() will
modify the watch list that is being walked. Even the QLIST_FOREACH_SAFE()
used in notifier_list_notify() is insufficient as *two* notifiers (for
the frontend and backend watches) are removed, thus potentially rendering
the 'next' pointer unsafe.

The solution is to use the XenBus backend_watch handler to do the clean-up
instead, as it is invoked whilst walking a separate watch list.

This patch therefore adds a new 'inactive_devices' list to XenBus, to which
offline devices are added by xen_device_backend_changed(). The XenBus
backend_watch registration is also changed to not only invoke
xen_bus_enumerate() but also a new xen_bus_cleanup() function, which will
walk 'inactive_devices' and perform the necessary actions.
For safety an extra 'online' check is also added to xen_bus_type_enumerate()
to make sure that no attempt is made to create a new XenDevice object for a
backend that is offline.

NOTE: This patch also includes some cosmetic changes:
      - substitute the local variable name 'backend_state'
        in xen_bus_type_enumerate() with 'state', since there
        is no ambiguity with any other state in that context.
      - change xen_device_state_is_active() to
        xen_device_frontend_is_active() (and pass a XenDevice directly)
        since the state tests contained therein only apply to a frontend.
      - use 'state' rather then 'xendev->backend_state' in
        xen_device_backend_changed() to shorten the code.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Message-Id: <20190913082159.31338-4-paul.durrant@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
2019-09-24 12:18:47 +01:00
..
acpi ipmi: Fix SSIF ACPI handling to use the right CRS 2019-09-20 14:08:10 -05:00
adc include: Make headers more self-contained 2019-08-16 13:31:51 +02:00
arm aspeed: Use consistent typenames 2019-09-13 16:05:01 +01:00
audio Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
block Include exec/memory.h slightly less 2019-08-16 13:31:52 +02:00
char escc: introduce a selector for the register bit 2019-09-07 08:32:12 +02:00
core exec: Factor out cpu_watchpoint_address_matches 2019-09-03 08:30:39 -07:00
cpu Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
cris Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
display Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
dma Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
firmware machine: Refactor smp-related call chains to pass MachineState 2019-07-05 17:07:36 -03:00
gpio hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500 2019-09-13 16:05:00 +01:00
hyperv hyperv: process POST_MESSAGE hypercall 2018-10-19 13:44:14 +02:00
i2c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
i386 pc: Add an SMB0 ACPI device to q35 2019-09-20 14:09:24 -05:00
ide sysemu: Move the VMChangeStateEntry typedef to qemu/typedefs.h 2019-08-16 13:31:53 +02:00
input Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
intc include: Make headers more self-contained 2019-08-16 13:31:51 +02:00
ipack Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
ipmi ipmi: Allow a size value to be passed for I/O space 2019-09-20 14:08:10 -05:00
isa Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
kvm Supply missing header guards 2019-06-12 13:20:21 +02:00
lm32 Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
m68k m68k: Add NeXTcube machine 2019-09-07 08:31:51 +02:00
mem Include sysemu/hostmem.h less 2019-08-16 13:31:53 +02:00
mips Include hw/irq.h a lot less 2019-08-16 13:31:52 +02:00
misc aspeed/scu: Introduce a aspeed_scu_get_apb_freq() routine 2019-09-13 16:05:01 +01:00
net Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
nvram include: Make headers more self-contained 2019-08-16 13:31:51 +02:00
pci ipmi: Add PCI IPMI interfaces 2019-09-20 14:08:10 -05:00
pci-bridge Supply missing header guards 2019-06-12 13:20:21 +02:00
pci-host spapr/pci: Convert types to QEMU coding style 2019-08-29 09:46:07 +10:00
ppc spapr_pci: Advertise BAR reallocation capability 2019-08-29 09:46:07 +10:00
rdma {hmp, hw/pvrdma}: Expose device internals via monitor interface 2019-03-16 15:52:44 +02:00
riscv riscv: sifive_u: Remove handcrafted clock nodes for UART and ethernet 2019-09-17 08:42:49 -07:00
s390x Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
scsi sysemu: Move the VMChangeStateEntry typedef to qemu/typedefs.h 2019-08-16 13:31:53 +02:00
sd Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
semihosting include: Make headers more self-contained 2019-08-16 13:31:51 +02:00
sh4 Include hw/irq.h a lot less 2019-08-16 13:31:52 +02:00
sparc Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
ssi aspeed/smc: Inject errors in DMA checksum 2019-09-13 16:05:01 +01:00
timer Clean up inclusion of sysemu/sysemu.h 2019-08-16 13:31:53 +02:00
tricore Include hw/irq.h a lot less 2019-08-16 13:31:52 +02:00
unicore32 hw/unicore32: restrict hw addr defines to source file 2017-12-18 17:07:02 +03:00
usb usb: Add basic code to emulate Chipidea USB IP 2018-02-09 10:40:30 +00:00
vfio Include hw/irq.h a lot less 2019-08-16 13:31:52 +02:00
virtio virtio-rng: Keep the default backend out of VirtIORNGConf 2019-09-04 06:32:51 -04:00
watchdog Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
xen xen: perform XenDevice clean-up in XenBus watch handler 2019-09-24 12:18:47 +01:00
xtensa Include hw/irq.h a lot less 2019-08-16 13:31:52 +02:00
boards.h qdev/machine: Introduce hotplug_allowed hook 2019-09-16 06:57:24 -04:00
bt.h Include hw/irq.h a lot less 2019-08-16 13:31:52 +02:00
elf_ops.h elf-ops.h: fix int overflow in load_elf() 2019-09-16 12:32:21 +02:00
empty_slot.h include: Make headers more self-contained 2019-08-16 13:31:51 +02:00
fw-path-provider.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
hotplug.h qom: make interface types abstract 2018-12-11 15:45:22 -02:00
hw.h Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
ide.h ide/via: Rename functions to match device name 2019-01-25 14:52:12 -05:00
irq.h Include hw/irq.h a lot less 2019-08-16 13:31:52 +02:00
loader-fit.h Use #include "..." for our own headers, <...> for others 2018-02-09 05:05:11 +01:00
loader.h elf-ops.h: fix int overflow in load_elf() 2019-09-16 12:32:21 +02:00
nmi.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
or-irq.h Include hw/irq.h a lot less 2019-08-16 13:31:52 +02:00
pcmcia.h Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
platform-bus.h platform-bus-device: use device plug callback instead of machine_done notifier 2018-05-10 18:10:56 +01:00
ptimer.h Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
qdev-core.h qdev/machine: Introduce hotplug_allowed hook 2019-09-16 06:57:24 -04:00
qdev-dma.h Supply missing header guards 2019-06-12 13:20:21 +02:00
qdev-properties.h qdev: Add a no default uuid property 2019-09-20 14:09:02 -05:00
register.h hw: register: Run post_write hook on reset 2018-03-01 11:05:43 +00:00
registerfields.h Use #include "..." for our own headers, <...> for others 2018-02-09 05:05:11 +01:00
stream.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
sysbus.h Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
usb.h Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00