Received: from eggs.gnu.org ([2001:4830:134:3::10]:47437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFyZ-0006LD-AU for qemu-devel@nongnu.org; Fri, 31 Oct 2014 13:27:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XkFyU-0007oX-FH for qemu-devel@nongnu.org; Fri, 31 Oct 2014 13:27:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFyU-0007n4-2z for qemu-devel@nongnu.org; Fri, 31 Oct 2014 13:26:58 -0400 From: Paolo Bonzini Date: Fri, 31 Oct 2014 18:25:56 +0100 Message-Id: <1414776373-9704-19-git-send-email-pbonzini@redhat.com> In-Reply-To: <1414776373-9704-1-git-send-email-pbonzini@redhat.com> References: <1414776373-9704-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 18/35] vl.c: Fix Coverity complaining for vmstate_dump_file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gonglei From: Gonglei commit abfd9ce3(migration: dump vmstate info as a json file for static analysis) introduce a new command, '-dump-vmstate', that takes a filename as an argument. When executed, QEMU will dump the vmstate information for the machine type it's invoked with to the file, and quit. However, only one instance of the -dump-vmstate option is supported. If more were given, the vmstate_dump_file variable would be overwritten. This fix also helps silence a Coverity error. Signed-off-by: Gonglei Signed-off-by: Paolo Bonzini --- vl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vl.c b/vl.c index f5721d1..f070c90 100644 --- a/vl.c +++ b/vl.c @@ -3750,6 +3750,11 @@ int main(int argc, char **argv, char **envp) configure_msg(opts); break; case QEMU_OPTION_dump_vmstate: + if (vmstate_dump_file) { + fprintf(stderr, "qemu: only one '-dump-vmstate' " + "option may be given\n"); + exit(1); + } vmstate_dump_file = fopen(optarg, "w"); if (vmstate_dump_file == NULL) { fprintf(stderr, "open %s: %s\n", optarg, strerror(errno)); -- 1.8.3.1