All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/22] Migration queue
@ 2014-06-24 13:09 Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 01/22] rdma: bug fixes Juan Quintela
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel

Hi

Peter, please pull:


- RDMA bugfixes (Michael)
- Static checker from Amit (v5)
- acked patches from vmstate (thanks Dave)

Later, Juan.


The following changes since commit d9c1647d896d3192cba9dbf98fb7efab876edde5:

  Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2014-06-23 12:55:22 +0100)

are available in the git repository at:


  git://github.com/juanquintela/qemu.git tags/migration/20140623

for you to fetch changes up to 4ea7df4e5c6b9d8b8a474680d6b1687fc8eacbac:

  vmstate: Refactor & increase tests for primitive types (2014-06-23 19:14:52 +0200)

----------------------------------------------------------------
migration/next for 20140623

----------------------------------------------------------------
Amit Shah (18):
      migration: dump vmstate info as a json file for static analysis
      vmstate-static-checker: script to validate vmstate changes
      tests: vmstate static checker: add dump1 and dump2 files
      tests: vmstate static checker: incompat machine types
      tests: vmstate static checker: add version error in main section
      tests: vmstate static checker: version mismatch inside a Description
      tests: vmstate static checker: minimum_version_id check
      tests: vmstate static checker: remove a section
      tests: vmstate static checker: remove a field
      tests: vmstate static checker: remove last field in a struct
      tests: vmstate static checker: change description name
      tests: vmstate static checker: remove Fields
      tests: vmstate static checker: remove Description
      tests: vmstate static checker: remove Description inside Fields
      tests: vmstate static checker: remove a subsection
      tests: vmstate static checker: remove Subsections
      tests: vmstate static checker: add substructure for usb-kbd for hid section
      tests: vmstate static checker: add size mismatch inside substructure

Juan Quintela (3):
      migration: Remove unneeded minimum_version_id_old
      vmstate: Return error in case of error
      vmstate: Refactor & increase tests for primitive types

Michael R. Hines (1):
      rdma: bug fixes

 hw/usb/hcd-ohci.c                            |    7 +-
 include/migration/vmstate.h                  |    2 +
 migration-rdma.c                             |   20 +-
 qemu-options.hx                              |   14 +
 savevm.c                                     |  139 +++
 scripts/vmstate-static-checker.py            |  345 ++++++++
 tests/test-vmstate.c                         |  273 ++++--
 tests/vmstate-static-checker-data/dump1.json | 1163 ++++++++++++++++++++++++++
 tests/vmstate-static-checker-data/dump2.json |  968 +++++++++++++++++++++
 vl.c                                         |   13 +
 vmstate.c                                    |    4 +
 11 files changed, 2872 insertions(+), 76 deletions(-)
 create mode 100755 scripts/vmstate-static-checker.py
 create mode 100644 tests/vmstate-static-checker-data/dump1.json
 create mode 100644 tests/vmstate-static-checker-data/dump2.json

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 01/22] rdma: bug fixes
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 02/22] migration: dump vmstate info as a json file for static analysis Juan Quintela
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael R. Hines

From: "Michael R. Hines" <mrhines@us.ibm.com>

1. Fix small memory leak in parsing inet address from command line in data_init()
2. Fix ibv_post_send() return value check and pass error code back up correctly.
3. Fix rdma_destroy_qp() segfault after failure to connect to destination.

Reported-by: frank.yangjie@gmail.com
Reported-by: dgilbert@redhat.com
Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration-rdma.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/migration-rdma.c b/migration-rdma.c
index f60749b..d99812c 100644
--- a/migration-rdma.c
+++ b/migration-rdma.c
@@ -1590,13 +1590,11 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf,
     }


-    if (ibv_post_send(rdma->qp, &send_wr, &bad_wr)) {
-        return -1;
-    }
+    ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr);

-    if (ret < 0) {
+    if (ret > 0) {
         fprintf(stderr, "Failed to use post IB SEND for control!\n");
-        return ret;
+        return -ret;
     }

     ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -2238,10 +2236,6 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
         }
     }

-    if (rdma->qp) {
-        rdma_destroy_qp(rdma->cm_id);
-        rdma->qp = NULL;
-    }
     if (rdma->cq) {
         ibv_destroy_cq(rdma->cq);
         rdma->cq = NULL;
@@ -2259,6 +2253,10 @@ static void qemu_rdma_cleanup(RDMAContext *rdma)
         rdma->listen_id = NULL;
     }
     if (rdma->cm_id) {
+        if (rdma->qp) {
+            rdma_destroy_qp(rdma->cm_id);
+            rdma->qp = NULL;
+        }
         rdma_destroy_id(rdma->cm_id);
         rdma->cm_id = NULL;
     }
@@ -2513,8 +2511,10 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
         } else {
             ERROR(errp, "bad RDMA migration address '%s'", host_port);
             g_free(rdma);
-            return NULL;
+            rdma = NULL;
         }
+
+        qapi_free_InetSocketAddress(addr);
     }

     return rdma;
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 02/22] migration: dump vmstate info as a json file for static analysis
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 01/22] rdma: bug fixes Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 03/22] vmstate-static-checker: script to validate vmstate changes Juan Quintela
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

This commit adds 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.

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.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h |   2 +
 qemu-options.hx             |  14 +++++
 savevm.c                    | 139 ++++++++++++++++++++++++++++++++++++++++++++
 vl.c                        |  13 +++++
 4 files changed, 168 insertions(+)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 799d2d0..71a8a95 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -788,4 +788,6 @@ int64_t self_announce_delay(int round)
     return 50 + (SELF_ANNOUNCE_ROUNDS - round - 1) * 100;
 }

+void dump_vmstate_json_to_file(FILE *out_fp);
+
 #endif
diff --git a/qemu-options.hx b/qemu-options.hx
index ca75760..ff76ad4 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3252,6 +3252,20 @@ STEXI
 prepend a timestamp to each log message.(default:on)
 ETEXI

+DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
+    "-dump-vmstate <file>\n"
+    "                Output vmstate information in JSON format to file.\n"
+    "                Use the scripts/vmstate-static-checker.py file to\n"
+    "                check for possible regressions in migration code\n"
+    "                by comparing two such vmstate dumps.",
+    QEMU_ARCH_ALL)
+STEXI
+@item -dump-vmstate @var{file}
+@findex -dump-vmstate
+Dump json-encoded vmstate information for current machine type to file
+in @var{file}
+ETEXI
+
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
 @end table
diff --git a/savevm.c b/savevm.c
index 6cbdaac..ba900d3 100644
--- a/savevm.c
+++ b/savevm.c
@@ -24,6 +24,7 @@

 #include "config-host.h"
 #include "qemu-common.h"
+#include "hw/boards.h"
 #include "hw/hw.h"
 #include "hw/qdev.h"
 #include "net/net.h"
@@ -240,6 +241,144 @@ static QTAILQ_HEAD(savevm_handlers, SaveStateEntry) savevm_handlers =
     QTAILQ_HEAD_INITIALIZER(savevm_handlers);
 static int global_section_id;

+static void dump_vmstate_vmsd(FILE *out_file,
+                              const VMStateDescription *vmsd, int indent,
+                              bool is_subsection);
+
+static void dump_vmstate_vmsf(FILE *out_file, const VMStateField *field,
+                              int indent)
+{
+    fprintf(out_file, "%*s{\n", indent, "");
+    indent += 2;
+    fprintf(out_file, "%*s\"field\": \"%s\",\n", indent, "", field->name);
+    fprintf(out_file, "%*s\"version_id\": %d,\n", indent, "",
+            field->version_id);
+    fprintf(out_file, "%*s\"field_exists\": %s,\n", indent, "",
+            field->field_exists ? "true" : "false");
+    fprintf(out_file, "%*s\"size\": %zu", indent, "", field->size);
+    if (field->vmsd != NULL) {
+        fprintf(out_file, ",\n");
+        dump_vmstate_vmsd(out_file, field->vmsd, indent, false);
+    }
+    fprintf(out_file, "\n%*s}", indent - 2, "");
+}
+
+static void dump_vmstate_vmss(FILE *out_file,
+                              const VMStateSubsection *subsection,
+                              int indent)
+{
+    if (subsection->vmsd != NULL) {
+        dump_vmstate_vmsd(out_file, subsection->vmsd, indent, true);
+    }
+}
+
+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, "");
+        first = true;
+        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");
+            }
+            dump_vmstate_vmsf(out_file, field, indent + 2);
+            field++;
+            first = false;
+        }
+        fprintf(out_file, "\n%*s]", indent, "");
+    }
+    if (vmsd->subsections != NULL) {
+        const VMStateSubsection *subsection = vmsd->subsections;
+        bool first;
+
+        fprintf(out_file, ",\n%*s\"Subsections\": [\n", indent, "");
+        first = true;
+        while (subsection->vmsd != NULL) {
+            if (!first) {
+                fprintf(out_file, ",\n");
+            }
+            dump_vmstate_vmss(out_file, subsection, indent + 2);
+            subsection++;
+            first = false;
+        }
+        fprintf(out_file, "\n%*s]", indent, "");
+    }
+    fprintf(out_file, "\n%*s}", indent - 2, "");
+}
+
+static void dump_machine_type(FILE *out_file)
+{
+    MachineClass *mc;
+
+    mc = MACHINE_GET_CLASS(current_machine);
+
+    fprintf(out_file, "  \"vmschkmachine\": {\n");
+    fprintf(out_file, "    \"Name\": \"%s\"\n", mc->name);
+    fprintf(out_file, "  },\n");
+}
+
+void dump_vmstate_json_to_file(FILE *out_file)
+{
+    GSList *list, *elt;
+    bool first;
+
+    fprintf(out_file, "{\n");
+    dump_machine_type(out_file);
+
+    first = true;
+    list = object_class_get_list(TYPE_DEVICE, true);
+    for (elt = list; elt; elt = elt->next) {
+        DeviceClass *dc = OBJECT_CLASS_CHECK(DeviceClass, elt->data,
+                                             TYPE_DEVICE);
+        const char *name;
+        int indent = 2;
+
+        if (!dc->vmsd) {
+            continue;
+        }
+
+        if (!first) {
+            fprintf(out_file, ",\n");
+        }
+        name = object_class_get_name(OBJECT_CLASS(dc));
+        fprintf(out_file, "%*s\"%s\": {\n", indent, "", name);
+        indent += 2;
+        fprintf(out_file, "%*s\"Name\": \"%s\",\n", indent, "", name);
+        fprintf(out_file, "%*s\"version_id\": %d,\n", indent, "",
+                dc->vmsd->version_id);
+        fprintf(out_file, "%*s\"minimum_version_id\": %d,\n", indent, "",
+                dc->vmsd->minimum_version_id);
+
+        dump_vmstate_vmsd(out_file, dc->vmsd, indent, false);
+
+        fprintf(out_file, "\n%*s}", indent - 2, "");
+        first = false;
+    }
+    fprintf(out_file, "\n}\n");
+    fclose(out_file);
+}
+
 static int calculate_new_instance_id(const char *idstr)
 {
     SaveStateEntry *se;
diff --git a/vl.c b/vl.c
index ab8f152..3288755 100644
--- a/vl.c
+++ b/vl.c
@@ -2935,6 +2935,7 @@ int main(int argc, char **argv, char **envp)
                                         1024 * 1024;
     ram_addr_t maxram_size = default_ram_size;
     uint64_t ram_slots = 0;
+    FILE *vmstate_dump_file = NULL;

     atexit(qemu_run_exit_notifiers);
     error_set_progname(argv[0]);
@@ -3944,6 +3945,13 @@ int main(int argc, char **argv, char **envp)
                 }
                 configure_msg(opts);
                 break;
+            case QEMU_OPTION_dump_vmstate:
+                vmstate_dump_file = fopen(optarg, "w");
+                if (vmstate_dump_file == NULL) {
+                    fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
+                    exit(1);
+                }
+                break;
             default:
                 os_parse_cmd_args(popt->index, optarg);
             }
@@ -4495,6 +4503,11 @@ int main(int argc, char **argv, char **envp)
     }

     qdev_prop_check_global();
+    if (vmstate_dump_file) {
+        /* dump and exit */
+        dump_vmstate_json_to_file(vmstate_dump_file);
+        return 0;
+    }

     if (incoming) {
         Error *local_err = NULL;
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 03/22] vmstate-static-checker: script to validate vmstate changes
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 01/22] rdma: bug fixes Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 02/22] migration: dump vmstate info as a json file for static analysis Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 04/22] tests: vmstate static checker: add dump1 and dump2 files Juan Quintela
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

This script compares the vmstate dumps in JSON format as output by QEMU
with the -dump-vmstate option.

It flags various errors, like version mismatch, sections going away,
size mismatches, etc.

This script is tolerant of a few changes that do not change the on-wire
format, like embedding a few fields within substructs.

The script takes -s/--src and -d/--dest parameters, to which filenames
are given as arguments.

Example:

(in a qemu 2.0 tree):
./x86_64-softmmu/qemu-system-x86_64 -dump-vmstate qemu-2.0.json

(in a qemu 2.2 tree:)
./x86_64-softmmu/qemu-system-x86_64 -dump-vmstate -M pc-i440fx-2.0 \
   qemu-2.2-m2.0.json

./scripts/vmstate-static-checker.py -s qemu-2.0.json -d qemu-2.2-m2.0.json

The script also takes a --reverse parameter to switch the src and dest
jsons.  This is just a shorthand for reversing the src and dest.

The --help parameter shows usage information.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 scripts/vmstate-static-checker.py | 345 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 345 insertions(+)
 create mode 100755 scripts/vmstate-static-checker.py

diff --git a/scripts/vmstate-static-checker.py b/scripts/vmstate-static-checker.py
new file mode 100755
index 0000000..1604e68
--- /dev/null
+++ b/scripts/vmstate-static-checker.py
@@ -0,0 +1,345 @@
+#!/usr/bin/python
+#
+# Compares vmstate information stored in JSON format, obtained from
+# the -dump-vmstate QEMU command.
+#
+# Copyright 2014 Amit Shah <amit.shah@redhat.com>
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, see <http://www.gnu.org/licenses/>.
+
+import argparse
+import json
+import sys
+
+# Count the number of errors found
+taint = 0
+
+def bump_taint():
+    global taint
+
+    # Ensure we don't wrap around or reset to 0 -- the shell only has
+    # an 8-bit return value.
+    if taint < 255:
+        taint = taint + 1
+
+
+def check_fields_match(name, s_field, d_field):
+    if s_field == d_field:
+        return True
+
+    # Some fields changed names between qemu versions.  This list
+    # is used to whitelist such changes in each section / description.
+    changed_names = {
+        'e1000': ['dev', 'parent_obj'],
+        'ehci': ['dev', 'pcidev'],
+        'I440FX': ['dev', 'parent_obj'],
+        'ich9_ahci': ['card', 'parent_obj'],
+        'ioh-3240-express-root-port': ['port.br.dev',
+                                       'parent_obj.parent_obj.parent_obj',
+                                       'port.br.dev.exp.aer_log',
+                                'parent_obj.parent_obj.parent_obj.exp.aer_log'],
+        'mch': ['d', 'parent_obj'],
+        'pci_bridge': ['bridge.dev', 'parent_obj', 'bridge.dev.shpc', 'shpc'],
+        'pcnet': ['pci_dev', 'parent_obj'],
+        'PIIX3': ['pci_irq_levels', 'pci_irq_levels_vmstate'],
+        'piix4_pm': ['dev', 'parent_obj', 'pci0_status',
+                     'acpi_pci_hotplug.acpi_pcihp_pci_status[0x0]'],
+        'rtl8139': ['dev', 'parent_obj'],
+        'qxl': ['num_surfaces', 'ssd.num_surfaces'],
+        'usb-host': ['dev', 'parent_obj'],
+        'usb-mouse': ['usb-ptr-queue', 'HIDPointerEventQueue'],
+        'usb-tablet': ['usb-ptr-queue', 'HIDPointerEventQueue'],
+        'xhci': ['pci_dev', 'parent_obj'],
+        'xio3130-express-downstream-port': ['port.br.dev',
+                                            'parent_obj.parent_obj.parent_obj',
+                                            'port.br.dev.exp.aer_log',
+                                'parent_obj.parent_obj.parent_obj.exp.aer_log'],
+        'xio3130-express-upstream-port': ['br.dev', 'parent_obj.parent_obj',
+                                          'br.dev.exp.aer_log',
+                                          'parent_obj.parent_obj.exp.aer_log'],
+    }
+
+    if not name in changed_names:
+        return False
+
+    if s_field in changed_names[name] and d_field in changed_names[name]:
+        return True
+
+    return False
+
+
+def exists_in_substruct(fields, item):
+    # Some QEMU versions moved a few fields inside a substruct.  This
+    # kept the on-wire format the same.  This function checks if
+    # something got shifted inside a substruct.  For example, the
+    # change in commit 1f42d22233b4f3d1a2933ff30e8d6a6d9ee2d08f
+
+    if not "Description" in fields:
+        return False
+
+    if not "Fields" in fields["Description"]:
+        return False
+
+    substruct_fields = fields["Description"]["Fields"]
+
+    if substruct_fields == []:
+        return False
+
+    return check_fields_match(fields["Description"]["name"],
+                              substruct_fields[0]["field"], item)
+
+
+def check_fields(src_fields, dest_fields, desc, sec):
+    # This function checks for all the fields in a section.  If some
+    # fields got embedded into a substruct, this function will also
+    # attempt to check inside the substruct.
+
+    d_iter = iter(dest_fields)
+    s_iter = iter(src_fields)
+
+    # Using these lists as stacks to store previous value of s_iter
+    # and d_iter, so that when time comes to exit out of a substruct,
+    # we can go back one level up and continue from where we left off.
+
+    s_iter_list = []
+    d_iter_list = []
+
+    advance_src = True
+    advance_dest = True
+
+    while True:
+        if advance_src:
+            try:
+                s_item = s_iter.next()
+            except StopIteration:
+                if s_iter_list == []:
+                    break
+
+                s_iter = s_iter_list.pop()
+                continue
+        else:
+            # We want to avoid advancing just once -- when entering a
+            # dest substruct, or when exiting one.
+            advance_src = True
+
+        if advance_dest:
+            try:
+                d_item = d_iter.next()
+            except StopIteration:
+                if d_iter_list == []:
+                    # We were not in a substruct
+                    print "Section \"" + sec + "\",",
+                    print "Description " + "\"" + desc + "\":",
+                    print "expected field \"" + s_item["field"] + "\",",
+                    print "while dest has no further fields"
+                    bump_taint()
+                    break
+
+                d_iter = d_iter_list.pop()
+                advance_src = False
+                continue
+        else:
+            advance_dest = True
+
+        if not check_fields_match(desc, s_item["field"], d_item["field"]):
+            # Some fields were put in substructs, keeping the
+            # on-wire format the same, but breaking static tools
+            # like this one.
+
+            # First, check if dest has a new substruct.
+            if exists_in_substruct(d_item, s_item["field"]):
+                # listiterators don't have a prev() function, so we
+                # have to store our current location, descend into the
+                # substruct, and ensure we come out as if nothing
+                # happened when the substruct is over.
+                #
+                # Essentially we're opening the substructs that got
+                # added which didn't change the wire format.
+                d_iter_list.append(d_iter)
+                substruct_fields = d_item["Description"]["Fields"]
+                d_iter = iter(substruct_fields)
+                advance_src = False
+                continue
+
+            # Next, check if src has substruct that dest removed
+            # (can happen in backward migration: 2.0 -> 1.5)
+            if exists_in_substruct(s_item, d_item["field"]):
+                s_iter_list.append(s_iter)
+                substruct_fields = s_item["Description"]["Fields"]
+                s_iter = iter(substruct_fields)
+                advance_dest = False
+                continue
+
+            print "Section \"" + sec + "\",",
+            print "Description \"" + desc + "\":",
+            print "expected field \"" + s_item["field"] + "\",",
+            print "got \"" + d_item["field"] + "\"; skipping rest"
+            bump_taint()
+            break
+
+        check_version(s_item, d_item, sec, desc)
+
+        if not "Description" in s_item:
+            # Check size of this field only if it's not a VMSTRUCT entry
+            check_size(s_item, d_item, sec, desc, s_item["field"])
+
+        check_description_in_list(s_item, d_item, sec, desc)
+
+
+def check_subsections(src_sub, dest_sub, desc, sec):
+    for s_item in src_sub:
+        found = False
+        for d_item in dest_sub:
+            if s_item["name"] != d_item["name"]:
+                continue
+
+            found = True
+            check_descriptions(s_item, d_item, sec)
+
+        if not found:
+            print "Section \"" + sec + "\", Description \"" + desc + "\":",
+            print "Subsection \"" + s_item["name"] + "\" not found"
+            bump_taint()
+
+
+def check_description_in_list(s_item, d_item, sec, desc):
+    if not "Description" in s_item:
+        return
+
+    if not "Description" in d_item:
+        print "Section \"" + sec + "\", Description \"" + desc + "\",",
+        print "Field \"" + s_item["field"] + "\": missing description"
+        bump_taint()
+        return
+
+    check_descriptions(s_item["Description"], d_item["Description"], sec)
+
+
+def check_descriptions(src_desc, dest_desc, sec):
+    check_version(src_desc, dest_desc, sec, src_desc["name"])
+
+    if not check_fields_match(sec, src_desc["name"], dest_desc["name"]):
+        print "Section \"" + sec + "\":",
+        print "Description \"" + src_desc["name"] + "\"",
+        print "missing, got \"" + dest_desc["name"] + "\" instead; skipping"
+        bump_taint()
+        return
+
+    for f in src_desc:
+        if not f in dest_desc:
+            print "Section \"" + sec + "\"",
+            print "Description \"" + src_desc["name"] + "\":",
+            print "Entry \"" + f + "\" missing"
+            bump_taint()
+            continue
+
+        if f == 'Fields':
+            check_fields(src_desc[f], dest_desc[f], src_desc["name"], sec)
+
+        if f == 'Subsections':
+            check_subsections(src_desc[f], dest_desc[f], src_desc["name"], sec)
+
+
+def check_version(s, d, sec, desc=None):
+    if s["version_id"] > d["version_id"]:
+        print "Section \"" + sec + "\"",
+        if desc:
+            print "Description \"" + desc + "\":",
+        print "version error:", s["version_id"], ">", d["version_id"]
+        bump_taint()
+
+    if not "minimum_version_id" in d:
+        return
+
+    if s["version_id"] < d["minimum_version_id"]:
+        print "Section \"" + sec + "\"",
+        if desc:
+            print "Description \"" + desc + "\":",
+            print "minimum version error:", s["version_id"], "<",
+            print d["minimum_version_id"]
+            bump_taint()
+
+
+def check_size(s, d, sec, desc=None, field=None):
+    if s["size"] != d["size"]:
+        print "Section \"" + sec + "\"",
+        if desc:
+            print "Description \"" + desc + "\"",
+        if field:
+            print "Field \"" + field + "\"",
+        print "size mismatch:", s["size"], ",", d["size"]
+        bump_taint()
+
+
+def check_machine_type(s, d):
+    if s["Name"] != d["Name"]:
+        print "Warning: checking incompatible machine types:",
+        print "\"" + s["Name"] + "\", \"" + d["Name"] + "\""
+    return
+
+
+def main():
+    help_text = "Parse JSON-formatted vmstate dumps from QEMU in files SRC and DEST.  Checks whether migration from SRC to DEST QEMU versions would break based on the VMSTATE information contained within the JSON outputs.  The JSON output is created from a QEMU invocation with the -dump-vmstate parameter and a filename argument to it.  Other parameters to QEMU do not matter, except the -M (machine type) parameter."
+
+    parser = argparse.ArgumentParser(description=help_text)
+    parser.add_argument('-s', '--src', type=file, required=True,
+                        help='json dump from src qemu')
+    parser.add_argument('-d', '--dest', type=file, required=True,
+                        help='json dump from dest qemu')
+    parser.add_argument('--reverse', required=False, default=False,
+                        action='store_true',
+                        help='reverse the direction')
+    args = parser.parse_args()
+
+    src_data = json.load(args.src)
+    dest_data = json.load(args.dest)
+    args.src.close()
+    args.dest.close()
+
+    if args.reverse:
+        temp = src_data
+        src_data = dest_data
+        dest_data = temp
+
+    for sec in src_data:
+        if not sec in dest_data:
+            print "Section \"" + sec + "\" does not exist in dest"
+            bump_taint()
+            continue
+
+        s = src_data[sec]
+        d = dest_data[sec]
+
+        if sec == "vmschkmachine":
+            check_machine_type(s, d)
+            continue
+
+        check_version(s, d, sec)
+
+        for entry in s:
+            if not entry in d:
+                print "Section \"" + sec + "\": Entry \"" + entry + "\"",
+                print "missing"
+                bump_taint()
+                continue
+
+            if entry == "Description":
+                check_descriptions(s[entry], d[entry], sec)
+
+    return taint
+
+
+if __name__ == '__main__':
+    sys.exit(main())
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 04/22] tests: vmstate static checker: add dump1 and dump2 files
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (2 preceding siblings ...)
  2014-06-24 13:09 ` [Qemu-devel] [PULL 03/22] vmstate-static-checker: script to validate vmstate changes Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 05/22] tests: vmstate static checker: incompat machine types Juan Quintela
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

These are stripped-down JSON data as obtained from the -dump-vmstate
option.  The two files are identical in this commit, and will be
modified in the later commits to show what the script does with the
data.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump1.json | 1163 ++++++++++++++++++++++++++
 tests/vmstate-static-checker-data/dump2.json | 1163 ++++++++++++++++++++++++++
 2 files changed, 2326 insertions(+)
 create mode 100644 tests/vmstate-static-checker-data/dump1.json
 create mode 100644 tests/vmstate-static-checker-data/dump2.json

diff --git a/tests/vmstate-static-checker-data/dump1.json b/tests/vmstate-static-checker-data/dump1.json
new file mode 100644
index 0000000..44200fb
--- /dev/null
+++ b/tests/vmstate-static-checker-data/dump1.json
@@ -0,0 +1,1163 @@
+{
+  "vmschkmachine": {
+    "Name": "pc-i440fx-2.1"
+  },
+  "fw_cfg": {
+    "Name": "fw_cfg",
+    "version_id": 2,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "fw_cfg",
+      "version_id": 2,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "cur_entry",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 2
+        },
+        {
+          "field": "cur_offset",
+          "version_id": 0,
+          "field_exists": true,
+          "size": 4
+        },
+        {
+          "field": "cur_offset",
+          "version_id": 2,
+          "field_exists": false,
+          "size": 4
+        }
+      ]
+    }
+  },
+  "fusbh200-ehci-usb": {
+    "Name": "fusbh200-ehci-usb",
+    "version_id": 2,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "ehci-sysbus",
+      "version_id": 2,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "ehci",
+          "version_id": 2,
+          "field_exists": false,
+          "size": 1880,
+          "Description": {
+            "name": "ehci-core",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "usbcmd",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "usbsts",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "usbsts_pending",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "usbsts_frindex",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "usbintr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "frindex",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "ctrldssegment",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "periodiclistbase",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "asynclistaddr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "configflag",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[0]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[1]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[2]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[3]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[4]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[5]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "frame_timer",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 8
+              },
+              {
+                "field": "last_run_ns",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 8
+              },
+              {
+                "field": "async_stepdown",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "astate",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "pstate",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "a_fetch_addr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "p_fetch_addr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              }
+            ]
+          }
+        }
+      ]
+    }
+  },
+  "pci-serial-4x": {
+    "Name": "pci-serial-4x",
+    "version_id": 1,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "pci-serial-multi",
+      "version_id": 1,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "dev",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "state",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 368,
+          "Description": {
+            "name": "serial",
+            "version_id": 3,
+            "minimum_version_id": 2,
+            "Fields": [
+              {
+                "field": "divider",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 2
+              },
+              {
+                "field": "rbr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "ier",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "iir",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "lcr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "mcr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "lsr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "msr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "scr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "fcr_vmstate",
+                "version_id": 3,
+                "field_exists": false,
+                "size": 1
+              }
+            ]
+          }
+        },
+        {
+          "field": "level",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        }
+      ]
+    }
+  },
+  "intel-hda-generic": {
+    "Name": "intel-hda-generic",
+    "version_id": 1,
+    "minimum_version_id": 0,
+    "Description": {
+      "name": "intel-hda",
+      "version_id": 1,
+      "minimum_version_id": 0,
+      "Fields": [
+        {
+          "field": "pci",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "g_ctl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "wake_en",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "state_sts",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "int_ctl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "int_sts",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "wall_clk",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_lbase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_ubase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_rp",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_wp",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_ctl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_sts",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_size",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_lbase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_ubase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_wp",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_cnt",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_ctl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_sts",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_size",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "dp_lbase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "dp_ubase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "icw",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "irr",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "ics",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "st",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 56,
+          "Description": {
+            "name": "intel-hda-stream",
+            "version_id": 1,
+            "minimum_version_id": 0,
+            "Fields": [
+              {
+                "field": "ctl",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "lpib",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "cbl",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "lvi",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "fmt",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "bdlp_lbase",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "bdlp_ubase",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              }
+            ]
+          }
+        },
+        {
+          "field": "rirb_count",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "wall_base_ns",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        }
+      ]
+    }
+  },
+  "cfi.pflash01": {
+    "Name": "cfi.pflash01",
+    "version_id": 1,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "pflash_cfi01",
+      "version_id": 1,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "wcycle",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "cmd",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "status",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "counter",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        }
+      ]
+    }
+  },
+  "megasas": {
+    "Name": "megasas",
+    "version_id": 0,
+    "minimum_version_id": 0,
+    "Description": {
+      "name": "megasas",
+      "version_id": 0,
+      "minimum_version_id": 0,
+      "Fields": [
+        {
+          "field": "parent_obj",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "fw_state",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "intr_mask",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "doorbell",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "reply_queue_pa",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        },
+        {
+          "field": "consumer_pa",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        },
+        {
+          "field": "producer_pa",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        }
+      ]
+    }
+  },
+  "PIIX3-xen": {
+    "Name": "PIIX3-xen",
+    "version_id": 3,
+    "minimum_version_id": 2,
+    "Description": {
+      "name": "PIIX3",
+      "version_id": 3,
+      "minimum_version_id": 2,
+      "Fields": [
+        {
+          "field": "dev",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "pci_irq_levels_vmstate",
+          "version_id": 3,
+          "field_exists": false,
+          "size": 4
+        }
+      ],
+      "Subsections": [
+        {
+          "name": "PIIX3/rcr",
+          "version_id": 1,
+          "minimum_version_id": 1,
+          "Fields": [
+            {
+              "field": "rcr",
+              "version_id": 0,
+              "field_exists": false,
+              "size": 1
+            }
+          ]
+        }
+      ]
+    }
+  },
+  "tpci200": {
+    "Name": "tpci200",
+    "version_id": 1,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "tpci200",
+      "version_id": 1,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "dev",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "big_endian",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "ctrl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "status",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 2
+        },
+        {
+          "field": "int_set",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        }
+      ]
+    }
+  },
+  "SUNW,fdtwo": {
+    "Name": "SUNW,fdtwo",
+    "version_id": 2,
+    "minimum_version_id": 2,
+    "Description": {
+      "name": "fdc",
+      "version_id": 2,
+      "minimum_version_id": 2,
+      "Fields": [
+        {
+          "field": "state",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 360,
+          "Description": {
+            "name": "fdc",
+            "version_id": 2,
+            "minimum_version_id": 2,
+            "Fields": [
+              {
+                "field": "sra",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "srb",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "dor_vmstate",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "tdr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "dsr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "msr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "status0",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "status1",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "status2",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "fifo",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "data_pos",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "data_len",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "data_state",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "data_dir",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "eot",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "timer0",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "timer1",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "precomp_trk",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "lock",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "pwrd",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "num_floppies",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "drives",
+                "version_id": 1,
+                "field_exists": false,
+                "size": 40,
+                "Description": {
+                  "name": "fdrive",
+                  "version_id": 1,
+                  "minimum_version_id": 1,
+                  "Fields": [
+                    {
+                      "field": "head",
+                      "version_id": 0,
+                      "field_exists": false,
+                      "size": 1
+                    },
+                    {
+                      "field": "track",
+                      "version_id": 0,
+                      "field_exists": false,
+                      "size": 1
+                    },
+                    {
+                      "field": "sect",
+                      "version_id": 0,
+                      "field_exists": false,
+                      "size": 1
+                    }
+                  ],
+                  "Subsections": [
+                    {
+                      "name": "fdrive/media_changed",
+                      "version_id": 1,
+                      "minimum_version_id": 1,
+                      "Fields": [
+                        {
+                          "field": "media_changed",
+                          "version_id": 0,
+                          "field_exists": false,
+                          "size": 1
+                        }
+                      ]
+                    },
+                    {
+                      "name": "fdrive/media_rate",
+                      "version_id": 1,
+                      "minimum_version_id": 1,
+                      "Fields": [
+                        {
+                          "field": "media_rate",
+                          "version_id": 0,
+                          "field_exists": false,
+                          "size": 1
+                        }
+                      ]
+                    }
+                  ]
+                }
+              }
+            ]
+          }
+        }
+      ]
+    }
+  },
+  "usb-kbd": {
+    "Name": "usb-kbd",
+    "version_id": 1,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "usb-kbd",
+      "version_id": 1,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "dev",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4352,
+          "Description": {
+            "name": "USBDevice",
+            "version_id": 1,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "addr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "state",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "remote_wakeup",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "setup_state",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "setup_len",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "setup_index",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "setup_buf",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              }
+            ]
+          }
+        },
+        {
+          "field": "kbd.keycodes",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "head",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "n",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "kbd.modifiers",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 2
+        },
+        {
+          "field": "kbd.leds",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "kbd.key",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "kbd.keys",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "protocol",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "idle",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        }
+      ]
+    }
+  }
+}
diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
new file mode 100644
index 0000000..44200fb
--- /dev/null
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -0,0 +1,1163 @@
+{
+  "vmschkmachine": {
+    "Name": "pc-i440fx-2.1"
+  },
+  "fw_cfg": {
+    "Name": "fw_cfg",
+    "version_id": 2,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "fw_cfg",
+      "version_id": 2,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "cur_entry",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 2
+        },
+        {
+          "field": "cur_offset",
+          "version_id": 0,
+          "field_exists": true,
+          "size": 4
+        },
+        {
+          "field": "cur_offset",
+          "version_id": 2,
+          "field_exists": false,
+          "size": 4
+        }
+      ]
+    }
+  },
+  "fusbh200-ehci-usb": {
+    "Name": "fusbh200-ehci-usb",
+    "version_id": 2,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "ehci-sysbus",
+      "version_id": 2,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "ehci",
+          "version_id": 2,
+          "field_exists": false,
+          "size": 1880,
+          "Description": {
+            "name": "ehci-core",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "usbcmd",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "usbsts",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "usbsts_pending",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "usbsts_frindex",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "usbintr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "frindex",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "ctrldssegment",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "periodiclistbase",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "asynclistaddr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "configflag",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[0]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[1]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[2]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[3]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[4]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "portsc[5]",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "frame_timer",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 8
+              },
+              {
+                "field": "last_run_ns",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 8
+              },
+              {
+                "field": "async_stepdown",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "astate",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "pstate",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "a_fetch_addr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "p_fetch_addr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              }
+            ]
+          }
+        }
+      ]
+    }
+  },
+  "pci-serial-4x": {
+    "Name": "pci-serial-4x",
+    "version_id": 1,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "pci-serial-multi",
+      "version_id": 1,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "dev",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "state",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 368,
+          "Description": {
+            "name": "serial",
+            "version_id": 3,
+            "minimum_version_id": 2,
+            "Fields": [
+              {
+                "field": "divider",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 2
+              },
+              {
+                "field": "rbr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "ier",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "iir",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "lcr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "mcr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "lsr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "msr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "scr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "fcr_vmstate",
+                "version_id": 3,
+                "field_exists": false,
+                "size": 1
+              }
+            ]
+          }
+        },
+        {
+          "field": "level",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        }
+      ]
+    }
+  },
+  "intel-hda-generic": {
+    "Name": "intel-hda-generic",
+    "version_id": 1,
+    "minimum_version_id": 0,
+    "Description": {
+      "name": "intel-hda",
+      "version_id": 1,
+      "minimum_version_id": 0,
+      "Fields": [
+        {
+          "field": "pci",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "g_ctl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "wake_en",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "state_sts",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "int_ctl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "int_sts",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "wall_clk",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_lbase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_ubase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_rp",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_wp",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_ctl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_sts",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "corb_size",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_lbase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_ubase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_wp",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_cnt",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_ctl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_sts",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "rirb_size",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "dp_lbase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "dp_ubase",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "icw",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "irr",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "ics",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "st",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 56,
+          "Description": {
+            "name": "intel-hda-stream",
+            "version_id": 1,
+            "minimum_version_id": 0,
+            "Fields": [
+              {
+                "field": "ctl",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "lpib",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "cbl",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "lvi",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "fmt",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "bdlp_lbase",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "bdlp_ubase",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              }
+            ]
+          }
+        },
+        {
+          "field": "rirb_count",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "wall_base_ns",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        }
+      ]
+    }
+  },
+  "cfi.pflash01": {
+    "Name": "cfi.pflash01",
+    "version_id": 1,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "pflash_cfi01",
+      "version_id": 1,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "wcycle",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "cmd",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "status",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "counter",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        }
+      ]
+    }
+  },
+  "megasas": {
+    "Name": "megasas",
+    "version_id": 0,
+    "minimum_version_id": 0,
+    "Description": {
+      "name": "megasas",
+      "version_id": 0,
+      "minimum_version_id": 0,
+      "Fields": [
+        {
+          "field": "parent_obj",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "fw_state",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "intr_mask",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "doorbell",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "reply_queue_pa",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        },
+        {
+          "field": "consumer_pa",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        },
+        {
+          "field": "producer_pa",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 8
+        }
+      ]
+    }
+  },
+  "PIIX3-xen": {
+    "Name": "PIIX3-xen",
+    "version_id": 3,
+    "minimum_version_id": 2,
+    "Description": {
+      "name": "PIIX3",
+      "version_id": 3,
+      "minimum_version_id": 2,
+      "Fields": [
+        {
+          "field": "dev",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "pci_irq_levels_vmstate",
+          "version_id": 3,
+          "field_exists": false,
+          "size": 4
+        }
+      ],
+      "Subsections": [
+        {
+          "name": "PIIX3/rcr",
+          "version_id": 1,
+          "minimum_version_id": 1,
+          "Fields": [
+            {
+              "field": "rcr",
+              "version_id": 0,
+              "field_exists": false,
+              "size": 1
+            }
+          ]
+        }
+      ]
+    }
+  },
+  "tpci200": {
+    "Name": "tpci200",
+    "version_id": 1,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "tpci200",
+      "version_id": 1,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "dev",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1944,
+          "Description": {
+            "name": "PCIDevice",
+            "version_id": 2,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "version_id",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 256
+              },
+              {
+                "field": "irq_state",
+                "version_id": 2,
+                "field_exists": false,
+                "size": 16
+              }
+            ]
+          }
+        },
+        {
+          "field": "big_endian",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "ctrl",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "status",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 2
+        },
+        {
+          "field": "int_set",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        }
+      ]
+    }
+  },
+  "SUNW,fdtwo": {
+    "Name": "SUNW,fdtwo",
+    "version_id": 2,
+    "minimum_version_id": 2,
+    "Description": {
+      "name": "fdc",
+      "version_id": 2,
+      "minimum_version_id": 2,
+      "Fields": [
+        {
+          "field": "state",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 360,
+          "Description": {
+            "name": "fdc",
+            "version_id": 2,
+            "minimum_version_id": 2,
+            "Fields": [
+              {
+                "field": "sra",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "srb",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "dor_vmstate",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "tdr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "dsr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "msr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "status0",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "status1",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "status2",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "fifo",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "data_pos",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "data_len",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "data_state",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "data_dir",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "eot",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "timer0",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "timer1",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "precomp_trk",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "config",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "lock",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "pwrd",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "num_floppies",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "drives",
+                "version_id": 1,
+                "field_exists": false,
+                "size": 40,
+                "Description": {
+                  "name": "fdrive",
+                  "version_id": 1,
+                  "minimum_version_id": 1,
+                  "Fields": [
+                    {
+                      "field": "head",
+                      "version_id": 0,
+                      "field_exists": false,
+                      "size": 1
+                    },
+                    {
+                      "field": "track",
+                      "version_id": 0,
+                      "field_exists": false,
+                      "size": 1
+                    },
+                    {
+                      "field": "sect",
+                      "version_id": 0,
+                      "field_exists": false,
+                      "size": 1
+                    }
+                  ],
+                  "Subsections": [
+                    {
+                      "name": "fdrive/media_changed",
+                      "version_id": 1,
+                      "minimum_version_id": 1,
+                      "Fields": [
+                        {
+                          "field": "media_changed",
+                          "version_id": 0,
+                          "field_exists": false,
+                          "size": 1
+                        }
+                      ]
+                    },
+                    {
+                      "name": "fdrive/media_rate",
+                      "version_id": 1,
+                      "minimum_version_id": 1,
+                      "Fields": [
+                        {
+                          "field": "media_rate",
+                          "version_id": 0,
+                          "field_exists": false,
+                          "size": 1
+                        }
+                      ]
+                    }
+                  ]
+                }
+              }
+            ]
+          }
+        }
+      ]
+    }
+  },
+  "usb-kbd": {
+    "Name": "usb-kbd",
+    "version_id": 1,
+    "minimum_version_id": 1,
+    "Description": {
+      "name": "usb-kbd",
+      "version_id": 1,
+      "minimum_version_id": 1,
+      "Fields": [
+        {
+          "field": "dev",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4352,
+          "Description": {
+            "name": "USBDevice",
+            "version_id": 1,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "addr",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "state",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "remote_wakeup",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "setup_state",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "setup_len",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "setup_index",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "setup_buf",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              }
+            ]
+          }
+        },
+        {
+          "field": "kbd.keycodes",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "head",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "n",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "kbd.modifiers",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 2
+        },
+        {
+          "field": "kbd.leds",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "kbd.key",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        },
+        {
+          "field": "kbd.keys",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "protocol",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 4
+        },
+        {
+          "field": "idle",
+          "version_id": 0,
+          "field_exists": false,
+          "size": 1
+        }
+      ]
+    }
+  }
+}
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 05/22] tests: vmstate static checker: incompat machine types
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (3 preceding siblings ...)
  2014-06-24 13:09 ` [Qemu-devel] [PULL 04/22] tests: vmstate static checker: add dump1 and dump2 files Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 06/22] tests: vmstate static checker: add version error in main section Juan Quintela
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

This commit modifies the dump2 data to flag incompatibilities in the
machine types being compared.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 44200fb..0a8b81d 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -1,6 +1,6 @@
 {
   "vmschkmachine": {
-    "Name": "pc-i440fx-2.1"
+    "Name": "pc-i440fx-2.2"
   },
   "fw_cfg": {
     "Name": "fw_cfg",
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 06/22] tests: vmstate static checker: add version error in main section
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (4 preceding siblings ...)
  2014-06-24 13:09 ` [Qemu-devel] [PULL 05/22] tests: vmstate static checker: incompat machine types Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 07/22] tests: vmstate static checker: version mismatch inside a Description Juan Quintela
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 0a8b81d..f405534 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -34,7 +34,7 @@
   },
   "fusbh200-ehci-usb": {
     "Name": "fusbh200-ehci-usb",
-    "version_id": 2,
+    "version_id": 1,
     "minimum_version_id": 1,
     "Description": {
       "name": "ehci-sysbus",
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 07/22] tests: vmstate static checker: version mismatch inside a Description
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (5 preceding siblings ...)
  2014-06-24 13:09 ` [Qemu-devel] [PULL 06/22] tests: vmstate static checker: add version error in main section Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 08/22] tests: vmstate static checker: minimum_version_id check Juan Quintela
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index f405534..36a9b4b 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -829,7 +829,7 @@
     "minimum_version_id": 2,
     "Description": {
       "name": "fdc",
-      "version_id": 2,
+      "version_id": 1,
       "minimum_version_id": 2,
       "Fields": [
         {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 08/22] tests: vmstate static checker: minimum_version_id check
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (6 preceding siblings ...)
  2014-06-24 13:09 ` [Qemu-devel] [PULL 07/22] tests: vmstate static checker: version mismatch inside a Description Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:09 ` [Qemu-devel] [PULL 09/22] tests: vmstate static checker: remove a section Juan Quintela
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump1.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vmstate-static-checker-data/dump1.json b/tests/vmstate-static-checker-data/dump1.json
index 44200fb..786ca0b 100644
--- a/tests/vmstate-static-checker-data/dump1.json
+++ b/tests/vmstate-static-checker-data/dump1.json
@@ -698,7 +698,7 @@
     "minimum_version_id": 2,
     "Description": {
       "name": "PIIX3",
-      "version_id": 3,
+      "version_id": 1,
       "minimum_version_id": 2,
       "Fields": [
         {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 09/22] tests: vmstate static checker: remove a section
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (7 preceding siblings ...)
  2014-06-24 13:09 ` [Qemu-devel] [PULL 08/22] tests: vmstate static checker: minimum_version_id check Juan Quintela
@ 2014-06-24 13:09 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 10/22] tests: vmstate static checker: remove a field Juan Quintela
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 36a9b4b..4ccfd67 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -2,7 +2,7 @@
   "vmschkmachine": {
     "Name": "pc-i440fx-2.2"
   },
-  "fw_cfg": {
+  "fw_cfg2": {
     "Name": "fw_cfg",
     "version_id": 2,
     "minimum_version_id": 1,
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 10/22] tests: vmstate static checker: remove a field
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (8 preceding siblings ...)
  2014-06-24 13:09 ` [Qemu-devel] [PULL 09/22] tests: vmstate static checker: remove a section Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 11/22] tests: vmstate static checker: remove last field in a struct Juan Quintela
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 4ccfd67..f6b52d0 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -58,12 +58,6 @@
                 "size": 4
               },
               {
-                "field": "usbsts",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 4
-              },
-              {
                 "field": "usbsts_pending",
                 "version_id": 2,
                 "field_exists": false,
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 11/22] tests: vmstate static checker: remove last field in a struct
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (9 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 10/22] tests: vmstate static checker: remove a field Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 12/22] tests: vmstate static checker: change description name Juan Quintela
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index f6b52d0..34bfbf6 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -637,12 +637,6 @@
                 "version_id": 0,
                 "field_exists": false,
                 "size": 256
-              },
-              {
-                "field": "irq_state",
-                "version_id": 2,
-                "field_exists": false,
-                "size": 16
               }
             ]
           }
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 12/22] tests: vmstate static checker: change description name
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (10 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 11/22] tests: vmstate static checker: remove last field in a struct Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 13/22] tests: vmstate static checker: remove Fields Juan Quintela
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 34bfbf6..f69966d 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -749,7 +749,7 @@
     "version_id": 1,
     "minimum_version_id": 1,
     "Description": {
-      "name": "tpci200",
+      "name": "tpci2002",
       "version_id": 1,
       "minimum_version_id": 1,
       "Fields": [
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 13/22] tests: vmstate static checker: remove Fields
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (11 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 12/22] tests: vmstate static checker: change description name Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 14/22] tests: vmstate static checker: remove Description Juan Quintela
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 114 +--------------------------
 1 file changed, 1 insertion(+), 113 deletions(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index f69966d..cc0aae3 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -196,119 +196,7 @@
     "Description": {
       "name": "pci-serial-multi",
       "version_id": 1,
-      "minimum_version_id": 1,
-      "Fields": [
-        {
-          "field": "dev",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 1944,
-          "Description": {
-            "name": "PCIDevice",
-            "version_id": 2,
-            "minimum_version_id": 1,
-            "Fields": [
-              {
-                "field": "version_id",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 4
-              },
-              {
-                "field": "config",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 256
-              },
-              {
-                "field": "irq_state",
-                "version_id": 2,
-                "field_exists": false,
-                "size": 16
-              }
-            ]
-          }
-        },
-        {
-          "field": "state",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 368,
-          "Description": {
-            "name": "serial",
-            "version_id": 3,
-            "minimum_version_id": 2,
-            "Fields": [
-              {
-                "field": "divider",
-                "version_id": 2,
-                "field_exists": false,
-                "size": 2
-              },
-              {
-                "field": "rbr",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 1
-              },
-              {
-                "field": "ier",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 1
-              },
-              {
-                "field": "iir",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 1
-              },
-              {
-                "field": "lcr",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 1
-              },
-              {
-                "field": "mcr",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 1
-              },
-              {
-                "field": "lsr",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 1
-              },
-              {
-                "field": "msr",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 1
-              },
-              {
-                "field": "scr",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 1
-              },
-              {
-                "field": "fcr_vmstate",
-                "version_id": 3,
-                "field_exists": false,
-                "size": 1
-              }
-            ]
-          }
-        },
-        {
-          "field": "level",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 4
-        }
-      ]
+      "minimum_version_id": 1
     }
   },
   "intel-hda-generic": {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 14/22] tests: vmstate static checker: remove Description
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (12 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 13/22] tests: vmstate static checker: remove Fields Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 15/22] tests: vmstate static checker: remove Description inside Fields Juan Quintela
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 33 +---------------------------
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index cc0aae3..66ac3bd 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -462,38 +462,7 @@
   "cfi.pflash01": {
     "Name": "cfi.pflash01",
     "version_id": 1,
-    "minimum_version_id": 1,
-    "Description": {
-      "name": "pflash_cfi01",
-      "version_id": 1,
-      "minimum_version_id": 1,
-      "Fields": [
-        {
-          "field": "wcycle",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 1
-        },
-        {
-          "field": "cmd",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 1
-        },
-        {
-          "field": "status",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 1
-        },
-        {
-          "field": "counter",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 8
-        }
-      ]
-    }
+    "minimum_version_id": 1
   },
   "megasas": {
     "Name": "megasas",
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 15/22] tests: vmstate static checker: remove Description inside Fields
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (13 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 14/22] tests: vmstate static checker: remove Description Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 16/22] tests: vmstate static checker: remove a subsection Juan Quintela
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 27 +--------------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 66ac3bd..05b8fce 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -212,32 +212,7 @@
           "field": "pci",
           "version_id": 0,
           "field_exists": false,
-          "size": 1944,
-          "Description": {
-            "name": "PCIDevice",
-            "version_id": 2,
-            "minimum_version_id": 1,
-            "Fields": [
-              {
-                "field": "version_id",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 4
-              },
-              {
-                "field": "config",
-                "version_id": 0,
-                "field_exists": false,
-                "size": 256
-              },
-              {
-                "field": "irq_state",
-                "version_id": 2,
-                "field_exists": false,
-                "size": 16
-              }
-            ]
-          }
+          "size": 1944
         },
         {
           "field": "g_ctl",
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 16/22] tests: vmstate static checker: remove a subsection
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (14 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 15/22] tests: vmstate static checker: remove Description inside Fields Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 17/22] tests: vmstate static checker: remove Subsections Juan Quintela
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 05b8fce..6f8a617 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -836,19 +836,6 @@
                           "size": 1
                         }
                       ]
-                    },
-                    {
-                      "name": "fdrive/media_rate",
-                      "version_id": 1,
-                      "minimum_version_id": 1,
-                      "Fields": [
-                        {
-                          "field": "media_rate",
-                          "version_id": 0,
-                          "field_exists": false,
-                          "size": 1
-                        }
-                      ]
                     }
                   ]
                 }
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 17/22] tests: vmstate static checker: remove Subsections
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (15 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 16/22] tests: vmstate static checker: remove a subsection Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 18/22] tests: vmstate static checker: add substructure for usb-kbd for hid section Juan Quintela
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 6f8a617..b5cb1aa 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -558,21 +558,6 @@
           "field_exists": false,
           "size": 4
         }
-      ],
-      "Subsections": [
-        {
-          "name": "PIIX3/rcr",
-          "version_id": 1,
-          "minimum_version_id": 1,
-          "Fields": [
-            {
-              "field": "rcr",
-              "version_id": 0,
-              "field_exists": false,
-              "size": 1
-            }
-          ]
-        }
       ]
     }
   },
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 18/22] tests: vmstate static checker: add substructure for usb-kbd for hid section
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (16 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 17/22] tests: vmstate static checker: remove Subsections Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 19/22] tests: vmstate static checker: add size mismatch inside substructure Juan Quintela
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

This shows how the script deals with substructures added to vmstate
descriptions that don't change the on-wire format.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 115 +++++++++++++++------------
 1 file changed, 64 insertions(+), 51 deletions(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index b5cb1aa..45cccaf 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -844,7 +844,7 @@
           "field": "dev",
           "version_id": 0,
           "field_exists": false,
-          "size": 4352,
+          "size": 5832,
           "Description": {
             "name": "USBDevice",
             "version_id": 1,
@@ -896,58 +896,71 @@
           }
         },
         {
-          "field": "kbd.keycodes",
+          "field": "hid",
           "version_id": 0,
           "field_exists": false,
-          "size": 4
-        },
-        {
-          "field": "head",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 4
-        },
-        {
-          "field": "n",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 4
-        },
-        {
-          "field": "kbd.modifiers",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 2
-        },
-        {
-          "field": "kbd.leds",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 1
-        },
-        {
-          "field": "kbd.key",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 1
-        },
-        {
-          "field": "kbd.keys",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 4
-        },
-        {
-          "field": "protocol",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 4
-        },
-        {
-          "field": "idle",
-          "version_id": 0,
-          "field_exists": false,
-          "size": 1
+          "size": 312,
+          "Description": {
+            "name": "HIDKeyboardDevice",
+            "version_id": 1,
+            "minimum_version_id": 1,
+            "Fields": [
+              {
+                "field": "kbd.keycodes",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "head",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "n",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "kbd.modifiers",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 2
+              },
+              {
+                "field": "kbd.leds",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "kbd.key",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              },
+              {
+                "field": "kbd.keys",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "protocol",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 4
+              },
+              {
+                "field": "idle",
+                "version_id": 0,
+                "field_exists": false,
+                "size": 1
+              }
+            ]
+          }
         }
       ]
     }
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 19/22] tests: vmstate static checker: add size mismatch inside substructure
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (17 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 18/22] tests: vmstate static checker: add substructure for usb-kbd for hid section Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 20/22] migration: Remove unneeded minimum_version_id_old Juan Quintela
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah

From: Amit Shah <amit.shah@redhat.com>

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/vmstate-static-checker-data/dump2.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/vmstate-static-checker-data/dump2.json b/tests/vmstate-static-checker-data/dump2.json
index 45cccaf..75719f5 100644
--- a/tests/vmstate-static-checker-data/dump2.json
+++ b/tests/vmstate-static-checker-data/dump2.json
@@ -909,7 +909,7 @@
                 "field": "kbd.keycodes",
                 "version_id": 0,
                 "field_exists": false,
-                "size": 4
+                "size": 2
               },
               {
                 "field": "head",
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 20/22] migration: Remove unneeded minimum_version_id_old
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (18 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 19/22] tests: vmstate static checker: add size mismatch inside substructure Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 21/22] vmstate: Return error in case of error Juan Quintela
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel

Once there, make checkpatch happy.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 hw/usb/hcd-ohci.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index cd87074..cace945 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1988,8 +1988,7 @@ static const VMStateDescription vmstate_ohci_state_port = {
     .name = "ohci-core/port",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(ctrl, OHCIPort),
         VMSTATE_END_OF_LIST()
     },
@@ -2015,9 +2014,8 @@ static const VMStateDescription vmstate_ohci_eof_timer = {
     .name = "ohci-core/eof-timer",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .pre_load = ohci_eof_timer_pre_load,
-    .fields = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_TIMER(eof_timer, OHCIState),
         VMSTATE_END_OF_LIST()
     },
@@ -2078,7 +2076,6 @@ static const VMStateDescription vmstate_ohci = {
     .name = "ohci",
     .version_id = 1,
     .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
     .fields = (VMStateField[]) {
         VMSTATE_PCI_DEVICE(parent_obj, OHCIPCIState),
         VMSTATE_STRUCT(state, OHCIPCIState, 1, vmstate_ohci_state, OHCIState),
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 21/22] vmstate: Return error in case of error
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (19 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 20/22] migration: Remove unneeded minimum_version_id_old Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 13:10 ` [Qemu-devel] [PULL 22/22] vmstate: Refactor & increase tests for primitive types Juan Quintela
  2014-06-24 15:10 ` [Qemu-devel] [PULL 00/22] Migration queue Peter Maydell
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel

If there is an error while loading a field, we should stop reading and
not continue with the rest of fields.  And we should also set an error
in qemu_file.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 vmstate.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/vmstate.c b/vmstate.c
index b5882fa..c996520 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -98,7 +98,11 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
                     ret = field->info->get(f, addr, size);

                 }
+                if (ret >= 0) {
+                    ret = qemu_file_get_error(f);
+                }
                 if (ret < 0) {
+                    qemu_file_set_error(f, ret);
                     trace_vmstate_load_field_error(field->name, ret);
                     return ret;
                 }
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [Qemu-devel] [PULL 22/22] vmstate: Refactor & increase tests for primitive types
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (20 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 21/22] vmstate: Return error in case of error Juan Quintela
@ 2014-06-24 13:10 ` Juan Quintela
  2014-06-24 15:10 ` [Qemu-devel] [PULL 00/22] Migration queue Peter Maydell
  22 siblings, 0 replies; 24+ messages in thread
From: Juan Quintela @ 2014-06-24 13:10 UTC (permalink / raw)
  To: qemu-devel

This commit refactor the simple tests to test all integer types. We
move to hex because it is easier to read values of different types.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 tests/test-vmstate.c | 273 +++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 212 insertions(+), 61 deletions(-)

diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c
index 8b242c4..a462335 100644
--- a/tests/test-vmstate.c
+++ b/tests/test-vmstate.c
@@ -54,80 +54,232 @@ static QEMUFile *open_test_file(bool write)
     return qemu_fdopen(fd, write ? "wb" : "rb");
 }

-typedef struct TestSruct {
-    uint32_t a, b, c, e;
-    uint64_t d, f;
-    bool skip_c_e;
-} TestStruct;
+#define SUCCESS(val) \
+    g_assert_cmpint((val), ==, 0)

+#define FAILURE(val) \
+    g_assert_cmpint((val), !=, 0)

-static const VMStateDescription vmstate_simple = {
-    .name = "test",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .fields = (VMStateField[]) {
-        VMSTATE_UINT32(a, TestStruct),
-        VMSTATE_UINT32(b, TestStruct),
-        VMSTATE_UINT32(c, TestStruct),
-        VMSTATE_UINT64(d, TestStruct),
-        VMSTATE_END_OF_LIST()
-    }
-};
+static void save_vmstate(const VMStateDescription *desc, void *obj)
+{
+    QEMUFile *f = open_test_file(true);
+
+    /* Save file with vmstate */
+    vmstate_save_state(f, desc, obj);
+    qemu_put_byte(f, QEMU_VM_EOF);
+    g_assert(!qemu_file_get_error(f));
+    qemu_fclose(f);
+}

-static void test_simple_save(void)
+static void compare_vmstate(uint8_t *wire, size_t size)
 {
-    QEMUFile *fsave = open_test_file(true);
-    TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4 };
-    vmstate_save_state(fsave, &vmstate_simple, &obj);
-    g_assert(!qemu_file_get_error(fsave));
-    qemu_fclose(fsave);
+    QEMUFile *f = open_test_file(false);
+    uint8_t result[size];

-    QEMUFile *loading = open_test_file(false);
-    uint8_t expected[] = {
-        0, 0, 0, 1, /* a */
-        0, 0, 0, 2, /* b */
-        0, 0, 0, 3, /* c */
-        0, 0, 0, 0, 0, 0, 0, 4, /* d */
-    };
-    uint8_t result[sizeof(expected)];
-    g_assert_cmpint(qemu_get_buffer(loading, result, sizeof(result)), ==,
+    /* read back as binary */
+
+    g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==,
                     sizeof(result));
-    g_assert(!qemu_file_get_error(loading));
-    g_assert_cmpint(memcmp(result, expected, sizeof(result)), ==, 0);
+    g_assert(!qemu_file_get_error(f));
+
+    /* Compare that what is on the file is the same that what we
+       expected to be there */
+    SUCCESS(memcmp(result, wire, sizeof(result)));

     /* Must reach EOF */
-    qemu_get_byte(loading);
-    g_assert_cmpint(qemu_file_get_error(loading), ==, -EIO);
+    qemu_get_byte(f);
+    g_assert_cmpint(qemu_file_get_error(f), ==, -EIO);

-    qemu_fclose(loading);
+    qemu_fclose(f);
 }

-static void test_simple_load(void)
+static int load_vmstate_one(const VMStateDescription *desc, void *obj,
+                            int version, uint8_t *wire, size_t size)
 {
-    QEMUFile *fsave = open_test_file(true);
-    uint8_t buf[] = {
-        0, 0, 0, 10,             /* a */
-        0, 0, 0, 20,             /* b */
-        0, 0, 0, 30,             /* c */
-        0, 0, 0, 0, 0, 0, 0, 40, /* d */
-        QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
-    };
-    qemu_put_buffer(fsave, buf, sizeof(buf));
-    qemu_fclose(fsave);
+    QEMUFile *f;
+    int ret;
+
+    f = open_test_file(true);
+    qemu_put_buffer(f, wire, size);
+    qemu_fclose(f);
+
+    f = open_test_file(false);
+    ret = vmstate_load_state(f, desc, obj, version);
+    if (ret) {
+        g_assert(qemu_file_get_error(f));
+    } else{
+        g_assert(!qemu_file_get_error(f));
+    }
+    qemu_fclose(f);
+    return ret;
+}

-    QEMUFile *loading = open_test_file(false);
-    TestStruct obj;
-    vmstate_load_state(loading, &vmstate_simple, &obj, 1);
-    g_assert(!qemu_file_get_error(loading));
-    g_assert_cmpint(obj.a, ==, 10);
-    g_assert_cmpint(obj.b, ==, 20);
-    g_assert_cmpint(obj.c, ==, 30);
-    g_assert_cmpint(obj.d, ==, 40);
-    qemu_fclose(loading);
+
+static int load_vmstate(const VMStateDescription *desc,
+                        void *obj, void *obj_clone,
+                        void (*obj_copy)(void *, void*),
+                        int version, uint8_t *wire, size_t size)
+{
+    /* We test with zero size */
+    obj_copy(obj_clone, obj);
+    FAILURE(load_vmstate_one(desc, obj, version, wire, 0));
+
+    /* Stream ends with QEMU_EOF, so we need at least 3 bytes to be
+     * able to test in the middle */
+
+    if (size > 3) {
+
+        /* We test with size - 2. We can't test size - 1 due to EOF tricks */
+        obj_copy(obj, obj_clone);
+        FAILURE(load_vmstate_one(desc, obj, version, wire, size - 2));
+
+        /* Test with size/2, first half of real state */
+        obj_copy(obj, obj_clone);
+        FAILURE(load_vmstate_one(desc, obj, version, wire, size/2));
+
+        /* Test with size/2, second half of real state */
+        obj_copy(obj, obj_clone);
+        FAILURE(load_vmstate_one(desc, obj, version, wire + (size/2), size/2));
+
+    }
+    obj_copy(obj, obj_clone);
+    return load_vmstate_one(desc, obj, version, wire, size);
+}
+
+/* Test struct that we are going to use for our tests */
+
+typedef struct TestSimple {
+    bool     b_1,   b_2;
+    uint8_t  u8_1;
+    uint16_t u16_1;
+    uint32_t u32_1;
+    uint64_t u64_1;
+    int8_t   i8_1,  i8_2;
+    int16_t  i16_1, i16_2;
+    int32_t  i32_1, i32_2;
+    int64_t  i64_1, i64_2;
+} TestSimple;
+
+/* Object instantiation, we are going to use it in more than one test */
+
+TestSimple obj_simple = {
+    .b_1 = true,
+    .b_2 = false,
+    .u8_1 = 130,
+    .u16_1 = 512,
+    .u32_1 = 70000,
+    .u64_1 = 12121212,
+    .i8_1 = 65,
+    .i8_2 = -65,
+    .i16_1 = 512,
+    .i16_2 = -512,
+    .i32_1 = 70000,
+    .i32_2 = -70000,
+    .i64_1 = 12121212,
+    .i64_2 = -12121212,
+};
+
+/* Description of the values.  If you add a primitive type
+   you are expected to add a test here */
+
+static const VMStateDescription vmstate_simple_primitive = {
+    .name = "simple/primitive",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_BOOL(b_1, TestSimple),
+        VMSTATE_BOOL(b_2, TestSimple),
+        VMSTATE_UINT8(u8_1, TestSimple),
+        VMSTATE_UINT16(u16_1, TestSimple),
+        VMSTATE_UINT32(u32_1, TestSimple),
+        VMSTATE_UINT64(u64_1, TestSimple),
+        VMSTATE_INT8(i8_1, TestSimple),
+        VMSTATE_INT8(i8_2, TestSimple),
+        VMSTATE_INT16(i16_1, TestSimple),
+        VMSTATE_INT16(i16_2, TestSimple),
+        VMSTATE_INT32(i32_1, TestSimple),
+        VMSTATE_INT32(i32_2, TestSimple),
+        VMSTATE_INT64(i64_1, TestSimple),
+        VMSTATE_INT64(i64_2, TestSimple),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+/* It describes what goes through the wire.  Our tests are basically:
+
+   * save test
+     - save a struct a vmstate to a file
+     - read that file back (binary read, no vmstate)
+     - compare it with what we expect to be on the wire
+   * load test
+     - save to the file what we expect to be on the wire
+     - read struct back with vmstate in a different
+     - compare back with the original struct
+*/
+
+uint8_t wire_simple_primitive[] = {
+    /* b_1 */   0x01,
+    /* b_2 */   0x00,
+    /* u8_1 */  0x82,
+    /* u16_1 */ 0x02, 0x00,
+    /* u32_1 */ 0x00, 0x01, 0x11, 0x70,
+    /* u64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
+    /* i8_1 */  0x41,
+    /* i8_2 */  0xbf,
+    /* i16_1 */ 0x02, 0x00,
+    /* i16_2 */ 0xfe, 0x0,
+    /* i32_1 */ 0x00, 0x01, 0x11, 0x70,
+    /* i32_2 */ 0xff, 0xfe, 0xee, 0x90,
+    /* i64_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0xf4, 0x7c,
+    /* i64_2 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x0b, 0x84,
+    QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
+};
+
+static void obj_simple_copy(void *target, void *source)
+{
+    memcpy(target, source, sizeof(TestSimple));
+}
+
+static void test_simple_primitive(void)
+{
+    TestSimple obj, obj_clone;
+
+    memset(&obj, 0, sizeof(obj));
+    save_vmstate(&vmstate_simple_primitive, &obj_simple);
+
+    compare_vmstate(wire_simple_primitive, sizeof(wire_simple_primitive));
+
+    SUCCESS(load_vmstate(&vmstate_simple_primitive, &obj, &obj_clone,
+                         obj_simple_copy, 1, wire_simple_primitive,
+                         sizeof(wire_simple_primitive)));
+
+#define FIELD_EQUAL(name)   g_assert_cmpint(obj.name, ==, obj_simple.name)
+
+    FIELD_EQUAL(b_1);
+    FIELD_EQUAL(b_2);
+    FIELD_EQUAL(u8_1);
+    FIELD_EQUAL(u16_1);
+    FIELD_EQUAL(u32_1);
+    FIELD_EQUAL(u64_1);
+    FIELD_EQUAL(i8_1);
+    FIELD_EQUAL(i8_2);
+    FIELD_EQUAL(i16_1);
+    FIELD_EQUAL(i16_2);
+    FIELD_EQUAL(i32_1);
+    FIELD_EQUAL(i32_2);
+    FIELD_EQUAL(i64_1);
+    FIELD_EQUAL(i64_2);
 }
+#undef FIELD_EQUAL
+
+typedef struct TestStruct {
+    uint32_t a, b, c, e;
+    uint64_t d, f;
+    bool skip_c_e;
+} TestStruct;

 static const VMStateDescription vmstate_versioned = {
-    .name = "test",
+    .name = "test/versioned",
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
@@ -202,7 +354,7 @@ static bool test_skip(void *opaque, int version_id)
 }

 static const VMStateDescription vmstate_skipping = {
-    .name = "test",
+    .name = "test/skip",
     .version_id = 2,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
@@ -337,8 +489,7 @@ int main(int argc, char **argv)
     temp_fd = mkstemp(temp_file);

     g_test_init(&argc, &argv, NULL);
-    g_test_add_func("/vmstate/simple/save", test_simple_save);
-    g_test_add_func("/vmstate/simple/load", test_simple_load);
+    g_test_add_func("/vmstate/simple/primitive", test_simple_primitive);
     g_test_add_func("/vmstate/versioned/load/v1", test_load_v1);
     g_test_add_func("/vmstate/versioned/load/v2", test_load_v2);
     g_test_add_func("/vmstate/field_exists/load/noskip", test_load_noskip);
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [Qemu-devel] [PULL 00/22] Migration queue
  2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
                   ` (21 preceding siblings ...)
  2014-06-24 13:10 ` [Qemu-devel] [PULL 22/22] vmstate: Refactor & increase tests for primitive types Juan Quintela
@ 2014-06-24 15:10 ` Peter Maydell
  22 siblings, 0 replies; 24+ messages in thread
From: Peter Maydell @ 2014-06-24 15:10 UTC (permalink / raw)
  To: Juan Quintela; +Cc: QEMU Developers

On 24 June 2014 14:09, Juan Quintela <quintela@redhat.com> wrote:
> Hi
>
> Peter, please pull:
>
>
> - RDMA bugfixes (Michael)
> - Static checker from Amit (v5)
> - acked patches from vmstate (thanks Dave)
>
> Later, Juan.
>
>
> The following changes since commit d9c1647d896d3192cba9dbf98fb7efab876edde5:
>
>   Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2014-06-23 12:55:22 +0100)
>
> are available in the git repository at:
>
>
>   git://github.com/juanquintela/qemu.git tags/migration/20140623
>
> for you to fetch changes up to 4ea7df4e5c6b9d8b8a474680d6b1687fc8eacbac:
>
>   vmstate: Refactor & increase tests for primitive types (2014-06-23 19:14:52 +0200)

> ----------------------------------------------------------------
> migration/next for 20140623

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2014-06-24 15:11 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-24 13:09 [Qemu-devel] [PULL 00/22] Migration queue Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 01/22] rdma: bug fixes Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 02/22] migration: dump vmstate info as a json file for static analysis Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 03/22] vmstate-static-checker: script to validate vmstate changes Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 04/22] tests: vmstate static checker: add dump1 and dump2 files Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 05/22] tests: vmstate static checker: incompat machine types Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 06/22] tests: vmstate static checker: add version error in main section Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 07/22] tests: vmstate static checker: version mismatch inside a Description Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 08/22] tests: vmstate static checker: minimum_version_id check Juan Quintela
2014-06-24 13:09 ` [Qemu-devel] [PULL 09/22] tests: vmstate static checker: remove a section Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 10/22] tests: vmstate static checker: remove a field Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 11/22] tests: vmstate static checker: remove last field in a struct Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 12/22] tests: vmstate static checker: change description name Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 13/22] tests: vmstate static checker: remove Fields Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 14/22] tests: vmstate static checker: remove Description Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 15/22] tests: vmstate static checker: remove Description inside Fields Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 16/22] tests: vmstate static checker: remove a subsection Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 17/22] tests: vmstate static checker: remove Subsections Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 18/22] tests: vmstate static checker: add substructure for usb-kbd for hid section Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 19/22] tests: vmstate static checker: add size mismatch inside substructure Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 20/22] migration: Remove unneeded minimum_version_id_old Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 21/22] vmstate: Return error in case of error Juan Quintela
2014-06-24 13:10 ` [Qemu-devel] [PULL 22/22] vmstate: Refactor & increase tests for primitive types Juan Quintela
2014-06-24 15:10 ` [Qemu-devel] [PULL 00/22] Migration queue Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.