Currently ram_block_discard_range() is called only by the postcopy code,
using length=block->used_length.  However, new code will use
ram_block_discard_range() to discard the contents of the entire
RAMBlock, so change the limit check to use max_length instead of
used_length.

Signed-off-by: Eduardo Habkost <ehabk...@redhat.com>
---
 exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/exec.c b/exec.c
index a93e209625..585d6ed6d7 100644
--- a/exec.c
+++ b/exec.c
@@ -3522,7 +3522,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, 
size_t length)
         goto err;
     }
 
-    if ((start + length) <= rb->used_length) {
+    if ((start + length) <= rb->max_length) {
         uint8_t *host_endaddr = host_startaddr + length;
         if ((uintptr_t)host_endaddr & (rb->page_size - 1)) {
             error_report("ram_block_discard_range: Unaligned end address: %p",
-- 
2.11.0.259.g40922b1


Reply via email to