@@ -188,7 +188,7 @@ static int ram_save_block(QEMUFile *f)
{
RAMBlock *block = last_block;
ram_addr_t offset = last_offset;
- int bytes_sent = 0;
+ int bytes_sent = -1;
MemoryRegion *mr;
if (!block)
@@ -349,8 +349,11 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque)
int bytes_sent;
bytes_sent = ram_save_block(f);
- bytes_transferred += bytes_sent;
- if (bytes_sent == 0) { /* no more blocks */
+ /* bytes_sent 0 represent unchanged page,
+ bytes_sent -1 represent no more blocks*/
+ if (bytes_sent > 0) {
+ bytes_transferred += bytes_sent;
+ } else if (bytes_sent == -1) { /* no more blocks */
break;
}
/* we want to check in the 1st loop, just in case it was the 1st time
@@ -387,7 +390,7 @@ int ram_save_live(QEMUFile *f, int stage, void *opaque)
int bytes_sent;
/* flush all remaining blocks regardless of rate limiting */
- while ((bytes_sent = ram_save_block(f)) != 0) {
+ while ((bytes_sent = ram_save_block(f)) != -1) {
bytes_transferred += bytes_sent;
}
migration_end();
It will return 0 if the page is unmodifed. Signed-off-by: Orit Wasserman <owasserm@redhat.com> --- arch_init.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)