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