From patchwork Thu Apr 18 15:17:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 237673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 28EA92C0151 for ; Fri, 19 Apr 2013 01:18:20 +1000 (EST) Received: from localhost ([::1]:46478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USqbH-0004a8-JY for incoming@patchwork.ozlabs.org; Thu, 18 Apr 2013 11:18:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USqap-0004Vf-Gx for qemu-devel@nongnu.org; Thu, 18 Apr 2013 11:17:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USqao-0000tP-9x for qemu-devel@nongnu.org; Thu, 18 Apr 2013 11:17:47 -0400 Received: from mail-qe0-f47.google.com ([209.85.128.47]:43680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USqao-0000t9-59 for qemu-devel@nongnu.org; Thu, 18 Apr 2013 11:17:46 -0400 Received: by mail-qe0-f47.google.com with SMTP id w7so1772240qeb.6 for ; Thu, 18 Apr 2013 08:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=9486HIvWN6EgjTB0+NWLRzsIxix7Tclb6wcN5lDBGYo=; b=RdPHIzTC6Okj5f7EY9ZrHNDSzZtglfuc6qYHfkKaEfDFHVEtmVOxRb56hzMRH8BlYs Gvq2yRnCU/dd0CHDDAc23teSXphouTTuaWzeQ2HovScFmGJrbparEKKr9MhsfIOvelhq TlHgdtVYQFnWhDRUjVp60XFyMAMyihWrbcFPqU0UrGNAx7AtzHbgOHeEa9GXtulzLA06 407DuxDjJmNP5iJnITn5s7CO2znwMK5tClaXiOUCPSn5yvG1/Lioebwt+f+WyI5+e2vc 72LHa2JQLZMr1QPjqUt7bMp3S3AHVirDYOIQgcp9x+WvRBiP+CH6d4BIuq17LgYsXD/y 7gaQ== X-Received: by 10.229.123.89 with SMTP id o25mr21041qcr.56.1366298265824; Thu, 18 Apr 2013 08:17:45 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id bv6sm12468970qab.5.2013.04.18.08.17.43 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 18 Apr 2013 08:17:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2013 17:17:25 +0200 Message-Id: <1366298249-11739-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.2 In-Reply-To: <1366298249-11739-1-git-send-email-pbonzini@redhat.com> References: <1366298249-11739-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.128.47 Cc: kwolf@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [RFC PATCH 1/5] qcow2.py: rename class to Qcow X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- tests/qemu-iotests/qcow2.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) 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':