diff mbox

[02/27] vmstate: Return error in case of error

Message ID 1402912703-28195-3-git-send-email-quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela June 16, 2014, 9:57 a.m. UTC
If there is an error while loading a field, we should stop reading and
not continue with the rest of fields.  And we should also set an error
in qemu_file.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 vmstate.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Dr. David Alan Gilbert June 17, 2014, 10:43 a.m. UTC | #1
* Juan Quintela (quintela@redhat.com) wrote:
> If there is an error while loading a field, we should stop reading and
> not continue with the rest of fields.  And we should also set an error
> in qemu_file.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

> ---
>  vmstate.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/vmstate.c b/vmstate.c
> index b5882fa..c996520 100644
> --- a/vmstate.c
> +++ b/vmstate.c
> @@ -98,7 +98,11 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
>                      ret = field->info->get(f, addr, size);
> 
>                  }
> +                if (ret >= 0) {
> +                    ret = qemu_file_get_error(f);
> +                }
>                  if (ret < 0) {
> +                    qemu_file_set_error(f, ret);
>                      trace_vmstate_load_field_error(field->name, ret);
>                      return ret;
>                  }

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

I wonder about turning that trace into an error_report; the process is doomed
anyway at this point and it would be nice to know why.

Dave
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox

Patch

diff --git a/vmstate.c b/vmstate.c
index b5882fa..c996520 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -98,7 +98,11 @@  int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                     ret = field->info->get(f, addr, size);

                 }
+                if (ret >= 0) {
+                    ret = qemu_file_get_error(f);
+                }
                 if (ret < 0) {
+                    qemu_file_set_error(f, ret);
                     trace_vmstate_load_field_error(field->name, ret);
                     return ret;
                 }