Skip to contentSkip to conversation

spapr/htab: fix savevm

PATCH Superseded Laurent Vivier 2 participants 3 messages Jul 18, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spapr/htab: fix savevm

Commit 3a38429 ("spapr: Add a "no HPT" encoding to HTAB migration stream") allows to migrate an empty HPT, but doesn't mark correctly the end of the migration stream.

The end condition (value returned by htab_save_iterate() and
htab_save_complete()) should be 1, whereas in 3a38429 they
return 0.

The problem can be reproduced with QEMU monitor command "savevm":
the command never stops and the disk image grows without limit.

Fixes 3a38429748aa4f74abaecf16c4c087e8a325e12a
---
 hw/ppc/spapr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +2 -2
index 970093e..fa01511 100644
@@ -1827,7 +1827,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque)
     /* Iteration header */
     if (!spapr->htab_shift) {
         qemu_put_be32(f, -1);
-        return 0;
+        return 1;
     } else {
         qemu_put_be32(f, 0);
     }
@@ -1866,7 +1866,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
     /* Iteration header */
     if (!spapr->htab_shift) {
         qemu_put_be32(f, -1);
-        return 0;
+        return 1;
     } else {
         qemu_put_be32(f, 0);
     }
Signature · 1 line
2.9.4
#1 lore raw
Quoted 32 lines · Laurent Vivier

Commit 3a38429 ("spapr: Add a "no HPT" encoding to HTAB migration stream") allows to migrate an empty HPT, but doesn't mark correctly the end of the migration stream.

The end condition (value returned by htab_save_iterate() and
htab_save_complete()) should be 1, whereas in 3a38429 they
return 0.

The problem can be reproduced with QEMU monitor command "savevm":
the command never stops and the disk image grows without limit.

Fixes 3a38429748aa4f74abaecf16c4c087e8a325e12a
---
 hw/ppc/spapr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +1 -1
index 970093e..fa01511 100644
@@ -1827,7 +1827,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque)
     /* Iteration header */
     if (!spapr->htab_shift) {
         qemu_put_be32(f, -1);
-        return 0;
+        return 1;
     } else {
         qemu_put_be32(f, 0);
     }

hw/ppc/spapr.c static int htab_save_complete(QEMUFile *f, void *opaque) · line 1872

Quoted 8 lines
hw/ppc/spapr.c +1 -1
@@ -1866,7 +1866,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
     /* Iteration header */
     if (!spapr->htab_shift) {
         qemu_put_be32(f, -1);
-        return 0;
+        return 1;
     } else {
         qemu_put_be32(f, 0);
     }

I think you only need to change htab_save_iterate(), but not htab_save_complete(), don't you? "1" does not seem to have any real meaning for the *save_complete functions, as far as I can see.

Thomas

#2 lore raw
Quoted 37 lines · Thomas Huth
Quoted 36 lines · Laurent Vivier

Commit 3a38429 ("spapr: Add a "no HPT" encoding to HTAB migration stream") allows to migrate an empty HPT, but doesn't mark correctly the end of the migration stream.

The end condition (value returned by htab_save_iterate() and
htab_save_complete()) should be 1, whereas in 3a38429 they
return 0.

The problem can be reproduced with QEMU monitor command "savevm":
the command never stops and the disk image grows without limit.

Fixes 3a38429748aa4f74abaecf16c4c087e8a325e12a
---
 hw/ppc/spapr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +2 -2
index 970093e..fa01511 100644
@@ -1827,7 +1827,7 @@ static int htab_save_iterate(QEMUFile *f, void *opaque)
     /* Iteration header */
     if (!spapr->htab_shift) {
         qemu_put_be32(f, -1);
-        return 0;
+        return 1;
     } else {
         qemu_put_be32(f, 0);
     }
@@ -1866,7 +1866,7 @@ static int htab_save_complete(QEMUFile *f, void *opaque)
     /* Iteration header */
     if (!spapr->htab_shift) {
         qemu_put_be32(f, -1);
-        return 0;
+        return 1;
Quoted 8 lines

hw/ppc/spapr.c static int htab_save_iterate(QEMUFile *f, void *opaque) · line 1833

Quoted 4 lines
hw/ppc/spapr.c +0 -0
     } else {
         qemu_put_be32(f, 0);
     }

I think you only need to change htab_save_iterate(), but not htab_save_complete(), don't you? "1" does not seem to have any real meaning for the *save_complete functions, as far as I can see.

Yes, you're right, htab_save_complete() always returns 0 or an error (< 0).

I update the patch.

Thanks,
Laurent