9d553ab38a
Hopefully we're at least close to the right stuff for handling python2 vs python3 right with these changes. OBS-URL: https://build.opensuse.org/request/show/569754 OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=384
307 lines
12 KiB
Diff
307 lines
12 KiB
Diff
From f633201a0f40958641f5ff3352b637bd2fa16922 Mon Sep 17 00:00:00 2001
|
|
From: Bruce Rogers <brogers@suse.com>
|
|
Date: Thu, 25 Jan 2018 14:26:04 -0700
|
|
Subject: [PATCH] Make installed scripts explicitly python3
|
|
|
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
---
|
|
scripts/analyze-migration.py | 18 ++++----
|
|
scripts/vmstate-static-checker.py | 94 +++++++++++++++++++--------------------
|
|
2 files changed, 56 insertions(+), 56 deletions(-)
|
|
|
|
diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py
|
|
index a512ddc552..d2e4cb9f8a 100755
|
|
--- a/scripts/analyze-migration.py
|
|
+++ b/scripts/analyze-migration.py
|
|
@@ -1,4 +1,4 @@
|
|
-#!/usr/bin/python2
|
|
+#!/usr/bin/python3
|
|
#
|
|
# Migration Stream Analyzer
|
|
#
|
|
@@ -162,7 +162,7 @@ class RamSection(object):
|
|
len = self.file.read64()
|
|
self.sizeinfo[self.name] = '0x%016x' % len
|
|
if self.write_memory:
|
|
- print self.name
|
|
+ print(self.name)
|
|
mkdir_p('./' + os.path.dirname(self.name))
|
|
f = open('./' + self.name, "wb")
|
|
f.truncate(0)
|
|
@@ -359,7 +359,7 @@ class VMSDFieldStruct(VMSDFieldGeneric):
|
|
array_len = field.pop('array_len')
|
|
field['index'] = 0
|
|
new_fields.append(field)
|
|
- for i in xrange(1, array_len):
|
|
+ for i in range(1, array_len):
|
|
c = field.copy()
|
|
c['index'] = i
|
|
new_fields.append(c)
|
|
@@ -426,7 +426,7 @@ class VMSDFieldStruct(VMSDFieldGeneric):
|
|
|
|
def getDictOrderedDict(self, dict):
|
|
r = collections.OrderedDict()
|
|
- for (key, value) in dict.items():
|
|
+ for (key, value) in list(dict.items()):
|
|
r[key] = self.getDictItem(value)
|
|
return r
|
|
|
|
@@ -558,7 +558,7 @@ class MigrationDump(object):
|
|
|
|
def getDict(self):
|
|
r = collections.OrderedDict()
|
|
- for (key, value) in self.sections.items():
|
|
+ for (key, value) in list(self.sections.items()):
|
|
key = "%s (%d)" % ( value.section_key[0], key )
|
|
r[key] = value.getDict()
|
|
return r
|
|
@@ -584,7 +584,7 @@ if args.extract:
|
|
dump = MigrationDump(args.file)
|
|
|
|
dump.read(desc_only = True)
|
|
- print "desc.json"
|
|
+ print("desc.json")
|
|
f = open("desc.json", "wb")
|
|
f.truncate()
|
|
f.write(jsonenc.encode(dump.vmsd_desc))
|
|
@@ -592,7 +592,7 @@ if args.extract:
|
|
|
|
dump.read(write_memory = True)
|
|
dict = dump.getDict()
|
|
- print "state.json"
|
|
+ print("state.json")
|
|
f = open("state.json", "wb")
|
|
f.truncate()
|
|
f.write(jsonenc.encode(dict))
|
|
@@ -601,10 +601,10 @@ elif args.dump == "state":
|
|
dump = MigrationDump(args.file)
|
|
dump.read(dump_memory = args.memory)
|
|
dict = dump.getDict()
|
|
- print jsonenc.encode(dict)
|
|
+ print(jsonenc.encode(dict))
|
|
elif args.dump == "desc":
|
|
dump = MigrationDump(args.file)
|
|
dump.read(desc_only = True)
|
|
- print jsonenc.encode(dump.vmsd_desc)
|
|
+ print(jsonenc.encode(dump.vmsd_desc))
|
|
else:
|
|
raise Exception("Please specify either -x, -d state or -d dump")
|
|
diff --git a/scripts/vmstate-static-checker.py b/scripts/vmstate-static-checker.py
|
|
index 45ae2df2cf..3bfcbd3d4a 100755
|
|
--- a/scripts/vmstate-static-checker.py
|
|
+++ b/scripts/vmstate-static-checker.py
|
|
@@ -1,4 +1,4 @@
|
|
-#!/usr/bin/python2
|
|
+#!/usr/bin/python3
|
|
#
|
|
# Compares vmstate information stored in JSON format, obtained from
|
|
# the -dump-vmstate QEMU command.
|
|
@@ -157,7 +157,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
|
|
@@ -172,14 +172,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
|
|
|
|
@@ -197,10 +197,10 @@ def check_fields(src_fields, dest_fields, desc, sec):
|
|
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
|
|
@@ -211,10 +211,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
|
|
@@ -262,10 +262,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
|
|
|
|
@@ -289,8 +289,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()
|
|
|
|
|
|
@@ -299,8 +299,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
|
|
|
|
@@ -311,17 +311,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
|
|
|
|
@@ -334,39 +334,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
|
|
|
|
|
|
@@ -374,9 +374,9 @@ 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,
|
|
+ parser.add_argument('-s', '--src', type=open, required=True,
|
|
help='json dump from src qemu')
|
|
- parser.add_argument('-d', '--dest', type=file, required=True,
|
|
+ parser.add_argument('-d', '--dest', type=open, required=True,
|
|
help='json dump from dest qemu')
|
|
parser.add_argument('--reverse', required=False, default=False,
|
|
action='store_true',
|
|
@@ -400,7 +400,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
|
|
|
|
@@ -415,8 +415,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
|
|
|
|
--
|
|
2.16.1
|
|
|