qcow2: Fix L1 table size after bdrv_snapshot_goto

When loading an internal snapshot whose L1 table is smaller than the current L1
table, the size of the current L1 would be shrunk to the snapshot's L1 size in
memory, but not on disk. This lead to incorrect refcount updates and eventuelly
to image corruption.

Instead of writing the new L1 size to disk, this simply retains the bigger L1
size that is currently in use and makes sure that the unused part is zeroed.

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