From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS7cs-0006ci-54 for qemu-devel@nongnu.org; Mon, 24 Mar 2014 12:21:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WS7cm-0000Ye-3K for qemu-devel@nongnu.org; Mon, 24 Mar 2014 12:21:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS7cl-0000YW-Rv for qemu-devel@nongnu.org; Mon, 24 Mar 2014 12:21:20 -0400 Date: Mon, 24 Mar 2014 18:21:25 +0200 From: "Michael S. Tsirkin" Message-ID: <20140324162125.GA5717@redhat.com> References: <1395671853-2685-1-git-send-email-mst@redhat.com> <1395671853-2685-4-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1395671853-2685-4-git-send-email-mst@redhat.com> Subject: Re: [Qemu-devel] [RFC v2 3/5] vmstate: add VMS_MUST_EXIST List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell 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 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 --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) {