On (Wed) 18 Jun 2014 [12:24:25], Juan Quintela wrote: > Amit Shah <amit.s...@redhat.com> 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 <amit.s...@redhat.com> > > > > > +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... > <full disclosure> > Yes, I have always hated pretty-printers > </full-disclosure> Oh, me too! > Rest of this, I fully agree. > > Later, Juan. Amit