qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com,
	famz@redhat.com
Cc: peter.maydell@linaro.org, cohuck@redhat.com, rth@twiddle.net
Subject: [Qemu-devel] [PATCH v2 3/6] migration: Check field save returns
Date: Mon, 25 Sep 2017 12:29:14 +0100	[thread overview]
Message-ID: <20170925112917.21340-4-dgilbert@redhat.com> (raw)
In-Reply-To: <20170925112917.21340-1-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Check the return values from vmstate_save_state for fields and also the
return values from 'put' for fields that use that.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 migration/vmstate.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/migration/vmstate.c b/migration/vmstate.c
index ae8abd3c32..848e8448c6 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -347,6 +347,7 @@ int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
             }
             for (i = 0; i < n_elems; i++) {
                 void *curr_elem = first_elem + size * i;
+                ret = 0;
 
                 vmsd_desc_field_start(vmsd, vmdesc_loop, field, i, n_elems);
                 old_offset = qemu_ftell_fast(f);
@@ -357,11 +358,19 @@ int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
                 if (!curr_elem && size) {
                     /* if null pointer write placeholder and do not follow */
                     assert(field->flags & VMS_ARRAY_OF_POINTER);
-                    vmstate_info_nullptr.put(f, curr_elem, size, NULL, NULL);
+                    ret = vmstate_info_nullptr.put(f, curr_elem, size, NULL,
+                                                   NULL);
                 } else if (field->flags & VMS_STRUCT) {
-                    vmstate_save_state(f, field->vmsd, curr_elem, vmdesc_loop);
+                    ret = vmstate_save_state(f, field->vmsd, curr_elem,
+                                             vmdesc_loop);
                 } else {
-                    field->info->put(f, curr_elem, size, field, vmdesc_loop);
+                    ret = field->info->put(f, curr_elem, size, field,
+                                     vmdesc_loop);
+                }
+                if (ret) {
+                    error_report("Save of field %s/%s failed",
+                                 vmsd->name, field->name);
+                    return ret;
                 }
 
                 written_bytes = qemu_ftell_fast(f) - old_offset;
-- 
2.13.5

  parent reply	other threads:[~2017-09-25 11:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-25 11:29 [Qemu-devel] [PATCH v2 0/6] migration: let pre_save fail Dr. David Alan Gilbert (git)
2017-09-25 11:29 ` [Qemu-devel] [PATCH v2 1/6] migration: pre_save return int Dr. David Alan Gilbert (git)
2017-09-25 13:19   ` Richard Henderson
2017-09-25 13:25     ` Dr. David Alan Gilbert
2017-09-25 13:29       ` Richard Henderson
2017-09-26  2:31   ` Peter Xu
2017-09-26 13:27   ` Cornelia Huck
2017-09-27  8:57   ` Juan Quintela
2017-09-25 11:29 ` [Qemu-devel] [PATCH v2 2/6] migration: check pre_save return in vmstate_save_state Dr. David Alan Gilbert (git)
2017-09-26  2:36   ` Peter Xu
2017-09-26 13:29   ` Cornelia Huck
2017-09-27  8:58   ` Juan Quintela
2017-09-25 11:29 ` Dr. David Alan Gilbert (git) [this message]
2017-09-26  2:42   ` [Qemu-devel] [PATCH v2 3/6] migration: Check field save returns Peter Xu
2017-09-26 13:32   ` Cornelia Huck
2017-09-27  8:59   ` Juan Quintela
2017-09-25 11:29 ` [Qemu-devel] [PATCH v2 4/6] migration: wire vmstate_save_state errors up to vmstate_subsection_save Dr. David Alan Gilbert (git)
2017-09-26  2:45   ` Peter Xu
2017-09-26  9:55     ` Dr. David Alan Gilbert
2017-09-26 13:35   ` Cornelia Huck
2017-09-27  9:00   ` Juan Quintela
2017-09-25 11:29 ` [Qemu-devel] [PATCH v2 5/6] migration: Route errors up through vmstate_save Dr. David Alan Gilbert (git)
2017-09-26  2:56   ` Peter Xu
2017-09-26 13:36   ` Cornelia Huck
2017-09-27  9:00   ` Juan Quintela
2017-09-25 11:29 ` [Qemu-devel] [PATCH v2 6/6] migration: Route more error paths Dr. David Alan Gilbert (git)
2017-09-26  3:06   ` Peter Xu
2017-09-26 10:03     ` Dr. David Alan Gilbert
2017-09-26 13:39   ` Cornelia Huck
2017-09-27  9:07   ` Juan Quintela
2017-09-27 10:51 ` [Qemu-devel] [PATCH v2 0/6] migration: let pre_save fail Dr. David Alan Gilbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170925112917.21340-4-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=famz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).