add qemu_error() + friends

This patch adds some functions for error reporting to address the
problem that error messages should be routed to different destinations
depending on the context of the caller, i.e. monitor command errors
should go to the monitor, command line errors to stderr.

qemu_error() is a printf-like function to report errors.

qemu_errors_to_file() and qemu_errors_to_mon() switch the destination
for the error message to the specified file or monitor.  When setting a
new destination the old one will be kept.  One can switch back using
qemu_errors_to_previous().  i.e. it works like a stack.

main() calls qemu_errors_to_file(stderr), so errors go to stderr by
default.  monitor callbacks are wrapped into qemu_errors_to_mon() +
qemu_errors_to_previous(), so any errors triggered by monitor commands
will go to the monitor.

Each thread has its own error message destination.  qemu-kvm probably
should add a qemu_errors_to_file(stderr) call to the i/o-thread
initialization code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
3 files changed
tree: 61b23e3a7f491b9f5939f03ab77527e9183be0cb
  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. envlist.c
  80. envlist.h
  81. exec-all.h
  82. exec.c
  83. feature_to_c.sh
  84. gdbstub.c
  85. gdbstub.h
  86. gen-icount.h
  87. host-utils.c
  88. host-utils.h
  89. hostregs_helper.h
  90. hpet.h
  91. hppa-dis.c
  92. hppa.ld
  93. hxtool
  94. i386-dis.c
  95. i386.ld
  96. ia64.ld
  97. ioport-user.c
  98. ioport.c
  99. ioport.h
  100. keymaps.c
  101. keymaps.h
  102. kvm-all.c
  103. kvm.h
  104. libfdt_env.h
  105. LICENSE
  106. linux-aio.c
  107. loader.c
  108. m68k-dis.c
  109. m68k-semi.c
  110. m68k.ld
  111. MAINTAINERS
  112. Makefile
  113. Makefile.hw
  114. Makefile.target
  115. microblaze-dis.c
  116. migration-exec.c
  117. migration-fd.c
  118. migration-tcp.c
  119. migration-unix.c
  120. migration.c
  121. migration.h
  122. mips-dis.c
  123. mips.ld
  124. module.c
  125. module.h
  126. monitor.c
  127. monitor.h
  128. nbd.c
  129. nbd.h
  130. net-checksum.c
  131. net.c
  132. net.h
  133. osdep.c
  134. osdep.h
  135. path.c
  136. pci-ids.txt
  137. posix-aio-compat.c
  138. ppc-dis.c
  139. ppc.ld
  140. ppc64.ld
  141. qemu-aio.h
  142. qemu-binfmt-conf.sh
  143. qemu-char.c
  144. qemu-char.h
  145. qemu-common.h
  146. qemu-config.c
  147. qemu-config.h
  148. qemu-doc.texi
  149. qemu-img-cmds.hx
  150. qemu-img.c
  151. qemu-img.texi
  152. qemu-io.c
  153. qemu-lock.h
  154. qemu-log.h
  155. qemu-malloc.c
  156. qemu-monitor.hx
  157. qemu-nbd.c
  158. qemu-nbd.texi
  159. qemu-option.c
  160. qemu-option.h
  161. qemu-options.hx
  162. qemu-sockets.c
  163. qemu-tech.texi
  164. qemu-thread.c
  165. qemu-thread.h
  166. qemu-timer.h
  167. qemu-tool.c
  168. qemu.sasl
  169. qemu_socket.h
  170. readline.c
  171. readline.h
  172. README
  173. rules.mak
  174. s390-dis.c
  175. s390.ld
  176. savevm.c
  177. sdl.c
  178. sdl_keysym.h
  179. sdl_zoom.c
  180. sdl_zoom.h
  181. sdl_zoom_template.h
  182. sh4-dis.c
  183. softmmu-semi.h
  184. softmmu_defs.h
  185. softmmu_exec.h
  186. softmmu_header.h
  187. softmmu_template.h
  188. sparc-dis.c
  189. sparc.ld
  190. sparc64.ld
  191. sys-queue.h
  192. sysemu.h
  193. tap-win32.c
  194. targphys.h
  195. texi2pod.pl
  196. thunk.c
  197. thunk.h
  198. TODO
  199. translate-all.c
  200. uboot_image.h
  201. usb-bsd.c
  202. usb-linux.c
  203. usb-stub.c
  204. VERSION
  205. vgafont.h
  206. vl.c
  207. vnc-auth-sasl.c
  208. vnc-auth-sasl.h
  209. vnc-auth-vencrypt.c
  210. vnc-auth-vencrypt.h
  211. vnc-tls.c
  212. vnc-tls.h
  213. vnc.c
  214. vnc.h
  215. vnc_keysym.h
  216. vnchextile.h
  217. x86_64.ld
  218. x_keymap.c
  219. x_keymap.h