qemu-e2k/hw
Markus Armbruster 3a55fc0f24 ivshmem: Receive shared memory synchronously in realize()
When configured for interrupts (property "chardev" given), we receive
the shared memory from an ivshmem server.  We do so asynchronously
after realize() completes, by setting up callbacks with
qemu_chr_add_handlers().

Keeping server I/O out of realize() that way avoids delays due to a
slow server.  This is probably relevant only for hot plug.

However, this funny "no shared memory, yet" state of the device also
causes a raft of issues that are hard or impossible to work around:

* The guest is exposed to this state: when we enter and leave it its
  shared memory contents is apruptly replaced, and device register
  IVPosition changes.

  This is a known issue.  We document that guests should not access
  the shared memory after device initialization until the IVPosition
  register becomes non-negative.

  For cold plug, the funny state is unlikely to be visible in
  practice, because we normally receive the shared memory long before
  the guest gets around to mess with the device.

  For hot plug, the timing is tighter, but the relative slowness of
  PCI device configuration has a good chance to hide the funny state.

  In either case, guests complying with the documented procedure are
  safe.

* Migration becomes racy.

  If migration completes before the shared memory setup completes on
  the source, shared memory contents is silently lost.  Fortunately,
  migration is rather unlikely to win this race.

  If the shared memory's ramblock arrives at the destination before
  shared memory setup completes, migration fails.

  There is no known way for a management application to wait for
  shared memory setup to complete.

  All you can do is retry failed migration.  You can improve your
  chances by leaving more time between running the destination QEMU
  and the migrate command.

  To mitigate silent memory loss, you need to ensure the server
  initializes shared memory exactly the same on source and
  destination.

  These issues are entirely undocumented so far.

I'd expect the server to be almost always fast enough to hide these
issues.  But then rare catastrophic races are in a way the worst kind.

This is way more trouble than I'm willing to take from any device.
Kill the funny state by receiving shared memory synchronously in
realize().  If your hot plug hangs, go kill your ivshmem server.

For easier review, this commit only makes the receive synchronous, it
doesn't add the necessary error propagation.  Without that, the funny
state persists.  The next commit will do that, and kill it off for
real.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1458066895-20632-26-git-send-email-armbru@redhat.com>
2016-03-21 21:29:01 +01:00
..
9pfs all: Clean up includes 2016-02-23 12:43:05 +00:00
acpi module: Rename machine_init() to opts_init() 2016-03-16 15:54:23 -03:00
alpha loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
arm machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
audio all: Clean up includes 2016-02-23 12:43:05 +00:00
block blockdev: Split monitor reference from BB creation 2016-03-17 15:47:56 +01:00
bt hw: Clean up includes 2016-01-29 15:07:25 +00:00
char bcm2835_aux: add emulation of BCM2835 AUX (aka UART1) block 2016-03-16 17:42:18 +00:00
core loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
cpu hw/intc/arm_gic.c: Implement GICv2 GICC_DIR 2016-03-04 11:30:22 +00:00
cris loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
display bcm2835_fb: add framebuffer device for Raspberry Pi 2016-03-16 17:42:18 +00:00
dma bcm2835_dma: add emulation of Raspberry Pi DMA controller 2016-03-16 17:42:18 +00:00
gpio ARM: PL061: Checking register r/w accesses to reserved area 2016-02-26 15:09:42 +00:00
i2c i.MX: Add missing descriptions in devices. 2016-03-16 17:42:18 +00:00
i386 kvm: x86: q35: Add support for -machine kernel_irqchip=split for q35 2016-03-15 18:23:33 +01:00
ide ahci: prohibit "restarting" the FIS or CLB engines 2016-02-10 13:29:40 -05:00
input ui: Shorten references into InputEvent 2016-03-05 10:41:55 +01:00
intc hw/intc: Add (new) ASPEED VIC device model 2016-03-16 17:42:18 +00:00
ipack hw: Clean up includes 2016-01-29 15:07:25 +00:00
ipmi ipmi: add some local variables in ipmi_sdr_init 2016-03-11 16:59:13 +02:00
isa ich9lpc: fix typo 2016-03-11 16:45:21 +02:00
lm32 machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
m68k loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
mem pc-dimm: fix error handling in pc_dimm_check_memdev_is_busy() 2016-03-11 14:55:15 +02:00
microblaze loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
mips machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
misc ivshmem: Receive shared memory synchronously in realize() 2016-03-21 21:29:01 +01:00
moxie loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
net i.MX: Add missing descriptions in devices. 2016-03-16 17:42:18 +00:00
nvram fw_cfg: expose control register size in fw_cfg.h 2016-03-08 10:46:30 +01:00
openrisc loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
pci msi_supported -> msi_nonbroken 2016-03-11 16:45:21 +02:00
pci-bridge pxb: cleanup 2016-03-11 16:59:12 +02:00
pci-host loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
pcmcia hw: Clean up includes 2016-01-29 15:07:25 +00:00
ppc machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
s390x machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
scsi scsi-bus: Remove tape command from scsi_req_xfer 2016-03-07 17:56:23 +01:00
sd sd: Fix "info qtree" on boards with SD cards 2016-03-16 17:42:19 +00:00
sh4 sh4: Clean up includes 2016-01-29 15:07:24 +00:00
smbios module: Rename machine_init() to opts_init() 2016-03-16 15:54:23 -03:00
sparc machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
sparc64 machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
ssi hw: Clean up includes 2016-01-29 15:07:25 +00:00
timer hw/timer: Add ASPEED timer device model 2016-03-16 17:42:18 +00:00
tpm hw: Clean up includes 2016-01-29 15:07:25 +00:00
tricore loader: Add data swap option to load-elf 2016-03-04 11:30:21 +00:00
unicore32 unicore: Clean up includes 2016-01-29 15:07:22 +00:00
usb usb-redirect: Avoid double free of data 2016-02-29 11:45:26 +01:00
vfio vfio: Eliminate vfio_container_ioctl() 2016-03-16 09:55:11 +11:00
virtio virtio-pci: call pci reset variant when guest requests reset. 2016-03-11 16:45:21 +02:00
watchdog watchdog/diag288: avoid race condition on expired watchdog 2016-03-01 12:15:28 +01:00
xen xen: drop XenXC and associated interface wrappers 2016-02-10 12:01:24 +00:00
xenpv xen: Clean up includes 2016-01-29 15:07:23 +00:00
xtensa machine: Use type_init() to register machine classes 2016-03-16 15:34:05 -03:00
Makefile.objs Add a base IPMI interface 2015-12-22 18:39:19 +02:00