From 88b0faf1853937b87a35cae8c74e38971aff0bba Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Mon, 25 Sep 2017 12:29:14 +0100 Subject: [PATCH] migration: Check field save returns 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 Message-Id: <20170925112917.21340-4-dgilbert@redhat.com> Reviewed-by: Peter Xu Reviewed-by: Cornelia Huck Reviewed-by: Juan Quintela Signed-off-by: Dr. David Alan Gilbert --- 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;