block/vdi: Zero unused parts when allocating a new block (fix #919242)

The new block was filled with zero when it was allocated by g_malloc0,
but when it was reused later and only partially used, data from the
previously allocated block were still present and written to the new
block.

This caused the problems reported by bug #919242
(https://bugs.launchpad.net/qemu/+bug/919242).

Now the unused parts of the new block which are before and after the data
are always filled with zero, so it is no longer necessary to zero the whole
block with g_malloc0.

I also updated the copyright comment.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1 file changed
tree: 37bbd0327a9d2d3ca4e4f163e87cccf246f835b4
  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. target-xtensa/
  37. tcg/
  38. tests/
  39. trace/
  40. ui/
  41. .gitignore
  42. .gitmodules
  43. .mailmap
  44. a.out.h
  45. acl.c
  46. acl.h
  47. aes.c
  48. aes.h
  49. aio.c
  50. alpha-dis.c
  51. alpha.ld
  52. arch_init.c
  53. arch_init.h
  54. arm-dis.c
  55. arm-semi.c
  56. arm.ld
  57. async.c
  58. balloon.c
  59. balloon.h
  60. bitmap.c
  61. bitmap.h
  62. bitops.c
  63. bitops.h
  64. block-migration.c
  65. block-migration.h
  66. block.c
  67. block.h
  68. block_int.h
  69. blockdev.c
  70. blockdev.h
  71. bswap.h
  72. bt-host.c
  73. bt-host.h
  74. bt-vhci.c
  75. buffered_file.c
  76. buffered_file.h
  77. cache-utils.c
  78. cache-utils.h
  79. Changelog
  80. check-qdict.c
  81. check-qfloat.c
  82. check-qint.c
  83. check-qjson.c
  84. check-qlist.c
  85. check-qstring.c
  86. cmd.c
  87. cmd.h
  88. CODING_STYLE
  89. compatfd.c
  90. compatfd.h
  91. compiler.h
  92. config.h
  93. configure
  94. console.c
  95. console.h
  96. COPYING
  97. COPYING.LIB
  98. coroutine-gthread.c
  99. coroutine-ucontext.c
  100. coroutine-win32.c
  101. cpu-all.h
  102. cpu-common.h
  103. cpu-defs.h
  104. cpu-exec.c
  105. cpus.c
  106. cpus.h
  107. cris-dis.c
  108. cursor.c
  109. cursor_hidden.xpm
  110. cursor_left_ptr.xpm
  111. cutils.c
  112. def-helper.h
  113. device_tree.c
  114. device_tree.h
  115. dis-asm.h
  116. disas.c
  117. disas.h
  118. dma-helpers.c
  119. dma.h
  120. dyngen-exec.h
  121. elf.h
  122. envlist.c
  123. envlist.h
  124. error.c
  125. error.h
  126. error_int.h
  127. event_notifier.c
  128. event_notifier.h
  129. exec-all.h
  130. exec-memory.h
  131. exec-obsolete.h
  132. exec.c
  133. gdbstub.c
  134. gdbstub.h
  135. gen-icount.h
  136. HACKING
  137. hmp-commands.hx
  138. hmp.c
  139. hmp.h
  140. host-utils.c
  141. host-utils.h
  142. hppa-dis.c
  143. hppa.ld
  144. i386-dis.c
  145. i386.ld
  146. ia64-dis.c
  147. ia64.ld
  148. input.c
  149. int128.h
  150. iohandler.c
  151. ioport-user.c
  152. ioport.c
  153. ioport.h
  154. iorange.h
  155. iov.c
  156. iov.h
  157. json-lexer.c
  158. json-lexer.h
  159. json-parser.c
  160. json-parser.h
  161. json-streamer.c
  162. json-streamer.h
  163. kvm-all.c
  164. kvm-stub.c
  165. kvm.h
  166. libfdt_env.h
  167. LICENSE
  168. linux-aio.c
  169. m68k-dis.c
  170. m68k-semi.c
  171. m68k.ld
  172. main-loop.c
  173. main-loop.h
  174. MAINTAINERS
  175. Makefile
  176. Makefile.dis
  177. Makefile.hw
  178. Makefile.objs
  179. Makefile.target
  180. Makefile.user
  181. memory.c
  182. memory.h
  183. microblaze-dis.c
  184. migration-exec.c
  185. migration-fd.c
  186. migration-tcp.c
  187. migration-unix.c
  188. migration.c
  189. migration.h
  190. mips-dis.c
  191. mips.ld
  192. module.c
  193. module.h
  194. monitor.c
  195. monitor.h
  196. nbd.c
  197. nbd.h
  198. net.c
  199. net.h
  200. notify.c
  201. notify.h
  202. os-posix.c
  203. os-win32.c
  204. osdep.c
  205. osdep.h
  206. oslib-posix.c
  207. oslib-win32.c
  208. path.c
  209. pci-ids.txt
  210. pflib.c
  211. pflib.h
  212. poison.h
  213. posix-aio-compat.c
  214. ppc-dis.c
  215. ppc.ld
  216. ppc64.ld
  217. qapi-schema-guest.json
  218. qapi-schema-test.json
  219. qapi-schema.json
  220. qbool.c
  221. qbool.h
  222. qdict-test-data.txt
  223. qdict.c
  224. qdict.h
  225. qemu-aio.h
  226. qemu-barrier.h
  227. qemu-char.c
  228. qemu-char.h
  229. qemu-common.h
  230. qemu-config.c
  231. qemu-config.h
  232. qemu-coroutine-int.h
  233. qemu-coroutine-io.c
  234. qemu-coroutine-lock.c
  235. qemu-coroutine-sleep.c
  236. qemu-coroutine.c
  237. qemu-coroutine.h
  238. qemu-doc.texi
  239. qemu-error.c
  240. qemu-error.h
  241. qemu-file.h
  242. qemu-ga.c
  243. qemu-img-cmds.hx
  244. qemu-img.c
  245. qemu-img.texi
  246. qemu-io.c
  247. qemu-lock.h
  248. qemu-log.h
  249. qemu-nbd.c
  250. qemu-nbd.texi
  251. qemu-objects.h
  252. qemu-option.c
  253. qemu-option.h
  254. qemu-options-wrapper.h
  255. qemu-options.h
  256. qemu-options.hx
  257. qemu-os-posix.h
  258. qemu-os-win32.h
  259. qemu-progress.c
  260. qemu-queue.h
  261. qemu-sockets.c
  262. qemu-tech.texi
  263. qemu-thread-posix.c
  264. qemu-thread-posix.h
  265. qemu-thread-win32.c
  266. qemu-thread-win32.h
  267. qemu-thread.h
  268. qemu-timer-common.c
  269. qemu-timer.c
  270. qemu-timer.h
  271. qemu-tls.h
  272. qemu-tool.c
  273. qemu-x509.h
  274. qemu-xattr.h
  275. qemu.sasl
  276. qemu_socket.h
  277. qerror.c
  278. qerror.h
  279. qfloat.c
  280. qfloat.h
  281. qint.c
  282. qint.h
  283. qjson.c
  284. qjson.h
  285. qlist.c
  286. qlist.h
  287. qmp-commands.hx
  288. qmp.c
  289. qobject.h
  290. qstring.c
  291. qstring.h
  292. range.h
  293. readline.c
  294. readline.h
  295. README
  296. rules.mak
  297. s390-dis.c
  298. s390.ld
  299. savevm.c
  300. sh4-dis.c
  301. softmmu-semi.h
  302. softmmu_defs.h
  303. softmmu_exec.h
  304. softmmu_header.h
  305. softmmu_template.h
  306. sparc-dis.c
  307. sparc.ld
  308. sparc64.ld
  309. spice-qemu-char.c
  310. sysemu.h
  311. targphys.h
  312. tcg-runtime.c
  313. tci-dis.c
  314. tci.c
  315. test-coroutine.c
  316. test-qmp-commands.c
  317. test-qmp-input-visitor.c
  318. test-qmp-output-visitor.c
  319. thunk.c
  320. thunk.h
  321. TODO
  322. trace-events
  323. translate-all.c
  324. uboot_image.h
  325. usb-bsd.c
  326. usb-linux.c
  327. usb-redir.c
  328. usb-stub.c
  329. user-exec.c
  330. VERSION
  331. version.rc
  332. vgafont.h
  333. vl.c
  334. vmstate.h
  335. x86_64.ld
  336. xen-all.c
  337. xen-mapcache.c
  338. xen-mapcache.h
  339. xen-stub.c
  340. xtensa-semi.c