qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 01/18] migration: dump vmstate info as a json


From: Juan Quintela
Subject: Re: [Qemu-devel] [PATCH v4 01/18] migration: dump vmstate info as a json file for static analysis
Date: Wed, 18 Jun 2014 12:24:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Amit Shah <address@hidden> 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 <address@hidden>



> +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?

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.

<full disclosure>
Yes, I have always hated pretty-printers
</full-disclosure>

Rest of this, I fully agree.

Later, Juan.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]