migration: Only go to the iterate stage if there is anything to send

Signed-off-by: Orit Wasserman <[email protected]>
Signed-off-by: Juan Quintela <[email protected]>

Reviewed-by: Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
diff --git a/migration.c b/migration.c
index 6d3aeed..fe1a103 100644
--- a/migration.c
+++ b/migration.c
@@ -698,7 +698,7 @@
             DPRINTF("iterate\n");
             pending_size = qemu_savevm_state_pending(s->file, max_size);
             DPRINTF("pending size %lu max %lu\n", pending_size, max_size);
-            if (pending_size >= max_size) {
+            if (pending_size && pending_size >= max_size) {
                 ret = qemu_savevm_state_iterate(s->file);
                 if (ret < 0) {
                     qemu_mutex_unlock_iothread();