]> git.proxmox.com Git - mirror_qemu.git/blobdiff - scripts/vmstate-static-checker.py
exec.c: get nodes_nb_alloc with one MAX calculation
[mirror_qemu.git] / scripts / vmstate-static-checker.py
index f7ce3fc483cb12ec3a6f5ece74db75edac1dbd27..d3467288dcc5dd2f7274576262f7801e468faa72 100755 (executable)
@@ -19,6 +19,7 @@
 # You should have received a copy of the GNU General Public License along
 # with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 import argparse
 import json
 import sys
@@ -53,6 +54,8 @@ def check_fields_match(name, s_field, d_field):
                                        'parent_obj.parent_obj.parent_obj',
                                        'port.br.dev.exp.aer_log',
                                 'parent_obj.parent_obj.parent_obj.exp.aer_log'],
+        'cirrus_vga': ['hw_cursor_x', 'vga.hw_cursor_x',
+                       'hw_cursor_y', 'vga.hw_cursor_y'],
         'lsiscsi': ['dev', 'parent_obj'],
         'mch': ['d', 'parent_obj'],
         'pci_bridge': ['bridge.dev', 'parent_obj', 'bridge.dev.shpc', 'shpc'],
@@ -83,6 +86,11 @@ def check_fields_match(name, s_field, d_field):
         'xio3130-express-upstream-port': ['br.dev', 'parent_obj.parent_obj',
                                           'br.dev.exp.aer_log',
                                           'parent_obj.parent_obj.exp.aer_log'],
+        'spapr_pci': ['dma_liobn[0]', 'mig_liobn',
+                      'mem_win_addr', 'mig_mem_win_addr',
+                      'mem_win_size', 'mig_mem_win_size',
+                      'io_win_addr', 'mig_io_win_addr',
+                      'io_win_size', 'mig_io_win_size'],
     }
 
     if not name in changed_names:
@@ -97,6 +105,7 @@ def get_changed_sec_name(sec):
     # Section names can change -- see commit 292b1634 for an example.
     changes = {
         "ICH9 LPC": "ICH9-LPC",
+        "e1000-82540em": "e1000",
     }
 
     for item in changes:
@@ -149,7 +158,7 @@ def check_fields(src_fields, dest_fields, desc, sec):
     while True:
         if advance_src:
             try:
-                s_item = s_iter.next()
+                s_item = next(s_iter)
             except StopIteration:
                 if s_iter_list == []:
                     break
@@ -164,14 +173,14 @@ def check_fields(src_fields, dest_fields, desc, sec):
 
         if advance_dest:
             try:
-                d_item = d_iter.next()
+                d_item = next(d_iter)
             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"
+                    print("Section \"" + sec + "\",", end=' ')
+                    print("Description " + "\"" + desc + "\":", end=' ')
+                    print("expected field \"" + s_item["field"] + "\",", end=' ')
+                    print("while dest has no further fields")
                     bump_taint()
                     break
 
@@ -182,17 +191,17 @@ def check_fields(src_fields, dest_fields, desc, sec):
             if unused_count == 0:
                 advance_dest = True
 
-        if unused_count > 0:
+        if unused_count != 0:
             if advance_dest == False:
                 unused_count = unused_count - s_item["size"]
                 if unused_count == 0:
                     advance_dest = True
                     continue
                 if unused_count < 0:
-                    print "Section \"" + sec + "\",",
-                    print "Description \"" + desc + "\":",
-                    print "unused size mismatch near \"",
-                    print s_item["field"] + "\""
+                    print("Section \"" + sec + "\",", end=' ')
+                    print("Description \"" + desc + "\":", end=' ')
+                    print("unused size mismatch near \"", end=' ')
+                    print(s_item["field"] + "\"")
                     bump_taint()
                     break
                 continue
@@ -203,10 +212,10 @@ def check_fields(src_fields, dest_fields, desc, sec):
                     advance_src = True
                     continue
                 if unused_count < 0:
-                    print "Section \"" + sec + "\",",
-                    print "Description \"" + desc + "\":",
-                    print "unused size mismatch near \"",
-                    print d_item["field"] + "\""
+                    print("Section \"" + sec + "\",", end=' ')
+                    print("Description \"" + desc + "\":", end=' ')
+                    print("unused size mismatch near \"", end=' ')
+                    print(d_item["field"] + "\"")
                     bump_taint()
                     break
                 continue
@@ -254,10 +263,10 @@ def check_fields(src_fields, dest_fields, desc, sec):
                     unused_count = s_item["size"] - d_item["size"]
                     continue
 
-            print "Section \"" + sec + "\",",
-            print "Description \"" + desc + "\":",
-            print "expected field \"" + s_item["field"] + "\",",
-            print "got \"" + d_item["field"] + "\"; skipping rest"
+            print("Section \"" + sec + "\",", end=' ')
+            print("Description \"" + desc + "\":", end=' ')
+            print("expected field \"" + s_item["field"] + "\",", end=' ')
+            print("got \"" + d_item["field"] + "\"; skipping rest")
             bump_taint()
             break
 
@@ -281,8 +290,8 @@ def check_subsections(src_sub, dest_sub, desc, sec):
             check_descriptions(s_item, d_item, sec)
 
         if not found:
-            print "Section \"" + sec + "\", Description \"" + desc + "\":",
-            print "Subsection \"" + s_item["name"] + "\" not found"
+            print("Section \"" + sec + "\", Description \"" + desc + "\":", end=' ')
+            print("Subsection \"" + s_item["name"] + "\" not found")
             bump_taint()
 
 
@@ -291,8 +300,8 @@ def check_description_in_list(s_item, d_item, sec, desc):
         return
 
     if not "Description" in d_item:
-        print "Section \"" + sec + "\", Description \"" + desc + "\",",
-        print "Field \"" + s_item["field"] + "\": missing description"
+        print("Section \"" + sec + "\", Description \"" + desc + "\",", end=' ')
+        print("Field \"" + s_item["field"] + "\": missing description")
         bump_taint()
         return
 
@@ -303,17 +312,17 @@ 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"
+        print("Section \"" + sec + "\":", end=' ')
+        print("Description \"" + src_desc["name"] + "\"", end=' ')
+        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"
+            print("Section \"" + sec + "\"", end=' ')
+            print("Description \"" + src_desc["name"] + "\":", end=' ')
+            print("Entry \"" + f + "\" missing")
             bump_taint()
             continue
 
@@ -326,39 +335,39 @@ def check_descriptions(src_desc, dest_desc, sec):
 
 def check_version(s, d, sec, desc=None):
     if s["version_id"] > d["version_id"]:
-        print "Section \"" + sec + "\"",
+        print("Section \"" + sec + "\"", end=' ')
         if desc:
-            print "Description \"" + desc + "\":",
-        print "version error:", s["version_id"], ">", d["version_id"]
+            print("Description \"" + desc + "\":", end=' ')
+        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 + "\"",
+        print("Section \"" + sec + "\"", end=' ')
         if desc:
-            print "Description \"" + desc + "\":",
-            print "minimum version error:", s["version_id"], "<",
-            print d["minimum_version_id"]
+            print("Description \"" + desc + "\":", end=' ')
+            print("minimum version error:", s["version_id"], "<", end=' ')
+            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 + "\"",
+        print("Section \"" + sec + "\"", end=' ')
         if desc:
-            print "Description \"" + desc + "\"",
+            print("Description \"" + desc + "\"", end=' ')
         if field:
-            print "Field \"" + field + "\"",
-        print "size mismatch:", s["size"], ",", d["size"]
+            print("Field \"" + field + "\"", end=' ')
+        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"] + "\""
+        print("Warning: checking incompatible machine types:", end=' ')
+        print("\"" + s["Name"] + "\", \"" + d["Name"] + "\"")
     return
 
 
@@ -392,7 +401,7 @@ def main():
             # doesn't exist in dest.
             dest_sec = get_changed_sec_name(sec)
             if not dest_sec in dest_data:
-                print "Section \"" + sec + "\" does not exist in dest"
+                print("Section \"" + sec + "\" does not exist in dest")
                 bump_taint()
                 continue
 
@@ -407,8 +416,8 @@ def main():
 
         for entry in s:
             if not entry in d:
-                print "Section \"" + sec + "\": Entry \"" + entry + "\"",
-                print "missing"
+                print("Section \"" + sec + "\": Entry \"" + entry + "\"", end=' ')
+                print("missing")
                 bump_taint()
                 continue