qcow2 corruption: Fix alloc_cluster_link_l2 (Kevin Wolf)

This patch fixes a qcow2 corruption bug introduced in SVN Rev 5861. L2 tables
are big endian, so entries must be converted before being passed to functions.

This bug is easy to trigger. The following script will create and destroy a
qcow2 image (the header is gone after three loop iterations):

    #!/bin/bash
    qemu-img create -f qcow2 test.qcow 1M
    for i in $(seq 1 10); do
    qemu-system-x86_64 -hda test.qcow -monitor stdio > /dev/null 2>&1 <<EOF
    savevm test-$i
    quit
    EOF
    done

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7165 c046a42c-6fe2-441c-8c8c-71466251a162
1 file changed
tree: 5c546c61697d72393f4c2286aaf01a326be26d34
  1. audio/
  2. bsd-user/
  3. darwin-user/
  4. fpu/
  5. gdb-xml/
  6. hw/
  7. keymaps/
  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-mips/
  17. target-ppc/
  18. target-sh4/
  19. target-sparc/
  20. tcg/
  21. tests/
  22. .gitignore
  23. a.out.h
  24. acl.c
  25. acl.h
  26. aes.c
  27. aes.h
  28. aio.c
  29. alpha-dis.c
  30. alpha.ld
  31. arm-dis.c
  32. arm-semi.c
  33. arm.ld
  34. balloon.h
  35. block-bochs.c
  36. block-cloop.c
  37. block-cow.c
  38. block-dmg.c
  39. block-nbd.c
  40. block-parallels.c
  41. block-qcow.c
  42. block-qcow2.c
  43. block-raw-posix.c
  44. block-raw-win32.c
  45. block-vmdk.c
  46. block-vpc.c
  47. block-vvfat.c
  48. block.c
  49. block.h
  50. block_int.h
  51. bswap.h
  52. bt-host.c
  53. bt-host.h
  54. bt-vhci.c
  55. buffered_file.c
  56. buffered_file.h
  57. cache-utils.c
  58. cache-utils.h
  59. Changelog
  60. cmd.c
  61. cmd.h
  62. cocoa.m
  63. CODING_STYLE
  64. configure
  65. console.c
  66. console.h
  67. COPYING
  68. COPYING.LIB
  69. cpu-all.h
  70. cpu-defs.h
  71. cpu-exec.c
  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. elf_ops.h
  89. exec-all.h
  90. exec.c
  91. feature_to_c.sh
  92. gdbstub.c
  93. gdbstub.h
  94. gen-icount.h
  95. host-utils.c
  96. host-utils.h
  97. hostregs_helper.h
  98. hpet.h
  99. hppa-dis.c
  100. hppa.ld
  101. hxtool
  102. i386-dis.c
  103. i386.ld
  104. ia64.ld
  105. keymaps.c
  106. keymaps.h
  107. kqemu.c
  108. kqemu.h
  109. kvm-all.c
  110. kvm.h
  111. libfdt_env.h
  112. LICENSE
  113. loader.c
  114. m68k-dis.c
  115. m68k-semi.c
  116. m68k.ld
  117. MAINTAINERS
  118. Makefile
  119. Makefile.target
  120. migration-exec.c
  121. migration-tcp.c
  122. migration.c
  123. migration.h
  124. mips-dis.c
  125. mips.ld
  126. mipsel.ld
  127. monitor.c
  128. monitor.h
  129. nbd.c
  130. nbd.h
  131. net-checksum.c
  132. net.c
  133. net.h
  134. osdep.c
  135. osdep.h
  136. pci-ids.txt
  137. posix-aio-compat.c
  138. posix-aio-compat.h
  139. ppc-dis.c
  140. ppc.ld
  141. ppc64.ld
  142. qemu-aio.h
  143. qemu-binfmt-conf.sh
  144. qemu-char.c
  145. qemu-char.h
  146. qemu-common.h
  147. qemu-doc.texi
  148. qemu-img.c
  149. qemu-img.texi
  150. qemu-io.c
  151. qemu-lock.h
  152. qemu-log.h
  153. qemu-malloc.c
  154. qemu-nbd.c
  155. qemu-nbd.texi
  156. qemu-options.hx
  157. qemu-sockets.c
  158. qemu-tech.texi
  159. qemu-timer.h
  160. qemu-tool.c
  161. qemu.sasl
  162. qemu_socket.h
  163. readline.c
  164. readline.h
  165. README
  166. rules.mak
  167. s390-dis.c
  168. s390.ld
  169. savevm.c
  170. sdl.c
  171. sdl_keysym.h
  172. sh4-dis.c
  173. softmmu-semi.h
  174. softmmu_defs.h
  175. softmmu_exec.h
  176. softmmu_header.h
  177. softmmu_template.h
  178. sparc-dis.c
  179. sparc.ld
  180. sparc64.ld
  181. sys-queue.h
  182. sysemu.h
  183. tap-win32.c
  184. texi2pod.pl
  185. thunk.c
  186. thunk.h
  187. TODO
  188. translate-all.c
  189. uboot_image.h
  190. usb-bsd.c
  191. usb-linux.c
  192. usb-stub.c
  193. VERSION
  194. vgafont.h
  195. vl.c
  196. vnc-auth-sasl.c
  197. vnc-auth-sasl.h
  198. vnc-auth-vencrypt.c
  199. vnc-auth-vencrypt.h
  200. vnc-tls.c
  201. vnc-tls.h
  202. vnc.c
  203. vnc.h
  204. vnc_keysym.h
  205. vnchextile.h
  206. x86_64.ld
  207. x_keymap.c
  208. x_keymap.h