diff mbox

[RFC,v2,3/5] vmstate: add VMS_MUST_EXIST

Message ID 20140324162125.GA5717@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin March 24, 2014, 4:21 p.m. UTC
On Mon, Mar 24, 2014 at 04:38:01PM +0200, Michael S. Tsirkin wrote:
> Can be used to verify a required field exists or validate
> state in some other way.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Sent a wrong patch. this is RFC in any case so not resending
everything, but this is needed on top both to build and make the intent
clear:
diff mbox

Patch

diff --git a/vmstate.c b/vmstate.c
index 4943b83..974c618 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -105,11 +105,11 @@  int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                     return ret;
                 }
             }
+        } else if (field->flags & VMS_MUST_EXIST) {
+            fprintf(stderr, "Input validation failed: %s/%s\n", vmsd->name, field->name);
+            return -1;
         }
         field++;
-    } else if (field->flags & VMS_MUST_EXIST) {
-        fprintf(stderr, "Input validation failed: %s/%s\n", vmsd->name, field->name);
-        return -1;
     }
     ret = vmstate_subsection_load(f, vmsd, opaque);
     if (ret != 0) {