Patchwork [RFC,1/5] qcow2.py: rename class to Qcow

login
register
mail settings
Submitter Paolo Bonzini
Date April 18, 2013, 3:17 p.m.
Message ID <1366298249-11739-2-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/237673/
State New
Headers show

Comments

Paolo Bonzini - April 18, 2013, 3:17 p.m.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/qemu-iotests/qcow2.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Patch

diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index fecf5b9..40241b1 100755
--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -15,7 +15,7 @@  class QcowHeaderExtension:
     def create(cls, magic, data):
         return QcowHeaderExtension(magic, len(data), data)
 
-class QcowHeader:
+class Qcow:
 
     uint32_t = 'I'
     uint64_t = 'Q'
@@ -44,18 +44,18 @@  class QcowHeader:
         [ uint32_t, '%d',   'header_length' ],
     ];
 
-    fmt = '>' + ''.join(field[0] for field in fields)
+    HEADER_FMT = '>' + ''.join(field[0] for field in fields)
 
     def __init__(self, fd):
 
-        buf_size = struct.calcsize(QcowHeader.fmt)
+        buf_size = struct.calcsize(Qcow.HEADER_FMT)
 
         fd.seek(0)
         buf = fd.read(buf_size)
 
-        header = struct.unpack(QcowHeader.fmt, buf)
+        header = struct.unpack(Qcow.HEADER_FMT, buf)
         self.__dict__ = dict((field[2], header[i])
-            for i, field in enumerate(QcowHeader.fields))
+            for i, field in enumerate(Qcow.fields))
 
         self.set_defaults()
         self.cluster_size = 1 << self.cluster_bits
@@ -118,13 +118,13 @@  class QcowHeader:
         self.update_extensions(fd)
 
         fd.seek(0)
-        header = tuple(self.__dict__[f] for t, p, f in QcowHeader.fields)
-        buf = struct.pack(QcowHeader.fmt, *header)
+        header = tuple(self.__dict__[f] for t, p, f in Qcow.fields)
+        buf = struct.pack(Qcow.HEADER_FMT, *header)
         buf = buf[0:header_bytes-1]
         fd.write(buf)
 
     def dump(self):
-        for f in QcowHeader.fields:
+        for f in Qcow.fields:
             print "%-25s" % f[2], f[1] % self.__dict__[f[2]]
         print ""
 
@@ -145,7 +145,7 @@  class QcowHeader:
 
 
 def cmd_dump_header(fd):
-    h = QcowHeader(fd)
+    h = Qcow(fd)
     h.dump()
     h.dump_extensions()
 
@@ -156,7 +156,7 @@  def cmd_add_header_ext(fd, magic, data):
         print "'%s' is not a valid magic number" % magic
         sys.exit(1)
 
-    h = QcowHeader(fd)
+    h = Qcow(fd)
     h.extensions.append(QcowHeaderExtension.create(magic, data))
     h.update(fd)
 
@@ -167,7 +167,7 @@  def cmd_del_header_ext(fd, magic):
         print "'%s' is not a valid magic number" % magic
         sys.exit(1)
 
-    h = QcowHeader(fd)
+    h = Qcow(fd)
     found = False
 
     for ex in h.extensions:
@@ -190,7 +190,7 @@  def cmd_set_feature_bit(fd, group, bit):
         print "'%s' is not a valid bit number in range [0, 64)" % bit
         sys.exit(1)
 
-    h = QcowHeader(fd)
+    h = Qcow(fd)
     if group == 'incompatible':
         h.incompatible_features |= 1 << bit
     elif group == 'compatible':