block: introduce block job error

The following behaviors are possible:

'report': The behavior is the same as in 1.1.  An I/O error,
respectively during a read or a write, will complete the job immediately
with an error code.

'ignore': An I/O error, respectively during a read or a write, will be
ignored.  For streaming, the job will complete with an error and the
backing file will be left in place.  For mirroring, the sector will be
marked again as dirty and re-examined later.

'stop': The job will be paused and the job iostatus will be set to
failed or nospace, while the VM will keep running.  This can only be
specified if the block device has rerror=stop and werror=stop or enospc.

'enospc': Behaves as 'stop' for ENOSPC errors, 'report' for others.

In all cases, even for 'report', the I/O error is reported as a QMP
event BLOCK_JOB_ERROR, with the same arguments as BLOCK_IO_ERROR.

It is possible that while stopping the VM a BLOCK_IO_ERROR event will be
reported and will clobber the event from BLOCK_JOB_ERROR, or vice versa.
This is not really avoidable since stopping the VM completes all pending
I/O requests.  In fact, it is already possible now that a series of
BLOCK_IO_ERROR events are reported with rerror=stop, because vm_stop
calls bdrv_drain_all and this can generate further errors.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 files changed
tree: 69270e827b26d7735a605626e58fea479b16a219
  1. audio/
  2. block/
  3. bsd-user/
  4. default-configs/
  5. docs/
  6. fpu/
  7. fsdev/
  8. gdb-xml/
  9. hw/
  10. include/
  11. libcacard/
  12. linux-headers/
  13. linux-user/
  14. net/
  15. pc-bios/
  16. qapi/
  17. qga/
  18. QMP/
  19. qom/
  20. roms/
  21. scripts/
  22. slirp/
  23. sysconfigs/
  24. target-alpha/
  25. target-arm/
  26. target-cris/
  27. target-i386/
  28. target-lm32/
  29. target-m68k/
  30. target-microblaze/
  31. target-mips/
  32. target-openrisc/
  33. target-ppc/
  34. target-s390x/
  35. target-sh4/
  36. target-sparc/
  37. target-unicore32/
  38. target-xtensa/
  39. tcg/
  40. tests/
  41. trace/
  42. ui/
  43. .exrc
  44. .gitignore
  45. .gitmodules
  46. .mailmap
  47. a.out.h
  48. acl.c
  49. acl.h
  50. aes.c
  51. aes.h
  52. aio.c
  53. alpha-dis.c
  54. alpha.ld
  55. arch_init.c
  56. arch_init.h
  57. arm-dis.c
  58. arm.ld
  59. async.c
  60. balloon.c
  61. balloon.h
  62. bitmap.c
  63. bitmap.h
  64. bitops.c
  65. bitops.h
  66. block-migration.c
  67. block-migration.h
  68. block.c
  69. block.h
  70. block_int.h
  71. blockdev.c
  72. blockdev.h
  73. blockjob.c
  74. blockjob.h
  75. bswap.h
  76. bt-host.c
  77. bt-host.h
  78. bt-vhci.c
  79. buffered_file.c
  80. buffered_file.h
  81. cache-utils.c
  82. cache-utils.h
  83. Changelog
  84. cmd.c
  85. cmd.h
  86. CODING_STYLE
  87. compatfd.c
  88. compatfd.h
  89. compiler.h
  90. config.h
  91. configure
  92. console.c
  93. console.h
  94. COPYING
  95. COPYING.LIB
  96. coroutine-gthread.c
  97. coroutine-sigaltstack.c
  98. coroutine-ucontext.c
  99. coroutine-win32.c
  100. cpu-all.h
  101. cpu-common.h
  102. cpu-defs.h
  103. cpu-exec.c
  104. cpus.c
  105. cpus.h
  106. cputlb.c
  107. cputlb.h
  108. cris-dis.c
  109. cursor.c
  110. cursor_hidden.xpm
  111. cursor_left_ptr.xpm
  112. cutils.c
  113. def-helper.h
  114. device_tree.c
  115. device_tree.h
  116. dis-asm.h
  117. disas.c
  118. disas.h
  119. dma-helpers.c
  120. dma.h
  121. dump-stub.c
  122. dump.c
  123. dump.h
  124. elf.h
  125. envlist.c
  126. envlist.h
  127. error.c
  128. error.h
  129. event_notifier.c
  130. event_notifier.h
  131. exec-all.h
  132. exec-memory.h
  133. exec-obsolete.h
  134. exec.c
  135. gdbstub.c
  136. gdbstub.h
  137. gen-icount.h
  138. HACKING
  139. hmp-commands.hx
  140. hmp.c
  141. hmp.h
  142. host-utils.c
  143. host-utils.h
  144. hppa-dis.c
  145. hppa.ld
  146. i386-dis.c
  147. i386.ld
  148. ia64-dis.c
  149. ia64.ld
  150. input.c
  151. int128.h
  152. iohandler.c
  153. ioport.c
  154. ioport.h
  155. iorange.h
  156. iov.c
  157. iov.h
  158. json-lexer.c
  159. json-lexer.h
  160. json-parser.c
  161. json-parser.h
  162. json-streamer.c
  163. json-streamer.h
  164. kvm-all.c
  165. kvm-stub.c
  166. kvm.h
  167. libfdt_env.h
  168. LICENSE
  169. linux-aio.c
  170. lm32-dis.c
  171. m68k-dis.c
  172. m68k.ld
  173. main-loop.c
  174. main-loop.h
  175. MAINTAINERS
  176. Makefile
  177. Makefile.dis
  178. Makefile.hw
  179. Makefile.objs
  180. Makefile.target
  181. Makefile.user
  182. memory.c
  183. memory.h
  184. memory_mapping-stub.c
  185. memory_mapping.c
  186. memory_mapping.h
  187. microblaze-dis.c
  188. migration-exec.c
  189. migration-fd.c
  190. migration-tcp.c
  191. migration-unix.c
  192. migration.c
  193. migration.h
  194. mips-dis.c
  195. mips.ld
  196. module.c
  197. module.h
  198. monitor.c
  199. monitor.h
  200. nbd.c
  201. nbd.h
  202. net.c
  203. net.h
  204. notify.c
  205. notify.h
  206. os-posix.c
  207. os-win32.c
  208. osdep.c
  209. osdep.h
  210. oslib-posix.c
  211. oslib-win32.c
  212. page_cache.c
  213. path.c
  214. pci-ids.txt
  215. pflib.c
  216. pflib.h
  217. poison.h
  218. posix-aio-compat.c
  219. ppc-dis.c
  220. ppc.ld
  221. ppc64.ld
  222. qapi-schema-guest.json
  223. qapi-schema-test.json
  224. qapi-schema.json
  225. qbool.c
  226. qbool.h
  227. qdict-test-data.txt
  228. qdict.c
  229. qdict.h
  230. qemu-aio.h
  231. qemu-barrier.h
  232. qemu-bridge-helper.c
  233. qemu-char.c
  234. qemu-char.h
  235. qemu-common.h
  236. qemu-config.c
  237. qemu-config.h
  238. qemu-coroutine-int.h
  239. qemu-coroutine-io.c
  240. qemu-coroutine-lock.c
  241. qemu-coroutine-sleep.c
  242. qemu-coroutine.c
  243. qemu-coroutine.h
  244. qemu-doc.texi
  245. qemu-error.c
  246. qemu-error.h
  247. qemu-file.h
  248. qemu-ga.c
  249. qemu-img-cmds.hx
  250. qemu-img.c
  251. qemu-img.texi
  252. qemu-io.c
  253. qemu-lock.h
  254. qemu-log.c
  255. qemu-log.h
  256. qemu-nbd.c
  257. qemu-nbd.texi
  258. qemu-objects.h
  259. qemu-option-internal.h
  260. qemu-option.c
  261. qemu-option.h
  262. qemu-options-wrapper.h
  263. qemu-options.h
  264. qemu-options.hx
  265. qemu-os-posix.h
  266. qemu-os-win32.h
  267. qemu-progress.c
  268. qemu-queue.h
  269. qemu-seccomp.c
  270. qemu-seccomp.h
  271. qemu-sockets.c
  272. qemu-tech.texi
  273. qemu-thread-posix.c
  274. qemu-thread-posix.h
  275. qemu-thread-win32.c
  276. qemu-thread-win32.h
  277. qemu-thread.h
  278. qemu-timer-common.c
  279. qemu-timer.c
  280. qemu-timer.h
  281. qemu-tls.h
  282. qemu-tool.c
  283. qemu-user.c
  284. qemu-x509.h
  285. qemu-xattr.h
  286. qemu.sasl
  287. qemu_socket.h
  288. qerror.c
  289. qerror.h
  290. qfloat.c
  291. qfloat.h
  292. qint.c
  293. qint.h
  294. qjson.c
  295. qjson.h
  296. qlist.c
  297. qlist.h
  298. qmp-commands.hx
  299. qmp.c
  300. qobject.h
  301. qstring.c
  302. qstring.h
  303. qtest.c
  304. qtest.h
  305. range.h
  306. readline.c
  307. readline.h
  308. README
  309. rules.mak
  310. s390-dis.c
  311. s390.ld
  312. savevm.c
  313. sh4-dis.c
  314. softmmu-semi.h
  315. softmmu_defs.h
  316. softmmu_exec.h
  317. softmmu_header.h
  318. softmmu_template.h
  319. sparc-dis.c
  320. sparc.ld
  321. sparc64.ld
  322. spice-qemu-char.c
  323. sysemu.h
  324. targphys.h
  325. tcg-runtime.c
  326. tci-dis.c
  327. tci.c
  328. thunk.c
  329. thunk.h
  330. TODO
  331. trace-events
  332. translate-all.c
  333. uboot_image.h
  334. uri.c
  335. uri.h
  336. user-exec.c
  337. VERSION
  338. version.rc
  339. vgafont.h
  340. vl.c
  341. vmstate.h
  342. x86_64.ld
  343. xen-all.c
  344. xen-mapcache.c
  345. xen-mapcache.h
  346. xen-stub.c