From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxDEl-0001aL-Io for qemu-devel@nongnu.org; Wed, 18 Jun 2014 06:37:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxDEe-00084p-2z for qemu-devel@nongnu.org; Wed, 18 Jun 2014 06:37:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11775) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxDEd-00084g-QG for qemu-devel@nongnu.org; Wed, 18 Jun 2014 06:36:55 -0400 Date: Wed, 18 Jun 2014 16:06:49 +0530 From: Amit Shah Message-ID: <20140618103649.GK29732@grmbl.mre> References: <4ab8ba6bf5de4943288c1ddc565179c807f263e3.1403079139.git.amit.shah@redhat.com> <87mwdaldly.fsf@troll.troll> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87mwdaldly.fsf@troll.troll> Subject: Re: [Qemu-devel] [PATCH v4 01/18] migration: dump vmstate info as a json file for static analysis List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu list , Markus Armbruster , Alexander Graf , "Dr. David Alan Gilbert" , Paolo Bonzini , Andreas =?iso-8859-1?Q?F=E4rber?= On (Wed) 18 Jun 2014 [12:24:25], Juan Quintela wrote: > Amit Shah wrote: > > This commit adds a new command, '-dump-vmstate', that takes a filename > > as a parameter. When executed, QEMU will dump the vmstate information > > for the machine type it's invoked with to the file, and quit. > > > > The JSON-format output can then be used to compare the vmstate info for > > different QEMU versions, specifically to test whether live migration > > would break due to changes in the vmstate data. > > > > A Python script that compares the output of such JSON dumps is included > > in the following commit. > > > > Signed-off-by: Amit Shah > > > > > +static void dump_vmstate_vmsd(FILE *out_file, > > + const VMStateDescription *vmsd, int indent, > > + bool is_subsection) > > +{ > > + if (is_subsection) { > > + fprintf(out_file, "%*s{\n", indent, ""); > > + } else { > > + fprintf(out_file, "%*s\"%s\": {\n", indent, "", "Description"); > > + } > > + indent += 2; > > + fprintf(out_file, "%*s\"name\": \"%s\",\n", indent, "", vmsd->name); > > + fprintf(out_file, "%*s\"version_id\": %d,\n", indent, "", > > + vmsd->version_id); > > + fprintf(out_file, "%*s\"minimum_version_id\": %d", indent, "", > > + vmsd->minimum_version_id); > > + if (vmsd->fields != NULL) { > > + const VMStateField *field = vmsd->fields; > > + bool first; > > + > > + fprintf(out_file, ",\n%*s\"Fields\": [\n", indent, ""); > > Remove last "\n" (*) > > > > + first = true; > > first can go now > > > + while (field->name != NULL) { > > + if (field->flags & VMS_MUST_EXIST) { > > + /* Ignore VMSTATE_VALIDATE bits; these don't get migrated */ > > + field++; > > + continue; > > + } > > + if (!first) { > > + fprintf(out_file, ",\n"); > > You can print always \n now, right? There's also a , there... This sequence was added recently (v2 onwards) for the ignoring of the VMS_MUST_EXIST stuff. > Same for the other places? Or I am missing something. > > I will even go that itwould be better to just left the \n on the (*), > and just add this \n at the end of writing a subsection. > > > > + fprintf(out_file, "\n%*s}", indent - 2, ""); > > And you remove it from here. I tried several things with the \n; the current setting is the best I found. Of course, this is just pretty-printing, so I don't actually remember all the details but I can look it up my git tree... > > Yes, I have always hated pretty-printers > Oh, me too! > Rest of this, I fully agree. > > Later, Juan. Amit