Added readonly flag to -drive command

This is a slightly revised patch for adding readonly flag to the -drive command.
Even though this patch is "stand-alone", it assumes a previous related patch (in Anthony staging tree), that passes
the readonly attribute of the drive to the guest OS, applied first.

This enables sharing same image between guests, with readonly access.
Implementaion mark the drive as read_only and changes the flags when actually opening the file.
The readonly attribute of a qcow also passed to it's base file.
For ide that cannot pass the readonly attribute to the guest OS, disallow the readonly flag.

Also, return error code from bdrv_truncate for readonly drive.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
4 files changed
tree: feff1eaf42f55486ef2a9fb6573191dbc5001c83
  1. audio/
  2. block/
  3. bsd-user/
  4. darwin-user/
  5. default-configs/
  6. fpu/
  7. gdb-xml/
  8. hw/
  9. linux-user/
  10. net/
  11. pc-bios/
  12. roms/
  13. slirp/
  14. target-alpha/
  15. target-arm/
  16. target-cris/
  17. target-i386/
  18. target-m68k/
  19. target-microblaze/
  20. target-mips/
  21. target-ppc/
  22. target-sh4/
  23. target-sparc/
  24. tcg/
  25. tests/
  26. .gitignore
  27. .gitmodules
  28. a.out.h
  29. acl.c
  30. acl.h
  31. aes.c
  32. aes.h
  33. aio.c
  34. alpha-dis.c
  35. alpha.ld
  36. arm-dis.c
  37. arm-semi.c
  38. arm.ld
  39. async.c
  40. balloon.h
  41. block.c
  42. block.h
  43. block_int.h
  44. bswap.h
  45. bt-host.c
  46. bt-host.h
  47. bt-vhci.c
  48. buffered_file.c
  49. buffered_file.h
  50. cache-utils.c
  51. cache-utils.h
  52. Changelog
  53. check-qdict.c
  54. check-qint.c
  55. check-qlist.c
  56. check-qstring.c
  57. cmd.c
  58. cmd.h
  59. cocoa.m
  60. CODING_STYLE
  61. config.h
  62. configure
  63. console.c
  64. console.h
  65. COPYING
  66. COPYING.LIB
  67. cpu-all.h
  68. cpu-common.h
  69. cpu-defs.h
  70. cpu-exec.c
  71. create_config
  72. cris-dis.c
  73. curses.c
  74. curses_keys.h
  75. cutils.c
  76. d3des.c
  77. d3des.h
  78. def-helper.h
  79. device_tree.c
  80. device_tree.h
  81. dis-asm.h
  82. disas.c
  83. disas.h
  84. dma-helpers.c
  85. dma.h
  86. dyngen-exec.h
  87. elf.h
  88. envlist.c
  89. envlist.h
  90. exec-all.h
  91. exec.c
  92. feature_to_c.sh
  93. gdbstub.c
  94. gdbstub.h
  95. gen-icount.h
  96. host-utils.c
  97. host-utils.h
  98. hostregs_helper.h
  99. hpet.h
  100. hppa-dis.c
  101. hppa.ld
  102. hxtool
  103. i386-dis.c
  104. i386.ld
  105. ia64.ld
  106. ioport-user.c
  107. ioport.c
  108. ioport.h
  109. keymaps.c
  110. keymaps.h
  111. kvm-all.c
  112. kvm.h
  113. libfdt_env.h
  114. LICENSE
  115. linux-aio.c
  116. m68k-dis.c
  117. m68k-semi.c
  118. m68k.ld
  119. MAINTAINERS
  120. Makefile
  121. Makefile.hw
  122. Makefile.target
  123. Makefile.user
  124. microblaze-dis.c
  125. migration-exec.c
  126. migration-fd.c
  127. migration-tcp.c
  128. migration-unix.c
  129. migration.c
  130. migration.h
  131. mips-dis.c
  132. mips.ld
  133. module.c
  134. module.h
  135. monitor.c
  136. monitor.h
  137. nbd.c
  138. nbd.h
  139. net-checksum.c
  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. targphys.h
  213. tcg-runtime.c
  214. texi2pod.pl
  215. thunk.c
  216. thunk.h
  217. TODO
  218. translate-all.c
  219. uboot_image.h
  220. usb-bsd.c
  221. usb-linux.c
  222. usb-stub.c
  223. VERSION
  224. vgafont.h
  225. vl.c
  226. vnc-auth-sasl.c
  227. vnc-auth-sasl.h
  228. vnc-auth-vencrypt.c
  229. vnc-auth-vencrypt.h
  230. vnc-tls.c
  231. vnc-tls.h
  232. vnc.c
  233. vnc.h
  234. vnc_keysym.h
  235. vnchextile.h
  236. x86_64.ld
  237. x_keymap.c
  238. x_keymap.h