memory: separate building the final memory map into two steps
authorAvi Kivity <avi@redhat.com>
Tue, 26 Jul 2011 11:26:12 +0000 (14:26 +0300)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 29 Jul 2011 13:25:43 +0000 (08:25 -0500)
commitb22c099c3a8a617828bdcbb05aad4a78e02c1899
treeabf9eed361bff11531e4ad2b6adca04f08849ee6
parenta95d99a850a70aab6421613e59dbfb97e64a3f10
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>
memory.c