qemu/tests
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
..
acpi-test-data acpi-test: update UID for GSI links 2016-03-15 23:25:52 +02:00
guest-debug tests/guest-debug: introduce basic gdbstub tests 2015-12-17 13:37:15 +00:00
image-fuzzer tests: Use Python 2.6 "except E as ..." syntax 2016-02-08 17:29:54 +01:00
libqos tests/libqos/pci-pc: Fix qpci_pc_iomap() to map BARs aligned 2016-03-21 21:28:59 +01:00
multiboot tests/multiboot: Add test for modules 2015-01-26 12:22:44 +01:00
qapi-schema qapi: Drop useless 'data' member of unions 2016-03-05 10:42:06 +01:00
qemu-iotests iotests: Test QUORUM_REPORT_BAD in fifo mode 2016-03-17 16:43:30 +01:00
rocker rocker: tests: don't need to specify master/self when setting vlans 2015-07-07 13:13:22 +01:00
tcg maint: remove unused include for signal.h 2015-09-11 10:21:38 +03:00
vmstate-static-checker-data tests: vmstate static checker: add size mismatch inside substructure 2014-06-23 19:14:52 +02:00
.gitignore crypto: add QCryptoSecret object class for password/key handling 2015-12-18 16:25:08 +00:00
ac97-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
ahci-test.c ide: Clean up includes 2016-01-29 15:07:23 +00:00
bios-tables-test.c vhost, virtio, pci, pxe 2016-02-19 10:50:37 +00:00
boot-order-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
boot-sector.c all: Clean up includes 2016-02-23 12:43:05 +00:00
boot-sector.h tests: add pxe e1000 and virtio-pci tests 2016-02-16 12:05:18 +02:00
check-block.sh qemu-iotests: make check-block.sh work on out-of-tree builds 2016-01-07 21:30:16 +01:00
check-qdict.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
check-qfloat.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
check-qint.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
check-qjson.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
check-qlist.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
check-qom-interface.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
check-qom-proplist.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
check-qstring.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
crypto-tls-x509-helpers.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
crypto-tls-x509-helpers.h crypto: add sanity checking of TLS x509 credentials 2015-09-15 15:05:09 +01:00
device-introspect-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
display-vga-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
drive_del-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
ds1338-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
e1000-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
eepro100-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
endianness-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
es1370-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
fdc-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
fw_cfg-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
hd-geo-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
i440fx-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
i82801b11-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
ide-test.c ide: Clean up includes 2016-01-29 15:07:23 +00:00
intel-hda-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
io-channel-helpers.c io: assert errors before asserting content in I/O test 2016-03-10 17:10:18 +00:00
io-channel-helpers.h io: add QIOChannelSocket class 2015-12-18 12:18:31 +00:00
ioh3420-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
ipmi-bt-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
ipmi-kcs-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
ipoctal232-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
ivshmem-test.c ivshmem: Receive shared memory synchronously in realize() 2016-03-21 21:29:01 +01:00
libqtest.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
libqtest.h all: Clean up includes 2016-02-23 12:43:05 +00:00
m48t59-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
Makefile event_notifier: Make event_notifier_init_fd() #ifdef CONFIG_EVENTFD 2016-03-21 21:28:59 +01:00
ne2000-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
nvme-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
pc-cpu-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
pcnet-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
pkix_asn1_tab.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
pvpanic-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
pxe-test.c all: Clean up includes 2016-02-23 12:43:05 +00:00
q35-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
qemu-iotests-quick.sh qemu-iotests: Speed up make check-block 2015-01-13 11:47:55 +00:00
qom-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
rcutorture.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
rtc-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
rtl8139-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
spapr-phb-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
tco-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-aio.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-base64.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-bitops.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-blockjob-txn.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-coroutine.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-crypto-cipher.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-crypto-hash.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-crypto-secret.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-crypto-tlscredsx509.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-crypto-tlssession.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-cutils.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-hbitmap.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-int128.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-io-channel-buffer.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-io-channel-command.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-io-channel-file.c Merge I/O fixes 2016/02/16 v1 2016-02-16 15:47:35 +00:00
test-io-channel-socket.c io: stronger check for support for IPv4/6 2016-03-15 13:55:52 +00:00
test-io-channel-tls.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-io-task.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-iov.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-mul64.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-netfilter.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-opts-visitor.c qapi-dealloc: Reduce use outside of generated code 2016-03-04 17:16:32 +01:00
test-qdev-global-props.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-qemu-opts.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-qga.c qga: Support enum names in guest-file-seek 2016-02-25 09:48:50 -06:00
test-qmp-commands.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-qmp-event.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-qmp-input-strict.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-qmp-input-visitor.c qapi: Don't box branches of flat unions 2016-02-19 11:08:57 +01:00
test-qmp-output-visitor.c qapi: Don't box branches of flat unions 2016-02-19 11:08:57 +01:00
test-rcu-list.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-rfifolock.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-string-input-visitor.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-string-output-visitor.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-thread-pool.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-throttle.c throttle: Test throttle_compute_wait() during bursts 2016-02-22 14:08:06 +01:00
test-timed-average.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-visitor-serialization.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-vmstate.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-write-threshold.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-x86-cpuid.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
test-xbzrle.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
tmp105-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
tpci200-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
usb-hcd-ehci-test.c usb: Clean up includes 2016-01-29 15:07:23 +00:00
usb-hcd-ohci-test.c usb: Clean up includes 2016-01-29 15:07:23 +00:00
usb-hcd-uhci-test.c usb: Clean up includes 2016-01-29 15:07:23 +00:00
usb-hcd-xhci-test.c usb: Clean up includes 2016-01-29 15:07:23 +00:00
vhost-user-bridge.c tests/vhost-user-bridge: fix build on 32 bit systems 2016-02-25 13:14:19 +02:00
vhost-user-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
virtio-9p-test.c 9pfs: Clean up includes 2016-01-29 15:07:23 +00:00
virtio-balloon-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
virtio-blk-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
virtio-console-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
virtio-net-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
virtio-rng-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
virtio-scsi-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
virtio-serial-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
vmxnet3-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00
wdt_ib700-test.c tests: Clean up includes 2016-02-16 14:29:27 +00:00