mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools/migration: Formatting and style cleanup
The code has devating from the prevailing style in many ways. Adjust spacing, indentation, position of operators, layout of multiline comments, removal of superfluous comments, constness, trailing commas, and use of unqualified 'unsigned'. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
This commit is contained in:
1 parent
b6d4106012
commit
321b658847
13 files changed
+235
-261
No files matched your search
@@ -257,8 +257,8 @@ def read_pv_extended_info(vm):
|
||||
|
||||
|
||||
if so_far != total_length:
|
||||
raise StreamError("Overshot Extended Info size by %d bytes"
|
||||
% (so_far - total_length,))
|
||||
raise StreamError("Overshot Extended Info size by %d bytes" %
|
||||
(so_far - total_length, ))
|
||||
|
||||
def read_pv_p2m_frames(vm):
|
||||
fpp = 4096 / vm.width
|
||||
@@ -375,8 +375,8 @@ def read_chunks(vm):
|
||||
elif marker > 0:
|
||||
|
||||
if marker > legacy.MAX_BATCH:
|
||||
raise StreamError("Page batch (%d) exceeded MAX_BATCH (%d)"
|
||||
% (marker, legacy.MAX_BATCH))
|
||||
raise StreamError("Page batch (%d) exceeded MAX_BATCH (%d)" %
|
||||
(marker, legacy.MAX_BATCH))
|
||||
pfns = unpack_ulongs(marker)
|
||||
|
||||
# xc_domain_save() leaves many XEN_DOMCTL_PFINFO_XTAB records for
|
||||
@@ -398,8 +398,8 @@ def read_chunks(vm):
|
||||
max_id, = unpack_exact("i")
|
||||
|
||||
if max_id > legacy.MAX_VCPU_ID:
|
||||
raise StreamError("Vcpu max_id out of range: %d > %d"
|
||||
% (max_id, legacy.MAX_VCPU_ID))
|
||||
raise StreamError("Vcpu max_id out of range: %d > %d" %
|
||||
(max_id, legacy.MAX_VCPU_ID))
|
||||
|
||||
vm.max_vcpu_id = max_id
|
||||
bitmap = unpack_exact("Q" * ((max_id/64) + 1))
|
||||
@@ -414,8 +414,8 @@ def read_chunks(vm):
|
||||
bit_idx += 1
|
||||
word >>= 1
|
||||
|
||||
info(" Vcpu info: max_id %d, online map %s"
|
||||
% (vm.max_vcpu_id, vm.online_vcpu_map))
|
||||
info(" Vcpu info: max_id %d, online map %s" %
|
||||
(vm.max_vcpu_id, vm.online_vcpu_map))
|
||||
|
||||
elif marker == legacy.CHUNK_hvm_ident_pt:
|
||||
_, ident_pt = unpack_exact("=IQ")
|
||||
@@ -512,7 +512,7 @@ def read_chunks(vm):
|
||||
[public.HVM_PARAM_NR_IOREQ_SERVER_PAGES, nr_pages])
|
||||
|
||||
else:
|
||||
raise StreamError("Unrecognised chunk %d" % (marker,))
|
||||
raise StreamError("Unrecognised chunk %d" % (marker, ))
|
||||
|
||||
def read_hvm_tail(vm):
|
||||
|
||||
@@ -579,7 +579,7 @@ def read_legacy_stream(vm):
|
||||
|
||||
try:
|
||||
vm.p2m_size, = unpack_ulongs(1)
|
||||
info("P2M Size: 0x%x" % (vm.p2m_size,))
|
||||
info("P2M Size: 0x%x" % (vm.p2m_size, ))
|
||||
|
||||
if vm.libxl:
|
||||
write_libxl_hdr()
|
||||
|
||||
@@ -74,7 +74,7 @@ rec_type_to_str = {
|
||||
REC_TYPE_x86_pv_vcpu_msrs : "x86 PV vcpu msrs",
|
||||
REC_TYPE_verify : "Verify",
|
||||
REC_TYPE_checkpoint : "Checkpoint",
|
||||
REC_TYPE_checkpoint_dirty_pfn_list : "Checkpoint dirty pfn list"
|
||||
REC_TYPE_checkpoint_dirty_pfn_list : "Checkpoint dirty pfn list",
|
||||
}
|
||||
|
||||
# page_data
|
||||
@@ -137,24 +137,25 @@ class VerifyLibxc(VerifyBase):
|
||||
self.unpack_exact(IHDR_FORMAT)
|
||||
|
||||
if marker != IHDR_MARKER:
|
||||
raise StreamError("Bad image marker: Expected 0x%x, got 0x%x"
|
||||
% (IHDR_MARKER, marker))
|
||||
raise StreamError("Bad image marker: Expected 0x%x, got 0x%x" %
|
||||
(IHDR_MARKER, marker))
|
||||
|
||||
if ident != IHDR_IDENT:
|
||||
raise StreamError("Bad image id: Expected 0x%x, got 0x%x"
|
||||
% (IHDR_IDENT, ident))
|
||||
raise StreamError("Bad image id: Expected 0x%x, got 0x%x" %
|
||||
(IHDR_IDENT, ident))
|
||||
|
||||
if version != IHDR_VERSION:
|
||||
raise StreamError("Unknown image version: Expected %d, got %d"
|
||||
% (IHDR_VERSION, version))
|
||||
raise StreamError("Unknown image version: Expected %d, got %d" %
|
||||
(IHDR_VERSION, version))
|
||||
|
||||
if options & IHDR_OPT_RESZ_MASK:
|
||||
raise StreamError("Reserved bits set in image options field: 0x%x"
|
||||
% (options & IHDR_OPT_RESZ_MASK))
|
||||
raise StreamError("Reserved bits set in image options field: 0x%x" %
|
||||
(options & IHDR_OPT_RESZ_MASK))
|
||||
|
||||
if res1 != 0 or res2 != 0:
|
||||
raise StreamError("Reserved bits set in image header: 0x%04x:0x%08x"
|
||||
% (res1, res2))
|
||||
raise StreamError(
|
||||
"Reserved bits set in image header: 0x%04x:0x%08x" %
|
||||
(res1, res2))
|
||||
|
||||
if ( (sys.byteorder == "little") and
|
||||
((options & IHDR_OPT_BIT_ENDIAN) != IHDR_OPT_LE) ):
|
||||
@@ -175,19 +176,19 @@ class VerifyLibxc(VerifyBase):
|
||||
raise StreamError("Unrecognised domain type 0x%x" % (gtype, ))
|
||||
|
||||
if res1 != 0:
|
||||
raise StreamError("Reserved bits set in domain header 0x%04x"
|
||||
% (res1, ))
|
||||
raise StreamError("Reserved bits set in domain header 0x%04x" %
|
||||
(res1, ))
|
||||
|
||||
if page_shift != 12:
|
||||
raise StreamError("Page shift expected to be 12. Got %d"
|
||||
% (page_shift, ))
|
||||
raise StreamError("Page shift expected to be 12. Got %d" %
|
||||
(page_shift, ))
|
||||
|
||||
if major == 0:
|
||||
self.info("Domain Header: legacy converted %s"
|
||||
% (dhdr_type_to_str[gtype], ))
|
||||
self.info("Domain Header: legacy converted %s" %
|
||||
(dhdr_type_to_str[gtype], ))
|
||||
else:
|
||||
self.info("Domain Header: %s from Xen %d.%d"
|
||||
% (dhdr_type_to_str[gtype], major, minor))
|
||||
self.info("Domain Header: %s from Xen %d.%d" %
|
||||
(dhdr_type_to_str[gtype], major, minor))
|
||||
|
||||
|
||||
def verify_record(self):
|
||||
@@ -204,12 +205,12 @@ class VerifyLibxc(VerifyBase):
|
||||
if rtype != REC_TYPE_page_data:
|
||||
|
||||
if self.squashed_pagedata_records > 0:
|
||||
self.info("Squashed %d Page Data records together"
|
||||
% (self.squashed_pagedata_records, ))
|
||||
self.info("Squashed %d Page Data records together" %
|
||||
(self.squashed_pagedata_records, ))
|
||||
self.squashed_pagedata_records = 0
|
||||
|
||||
self.info("Libxc Record: %s, length %d"
|
||||
% (rec_type_to_str[rtype], length))
|
||||
self.info("Libxc Record: %s, length %d" %
|
||||
(rec_type_to_str[rtype], length))
|
||||
|
||||
else:
|
||||
self.squashed_pagedata_records += 1
|
||||
@@ -219,8 +220,9 @@ class VerifyLibxc(VerifyBase):
|
||||
raise StreamError("Padding containing non0 bytes found")
|
||||
|
||||
if rtype not in record_verifiers:
|
||||
raise RuntimeError("No verification function for libxc record '%s'"
|
||||
% rec_type_to_str[rtype])
|
||||
raise RuntimeError(
|
||||
"No verification function for libxc record '%s'" %
|
||||
rec_type_to_str[rtype])
|
||||
else:
|
||||
record_verifiers[rtype](self, content[:length])
|
||||
|
||||
@@ -239,32 +241,32 @@ class VerifyLibxc(VerifyBase):
|
||||
minsz = calcsize(PAGE_DATA_FORMAT)
|
||||
|
||||
if len(content) <= minsz:
|
||||
raise RecordError("PAGE_DATA record must be at least %d bytes long"
|
||||
% (minsz, ))
|
||||
raise RecordError(
|
||||
"PAGE_DATA record must be at least %d bytes long" % (minsz, ))
|
||||
|
||||
count, res1 = unpack(PAGE_DATA_FORMAT, content[:minsz])
|
||||
|
||||
if res1 != 0:
|
||||
raise StreamError("Reserved bits set in PAGE_DATA record 0x%04x"
|
||||
% (res1, ))
|
||||
raise StreamError(
|
||||
"Reserved bits set in PAGE_DATA record 0x%04x" % (res1, ))
|
||||
|
||||
pfnsz = count * 8
|
||||
if (len(content) - minsz) < pfnsz:
|
||||
raise RecordError("PAGE_DATA record must contain a pfn record for "
|
||||
"each count")
|
||||
raise RecordError(
|
||||
"PAGE_DATA record must contain a pfn record for each count")
|
||||
|
||||
pfns = list(unpack("=%dQ" % (count,), content[minsz:minsz + pfnsz]))
|
||||
pfns = list(unpack("=%dQ" % (count, ), content[minsz:minsz + pfnsz]))
|
||||
|
||||
nr_pages = 0
|
||||
for idx, pfn in enumerate(pfns):
|
||||
|
||||
if pfn & PAGE_DATA_PFN_RESZ_MASK:
|
||||
raise RecordError("Reserved bits set in pfn[%d]: 0x%016x",
|
||||
idx, pfn & PAGE_DATA_PFN_RESZ_MASK)
|
||||
raise RecordError("Reserved bits set in pfn[%d]: 0x%016x" %
|
||||
(idx, pfn & PAGE_DATA_PFN_RESZ_MASK))
|
||||
|
||||
if pfn >> PAGE_DATA_TYPE_SHIFT in (5, 6, 7, 8):
|
||||
raise RecordError("Invalid type value in pfn[%d]: 0x%016x",
|
||||
idx, pfn & PAGE_DATA_TYPE_LTAB_MASK)
|
||||
raise RecordError("Invalid type value in pfn[%d]: 0x%016x" %
|
||||
(idx, pfn & PAGE_DATA_TYPE_LTAB_MASK))
|
||||
|
||||
# We expect page data for each normal page or pagetable
|
||||
if PAGE_DATA_TYPE_NOTAB <= (pfn & PAGE_DATA_TYPE_LTABTYPE_MASK) \
|
||||
@@ -273,8 +275,8 @@ class VerifyLibxc(VerifyBase):
|
||||
|
||||
pagesz = nr_pages * 4096
|
||||
if len(content) != minsz + pfnsz + pagesz:
|
||||
raise RecordError("Expected %u + %u + %u, got %u"
|
||||
% (minsz, pfnsz, pagesz, len(content)))
|
||||
raise RecordError("Expected %u + %u + %u, got %u" %
|
||||
(minsz, pfnsz, pagesz, len(content)))
|
||||
|
||||
|
||||
def verify_record_x86_pv_info(self, content):
|
||||
@@ -282,8 +284,8 @@ class VerifyLibxc(VerifyBase):
|
||||
|
||||
expectedsz = calcsize(X86_PV_INFO_FORMAT)
|
||||
if len(content) != expectedsz:
|
||||
raise RecordError("x86_pv_info: expected length of %d, got %d"
|
||||
% (expectedsz, len(content)))
|
||||
raise RecordError("x86_pv_info: expected length of %d, got %d" %
|
||||
(expectedsz, len(content)))
|
||||
|
||||
width, levels, res1, res2 = unpack(X86_PV_INFO_FORMAT, content)
|
||||
|
||||
@@ -294,8 +296,9 @@ class VerifyLibxc(VerifyBase):
|
||||
raise RecordError("Expected levels of 3 or 4, got %d" % (levels, ))
|
||||
|
||||
if res1 != 0 or res2 != 0:
|
||||
raise StreamError("Reserved bits set in X86_PV_INFO: 0x%04x 0x%08x"
|
||||
% (res1, res2))
|
||||
raise StreamError(
|
||||
"Reserved bits set in X86_PV_INFO: 0x%04x 0x%08x" %
|
||||
(res1, res2))
|
||||
|
||||
bitness = {4:32, 8:64}[width]
|
||||
self.info(" %sbit guest, %d levels of pagetables" % (bitness, levels))
|
||||
@@ -309,8 +312,8 @@ class VerifyLibxc(VerifyBase):
|
||||
" least 8 bytes long")
|
||||
|
||||
if len(content) % 8 != 0:
|
||||
raise RecordError("Length expected to be a multiple of 8, not %d"
|
||||
% (len(content), ))
|
||||
raise RecordError("Length expected to be a multiple of 8, not %d" %
|
||||
(len(content), ))
|
||||
|
||||
start, end = unpack("=II", content[:8])
|
||||
self.info(" Start pfn 0x%x, End 0x%x" % (start, end))
|
||||
@@ -321,30 +324,32 @@ class VerifyLibxc(VerifyBase):
|
||||
minsz = calcsize(X86_PV_VCPU_HDR_FORMAT)
|
||||
|
||||
if len(content) < minsz:
|
||||
raise RecordError("X86_PV_VCPU_%s record length must be at least %d"
|
||||
" bytes long" % (name, minsz))
|
||||
raise RecordError(
|
||||
"X86_PV_VCPU_%s record length must be at least %d bytes long" %
|
||||
(name, minsz))
|
||||
|
||||
if len(content) == minsz:
|
||||
self.info("Warning: X86_PV_VCPU_%s record with zero content"
|
||||
% (name, ))
|
||||
self.info("Warning: X86_PV_VCPU_%s record with zero content" %
|
||||
(name, ))
|
||||
|
||||
vcpuid, res1 = unpack(X86_PV_VCPU_HDR_FORMAT, content[:minsz])
|
||||
|
||||
if res1 != 0:
|
||||
raise StreamError(
|
||||
"Reserved bits set in x86_pv_vcpu_%s record 0x%04x"
|
||||
% (name, res1))
|
||||
"Reserved bits set in x86_pv_vcpu_%s record 0x%04x" %
|
||||
(name, res1))
|
||||
|
||||
self.info(" vcpu%d %s context, %d bytes"
|
||||
% (vcpuid, name, len(content) - minsz))
|
||||
self.info(" vcpu%d %s context, %d bytes" %
|
||||
(vcpuid, name, len(content) - minsz))
|
||||
|
||||
|
||||
def verify_record_shared_info(self, content):
|
||||
""" shared info record """
|
||||
|
||||
if len(content) != 4096:
|
||||
raise RecordError("Length expected to be 4906 bytes, not %d"
|
||||
% (len(content), ))
|
||||
contentsz = len(content)
|
||||
if contentsz != 4096:
|
||||
raise RecordError("Length expected to be 4906 bytes, not %d" %
|
||||
(contentsz, ))
|
||||
|
||||
|
||||
def verify_record_tsc_info(self, content):
|
||||
@@ -358,11 +363,11 @@ class VerifyLibxc(VerifyBase):
|
||||
mode, khz, nsec, incarn, res1 = unpack(X86_TSC_INFO_FORMAT, content)
|
||||
|
||||
if res1 != 0:
|
||||
raise StreamError("Reserved bits set in X86_TSC_INFO: 0x%08x"
|
||||
% (res1, ))
|
||||
raise StreamError("Reserved bits set in X86_TSC_INFO: 0x%08x" %
|
||||
(res1, ))
|
||||
|
||||
self.info(" Mode %u, %u kHz, %u ns, incarnation %d"
|
||||
% (mode, khz, nsec, incarn))
|
||||
self.info(" Mode %u, %u kHz, %u ns, incarnation %d" %
|
||||
(mode, khz, nsec, incarn))
|
||||
|
||||
|
||||
def verify_record_hvm_context(self, content):
|
||||
@@ -412,6 +417,7 @@ class VerifyLibxc(VerifyBase):
|
||||
if len(content) != 0:
|
||||
raise RecordError("Checkpoint record with non-zero length")
|
||||
|
||||
|
||||
def verify_record_checkpoint_dirty_pfn_list(self, content):
|
||||
""" checkpoint dirty pfn list """
|
||||
raise RecordError("Found checkpoint dirty pfn list record in stream")
|
||||
|
||||
@@ -45,7 +45,7 @@ rec_type_to_str = {
|
||||
REC_TYPE_emulator_xenstore_data : "Emulator xenstore data",
|
||||
REC_TYPE_emulator_context : "Emulator context",
|
||||
REC_TYPE_checkpoint_end : "Checkpoint end",
|
||||
REC_TYPE_checkpoint_state : "Checkpoint state"
|
||||
REC_TYPE_checkpoint_state : "Checkpoint state",
|
||||
}
|
||||
|
||||
# emulator_* header
|
||||
@@ -90,16 +90,16 @@ class VerifyLibxl(VerifyBase):
|
||||
ident, version, options = self.unpack_exact(HDR_FORMAT)
|
||||
|
||||
if ident != HDR_IDENT:
|
||||
raise StreamError("Bad image id: Expected 0x%x, got 0x%x"
|
||||
% (HDR_IDENT, ident))
|
||||
raise StreamError("Bad image id: Expected 0x%x, got 0x%x" %
|
||||
(HDR_IDENT, ident))
|
||||
|
||||
if version != HDR_VERSION:
|
||||
raise StreamError("Unknown image version: Expected %d, got %d"
|
||||
% (HDR_VERSION, version))
|
||||
raise StreamError("Unknown image version: Expected %d, got %d" %
|
||||
(HDR_VERSION, version))
|
||||
|
||||
if options & HDR_OPT_RESZ_MASK:
|
||||
raise StreamError("Reserved bits set in image options field: 0x%x"
|
||||
% (options & HDR_OPT_RESZ_MASK))
|
||||
raise StreamError("Reserved bits set in image options field: 0x%x" %
|
||||
(options & HDR_OPT_RESZ_MASK))
|
||||
|
||||
if ( (sys.byteorder == "little") and
|
||||
((options & HDR_OPT_BIT_ENDIAN) != HDR_OPT_LE) ):
|
||||
@@ -121,8 +121,8 @@ class VerifyLibxl(VerifyBase):
|
||||
if rtype not in rec_type_to_str:
|
||||
raise StreamError("Unrecognised record type %x" % (rtype, ))
|
||||
|
||||
self.info("Libxl Record: %s, length %d"
|
||||
% (rec_type_to_str[rtype], length))
|
||||
self.info("Libxl Record: %s, length %d" %
|
||||
(rec_type_to_str[rtype], length))
|
||||
|
||||
contentsz = (length + 7) & ~7
|
||||
content = self.rdexact(contentsz)
|
||||
@@ -132,8 +132,9 @@ class VerifyLibxl(VerifyBase):
|
||||
raise StreamError("Padding containing non0 bytes found")
|
||||
|
||||
if rtype not in record_verifiers:
|
||||
raise RuntimeError("No verification function for libxl record '%s'"
|
||||
% rec_type_to_str[rtype])
|
||||
raise RuntimeError(
|
||||
"No verification function for libxl record '%s'" %
|
||||
rec_type_to_str[rtype])
|
||||
else:
|
||||
record_verifiers[rtype](self, content[:length])
|
||||
|
||||
@@ -162,16 +163,16 @@ class VerifyLibxl(VerifyBase):
|
||||
minsz = calcsize(EMULATOR_HEADER_FORMAT)
|
||||
|
||||
if len(content) < minsz:
|
||||
raise RecordError("Length must be at least %d bytes, got %d"
|
||||
% (minsz, len(content)))
|
||||
raise RecordError("Length must be at least %d bytes, got %d" %
|
||||
(minsz, len(content)))
|
||||
|
||||
emu_id, emu_idx = unpack(EMULATOR_HEADER_FORMAT, content[:minsz])
|
||||
|
||||
if emu_id not in emulator_id_to_str:
|
||||
raise RecordError("Unrecognised emulator id 0x%x" % (emu_id, ))
|
||||
|
||||
self.info("Emulator Xenstore Data (%s, idx %d)"
|
||||
% (emulator_id_to_str[emu_id], emu_idx))
|
||||
self.info("Emulator Xenstore Data (%s, idx %d)" %
|
||||
(emulator_id_to_str[emu_id], emu_idx))
|
||||
|
||||
# Chop off the emulator header
|
||||
content = content[minsz:]
|
||||
@@ -185,8 +186,8 @@ class VerifyLibxl(VerifyBase):
|
||||
parts = content[:-1].split("\x00")
|
||||
|
||||
if (len(parts) % 2) != 0:
|
||||
raise RecordError("Expected an even number of strings, got %d"
|
||||
% (len(parts), ))
|
||||
raise RecordError("Expected an even number of strings, got %d" %
|
||||
(len(parts), ))
|
||||
|
||||
for key, val in zip(parts[0::2], parts[1::2]):
|
||||
self.info(" '%s' = '%s'" % (key, val))
|
||||
@@ -197,8 +198,8 @@ class VerifyLibxl(VerifyBase):
|
||||
minsz = calcsize(EMULATOR_HEADER_FORMAT)
|
||||
|
||||
if len(content) < minsz:
|
||||
raise RecordError("Length must be at least %d bytes, got %d"
|
||||
% (minsz, len(content)))
|
||||
raise RecordError("Length must be at least %d bytes, got %d" %
|
||||
(minsz, len(content)))
|
||||
|
||||
emu_id, emu_idx = unpack(EMULATOR_HEADER_FORMAT, content[:minsz])
|
||||
|
||||
|
||||