qcow2: Bring synchronous read/write back to life

When the synchronous read and write functions were dropped, they were replaced
by generic emulation functions. Unfortunately, these emulation functions don't
provide the same semantics as the original functions did.

The original bdrv_read would mean that we read some data synchronously and that
we won't be interrupted during this read. The latter assumption is no longer
true with the emulation function which needs to use qemu_aio_poll and therefore
allows the callback of any other concurrent AIO request to be run during the
read. Which in turn means that (meta)data read earlier could have changed and
be invalid now. qcow2 is not prepared to work in this way and it's just scary
how many places there are where other requests could run.

I'm not sure yet where exactly it breaks, but you'll see breakage with virtio
on qcow2 with a backing file. Providing synchronous functions again fixes the
problem for me.

Patchworks-ID: 35437
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit ef845c3bf421290153154635dc18eaa677cecb43)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
3 files changed
tree: eb72c9f023390352184a981fb23df34234e2a6e5
  1. audio/
  2. block/
  3. bsd-user/
  4. darwin-user/
  5. fpu/
  6. gdb-xml/
  7. hw/
  8. linux-user/
  9. pc-bios/
  10. slirp/
  11. target-alpha/
  12. target-arm/
  13. target-cris/
  14. target-i386/
  15. target-m68k/
  16. target-microblaze/
  17. target-mips/
  18. target-ppc/
  19. target-sh4/
  20. target-sparc/
  21. tcg/
  22. tests/
  23. .gitignore
  24. a.out.h
  25. acl.c
  26. acl.h
  27. aes.c
  28. aes.h
  29. aio.c
  30. alpha-dis.c
  31. alpha.ld
  32. arm-dis.c
  33. arm-semi.c
  34. arm.ld
  35. balloon.h
  36. block.c
  37. block.h
  38. block_int.h
  39. bswap.h
  40. bt-host.c
  41. bt-host.h
  42. bt-vhci.c
  43. buffered_file.c
  44. buffered_file.h
  45. cache-utils.c
  46. cache-utils.h
  47. Changelog
  48. cmd.c
  49. cmd.h
  50. cocoa.m
  51. CODING_STYLE
  52. configure
  53. console.c
  54. console.h
  55. COPYING
  56. COPYING.LIB
  57. cpu-all.h
  58. cpu-common.h
  59. cpu-defs.h
  60. cpu-exec.c
  61. create_config
  62. cris-dis.c
  63. curses.c
  64. curses_keys.h
  65. cutils.c
  66. d3des.c
  67. d3des.h
  68. def-helper.h
  69. device_tree.c
  70. device_tree.h
  71. dis-asm.h
  72. disas.c
  73. disas.h
  74. dma-helpers.c
  75. dma.h
  76. dyngen-exec.h
  77. elf.h
  78. elf_ops.h
  79. exec-all.h
  80. exec.c
  81. feature_to_c.sh
  82. gdbstub.c
  83. gdbstub.h
  84. gen-icount.h
  85. host-utils.c
  86. host-utils.h
  87. hostregs_helper.h
  88. hpet.h
  89. hppa-dis.c
  90. hppa.ld
  91. hxtool
  92. i386-dis.c
  93. i386.ld
  94. ia64.ld
  95. ioport-user.c
  96. ioport.c
  97. ioport.h
  98. keymaps.c
  99. keymaps.h
  100. kqemu.c
  101. kqemu.h
  102. kvm-all.c
  103. kvm.h
  104. libfdt_env.h
  105. LICENSE
  106. loader.c
  107. m68k-dis.c
  108. m68k-semi.c
  109. m68k.ld
  110. MAINTAINERS
  111. Makefile
  112. Makefile.hw
  113. Makefile.target
  114. microblaze-dis.c
  115. migration-exec.c
  116. migration-tcp.c
  117. migration.c
  118. migration.h
  119. mips-dis.c
  120. mips.ld
  121. mipsel.ld
  122. module.c
  123. module.h
  124. monitor.c
  125. monitor.h
  126. nbd.c
  127. nbd.h
  128. net-checksum.c
  129. net.c
  130. net.h
  131. osdep.c
  132. osdep.h
  133. pci-ids.txt
  134. posix-aio-compat.c
  135. posix-aio-compat.h
  136. ppc-dis.c
  137. ppc.ld
  138. ppc64.ld
  139. qemu-aio.h
  140. qemu-binfmt-conf.sh
  141. qemu-char.c
  142. qemu-char.h
  143. qemu-common.h
  144. qemu-doc.texi
  145. qemu-img-cmds.hx
  146. qemu-img.c
  147. qemu-img.texi
  148. qemu-io.c
  149. qemu-lock.h
  150. qemu-log.h
  151. qemu-malloc.c
  152. qemu-monitor.hx
  153. qemu-nbd.c
  154. qemu-nbd.texi
  155. qemu-option.c
  156. qemu-option.h
  157. qemu-options.hx
  158. qemu-sockets.c
  159. qemu-tech.texi
  160. qemu-thread.c
  161. qemu-thread.h
  162. qemu-timer.h
  163. qemu-tool.c
  164. qemu.sasl
  165. qemu_socket.h
  166. readline.c
  167. readline.h
  168. README
  169. rules.mak
  170. s390-dis.c
  171. s390.ld
  172. savevm.c
  173. sdl.c
  174. sdl_keysym.h
  175. sdl_zoom.c
  176. sdl_zoom.h
  177. sdl_zoom_template.h
  178. sh4-dis.c
  179. softmmu-semi.h
  180. softmmu_defs.h
  181. softmmu_exec.h
  182. softmmu_header.h
  183. softmmu_template.h
  184. sparc-dis.c
  185. sparc.ld
  186. sparc64.ld
  187. sys-queue.h
  188. sysemu.h
  189. tap-win32.c
  190. targphys.h
  191. texi2pod.pl
  192. thunk.c
  193. thunk.h
  194. TODO
  195. tool-osdep.c
  196. translate-all.c
  197. uboot_image.h
  198. usb-bsd.c
  199. usb-linux.c
  200. usb-stub.c
  201. VERSION
  202. vgafont.h
  203. vl.c
  204. vnc-auth-sasl.c
  205. vnc-auth-sasl.h
  206. vnc-auth-vencrypt.c
  207. vnc-auth-vencrypt.h
  208. vnc-tls.c
  209. vnc-tls.h
  210. vnc.c
  211. vnc.h
  212. vnc_keysym.h
  213. vnchextile.h
  214. x86_64.ld
  215. x_keymap.c
  216. x_keymap.h