memory: separate building the final memory map into two steps

Instead of adding and deleting regions in one pass, do a delete
pass followed by an add pass.  This fixes the following case:

from:
  0x0000-0x0fff ram  (a1)
  0x1000-0x1fff mmio (a2)
  0x2000-0x2fff ram  (a3)

to:
  0x0000-0x2fff ram  (b1)

The single pass algorithm removed a1, added b2, then removed a2 and a3,
which caused the wrong memory map to be built.  The two pass algorithm
removes a1, a2, and a3, then adds b1.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
1 file changed
tree: abf9eed361bff11531e4ad2b6adca04f08849ee6
  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-memory.h
  123. exec.c
  124. gdbstub.c
  125. gdbstub.h
  126. gen-icount.h
  127. HACKING
  128. hmp-commands.hx
  129. host-utils.c
  130. host-utils.h
  131. hpet.h
  132. hppa-dis.c
  133. hppa.ld
  134. i386-dis.c
  135. i386.ld
  136. ia64-dis.c
  137. ia64.ld
  138. input.c
  139. iohandler.c
  140. ioport-user.c
  141. ioport.c
  142. ioport.h
  143. iorange.h
  144. iov.c
  145. iov.h
  146. json-lexer.c
  147. json-lexer.h
  148. json-parser.c
  149. json-parser.h
  150. json-streamer.c
  151. json-streamer.h
  152. kvm-all.c
  153. kvm-stub.c
  154. kvm.h
  155. libfdt_env.h
  156. LICENSE
  157. linux-aio.c
  158. m68k-dis.c
  159. m68k-semi.c
  160. m68k.ld
  161. MAINTAINERS
  162. Makefile
  163. Makefile.dis
  164. Makefile.hw
  165. Makefile.objs
  166. Makefile.target
  167. Makefile.user
  168. memory.c
  169. memory.h
  170. microblaze-dis.c
  171. migration-exec.c
  172. migration-fd.c
  173. migration-tcp.c
  174. migration-unix.c
  175. migration.c
  176. migration.h
  177. mips-dis.c
  178. mips.ld
  179. module.c
  180. module.h
  181. monitor.c
  182. monitor.h
  183. nbd.c
  184. nbd.h
  185. net.c
  186. net.h
  187. notify.c
  188. notify.h
  189. os-posix.c
  190. os-win32.c
  191. osdep.c
  192. osdep.h
  193. oslib-posix.c
  194. oslib-win32.c
  195. path.c
  196. pci-ids.txt
  197. pflib.c
  198. pflib.h
  199. poison.h
  200. posix-aio-compat.c
  201. ppc-dis.c
  202. ppc.ld
  203. ppc64.ld
  204. qapi-schema-guest.json
  205. qapi-schema-test.json
  206. qbool.c
  207. qbool.h
  208. qdict-test-data.txt
  209. qdict.c
  210. qdict.h
  211. qemu-aio.h
  212. qemu-barrier.h
  213. qemu-char.c
  214. qemu-char.h
  215. qemu-common.h
  216. qemu-config.c
  217. qemu-config.h
  218. qemu-doc.texi
  219. qemu-error.c
  220. qemu-error.h
  221. qemu-ga.c
  222. qemu-img-cmds.hx
  223. qemu-img.c
  224. qemu-img.texi
  225. qemu-io.c
  226. qemu-lock.h
  227. qemu-log.h
  228. qemu-malloc.c
  229. qemu-nbd.c
  230. qemu-nbd.texi
  231. qemu-objects.h
  232. qemu-option.c
  233. qemu-option.h
  234. qemu-options.h
  235. qemu-options.hx
  236. qemu-os-posix.h
  237. qemu-os-win32.h
  238. qemu-progress.c
  239. qemu-queue.h
  240. qemu-sockets.c
  241. qemu-tech.texi
  242. qemu-thread-posix.c
  243. qemu-thread-posix.h
  244. qemu-thread-win32.c
  245. qemu-thread-win32.h
  246. qemu-thread.h
  247. qemu-timer-common.c
  248. qemu-timer.c
  249. qemu-timer.h
  250. qemu-tool.c
  251. qemu-x509.h
  252. qemu.sasl
  253. qemu_socket.h
  254. qerror.c
  255. qerror.h
  256. qfloat.c
  257. qfloat.h
  258. qint.c
  259. qint.h
  260. qjson.c
  261. qjson.h
  262. qlist.c
  263. qlist.h
  264. qmp-commands.hx
  265. qobject.h
  266. qstring.c
  267. qstring.h
  268. range.h
  269. readline.c
  270. readline.h
  271. README
  272. rules.mak
  273. rwhandler.c
  274. rwhandler.h
  275. s390-dis.c
  276. s390.ld
  277. savevm.c
  278. sh4-dis.c
  279. simpletrace.c
  280. simpletrace.h
  281. softmmu-semi.h
  282. softmmu_defs.h
  283. softmmu_exec.h
  284. softmmu_header.h
  285. softmmu_template.h
  286. sparc-dis.c
  287. sparc.ld
  288. sparc64.ld
  289. spice-qemu-char.c
  290. sysemu.h
  291. targphys.h
  292. tcg-runtime.c
  293. test-qmp-commands.c
  294. test-visitor.c
  295. thunk.c
  296. thunk.h
  297. TODO
  298. trace-events
  299. translate-all.c
  300. uboot_image.h
  301. usb-bsd.c
  302. usb-linux.c
  303. usb-redir.c
  304. usb-stub.c
  305. user-exec.c
  306. VERSION
  307. version.rc
  308. vgafont.h
  309. vl.c
  310. x86_64.ld
  311. xen-all.c
  312. xen-mapcache.c
  313. xen-mapcache.h
  314. xen-stub.c