Skip to contentSkip to conversation

Add error reporting in migration

PATCH Applied Dr. David Alan Gilbert (git) 4 participants 7 messages Sep 27, 2016 – Oct 5, 2016

lore
Share & tools
lore
#0 lore raw

cover Add error reporting in migration

From: "Dr. David Alan Gilbert" <[email protected]>

At the moment if you use a VMSTATE_*_EQUAL macro and the value doesn't match you just get an error about the section that failed

e.g.
qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu'
qemu-system-ppc64: load of migration failed: Invalid argument

with this pair you get the field and the mismatched values.
e.g.
qemu-system-ppc64: 8000600FE1FF7AE1 != 8000600FE1FF3A21
qemu-system-ppc64: Failed to load cpu:env.insns_flags
qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu'
qemu-system-ppc64: load of migration failed: Invalid argument

which is much more likely to point you at the culprit.

(Broken out from a larger vmstatification series, the only change since then is the values are printed in hex except for the le case).

Dave

Dr. David Alan Gilbert (2):
migration: report an error giving the failed field
migration: Report values for comparisons

 migration/vmstate.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 migration: report an error giving the failed field

From: "Dr. David Alan Gilbert" <[email protected]>

When a field fails to load (typically due to a limit check, or a call to a get/put) report the device and field to give an indication of the cause.

---
 migration/vmstate.c | 2 ++
 1 file changed, 2 insertions(+)
migration/vmstate.c +2 -0
index fc29acf..1d637b2 100644
@@ -130,6 +130,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                 }
                 if (ret < 0) {
                     qemu_file_set_error(f, ret);
+                    error_report("Failed to load %s:%s", vmsd->name,
+                                 field->name);
                     trace_vmstate_load_field_error(field->name, ret);
                     return ret;
                 }
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] migration: report an error giving the failed field

Quoted 16 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

When a field fails to load (typically due to a limit check, or a call to a get/put) report the device and field to give an indication of the cause.

---
 migration/vmstate.c | 2 ++
 1 file changed, 2 insertions(+)
migration/vmstate.c +0 -0
index fc29acf..1d637b2 100644

migration/vmstate.c int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, · line 137

Quoted 8 lines
migration/vmstate.c +2 -0
@@ -130,6 +130,8 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                 }
                 if (ret < 0) {
                     qemu_file_set_error(f, ret);
+                    error_report("Failed to load %s:%s", vmsd->name,
+                                 field->name);
                     trace_vmstate_load_field_error(field->name, ret);
                     return ret;
                 }

Applied, thanks.

#3 lore raw

PATCH 2/2 migration: Report values for comparisons

In reply to Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Report the values when a comparison fails; together with the previous patch that prints the device and field names this should give a good idea of why loading the migration failed.

---
 migration/vmstate.c | 8 ++++++++
 1 file changed, 8 insertions(+)
migration/vmstate.c +8 -0
index 1d637b2..0bc9f35 100644
@@ -557,6 +557,7 @@ static int get_int32_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%" PRIx32 " != %" PRIx32, *v, v2);
     return -EINVAL;
 }
 
@@ -580,6 +581,9 @@ static int get_int32_le(QEMUFile *f, void *pv, size_t size)
         *cur = loaded;
         return 0;
     }
+    error_report("Invalid value %" PRId32
+                 " expecting positive value <= %" PRId32,
+                 loaded, *cur);
     return -EINVAL;
 }
 
@@ -685,6 +689,7 @@ static int get_uint32_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%" PRIx32 " != %" PRIx32, *v, v2);
     return -EINVAL;
 }
 
@@ -727,6 +732,7 @@ static int get_uint64_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%" PRIx64 " != %" PRIx64, *v, v2);
     return -EINVAL;
 }
 
@@ -748,6 +754,7 @@ static int get_uint8_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%x != %x", *v, v2);
     return -EINVAL;
 }
 
@@ -769,6 +776,7 @@ static int get_uint16_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%x != %x", *v, v2);
     return -EINVAL;
 }
 
Signature · 1 line
2.7.4
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] migration: Report values for comparisons

Quoted 58 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Report the values when a comparison fails; together with the previous patch that prints the device and field names this should give a good idea of why loading the migration failed.

---
 migration/vmstate.c | 8 ++++++++
 1 file changed, 8 insertions(+)
migration/vmstate.c +7 -0
index 1d637b2..0bc9f35 100644
@@ -557,6 +557,7 @@ static int get_int32_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%" PRIx32 " != %" PRIx32, *v, v2);
     return -EINVAL;
 }
 
@@ -580,6 +581,9 @@ static int get_int32_le(QEMUFile *f, void *pv, size_t size)
         *cur = loaded;
         return 0;
     }
+    error_report("Invalid value %" PRId32
+                 " expecting positive value <= %" PRId32,
+                 loaded, *cur);
     return -EINVAL;
 }
 
@@ -685,6 +689,7 @@ static int get_uint32_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%" PRIx32 " != %" PRIx32, *v, v2);
     return -EINVAL;
 }
 
@@ -727,6 +732,7 @@ static int get_uint64_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%" PRIx64 " != %" PRIx64, *v, v2);
     return -EINVAL;
 }
 
@@ -748,6 +754,7 @@ static int get_uint8_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%x != %x", *v, v2);
     return -EINVAL;
 }
 

migration/vmstate.c static int get_uint16_equal(QEMUFile *f, void *pv, size_t size) · line 781

Quoted 6 lines
migration/vmstate.c +1 -0
@@ -769,6 +776,7 @@ static int get_uint16_equal(QEMUFile *f, void *pv, size_t size)
     if (*v == v2) {
         return 0;
     }
+    error_report("%x != %x", *v, v2);
     return -EINVAL;
 }

Applied, thanks.

Reviewed-by on the v1 series
#5 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 21 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

At the moment if you use a VMSTATE_*_EQUAL macro and the value doesn't match you just get an error about the section that failed

e.g.
qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu'
qemu-system-ppc64: load of migration failed: Invalid argument

with this pair you get the field and the mismatched values.
e.g.
qemu-system-ppc64: 8000600FE1FF7AE1 != 8000600FE1FF3A21
qemu-system-ppc64: Failed to load cpu:env.insns_flags
qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu'
qemu-system-ppc64: load of migration failed: Invalid argument

which is much more likely to point you at the culprit.

(Broken out from a larger vmstatification series, the only change since then is the values are printed in hex except for the le case).

Quoted 9 lines

Dave

Dr. David Alan Gilbert (2):
migration: report an error giving the failed field
migration: Report values for comparisons

 migration/vmstate.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

I see this as a strict improvement; though I don't know if there will be complaints about printing error messages instead of adding pathways for the Error object.

Meh. Existing errors here simply use error_report anyway, so:

#6 lore raw
Quoted 28 lines · John Snow
Quoted 27 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

At the moment if you use a VMSTATE_*_EQUAL macro and the value doesn't match you just get an error about the section that failed

e.g.
qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu'
qemu-system-ppc64: load of migration failed: Invalid argument

with this pair you get the field and the mismatched values.
e.g.
qemu-system-ppc64: 8000600FE1FF7AE1 != 8000600FE1FF3A21
qemu-system-ppc64: Failed to load cpu:env.insns_flags
qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu'
qemu-system-ppc64: load of migration failed: Invalid argument

which is much more likely to point you at the culprit.

(Broken out from a larger vmstatification series, the only change since then is the values are printed in hex except for the le case).

Dave

Dr. David Alan Gilbert (2):
migration: report an error giving the failed field
migration: Report values for comparisons

Quoted 7 lines
Quoted 3 lines
 migration/vmstate.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

I see this as a strict improvement; though I don't know if there will be complaints about printing error messages instead of adding pathways for the Error object.

Drive-by comment without having studied the patch: if a function can run within a function that takes an Error * parameter, then error_report() is probably wrong. It's less wrong than not reporting the error at all, though. It's okay to point this out to the poster. Perhaps he's willing to go all the way, once aware. Sometimes, going all the way is more work than the poster can give. Badgering him for it would be ungrateful. A small incremental improvement is still better than nothing. Recording the imperfect nature of the change in commit message or comments may be in order then.

Quoted 3 lines

Meh. Existing errors here simply use error_report anyway, so: