qcow2: Fix creation of large images

qcow_create2 assumes that the new image will only need one cluster for its
refcount table initially. Obviously that's not true any more when the image is
big enough (exact value depends on the cluster size).

This patch calculates the refcount table size dynamically.

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