From patchwork Thu Jun 14 12:58:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 164925 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 694A2B7027 for ; Thu, 14 Jun 2012 22:59:30 +1000 (EST) Received: from localhost ([::1]:43152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf9e4-00011W-DT for incoming@patchwork.ozlabs.org; Thu, 14 Jun 2012 08:59:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf9dm-0000Oi-0F for qemu-devel@nongnu.org; Thu, 14 Jun 2012 08:59:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sf9df-0003dB-Hb for qemu-devel@nongnu.org; Thu, 14 Jun 2012 08:59:09 -0400 Received: from e06smtp18.uk.ibm.com ([195.75.94.114]:48387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sf9df-0003ci-8z for qemu-devel@nongnu.org; Thu, 14 Jun 2012 08:59:03 -0400 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Jun 2012 13:58:58 +0100 Received: from d06nrmr1707.portsmouth.uk.ibm.com (9.149.39.225) by e06smtp18.uk.ibm.com (192.168.101.148) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 14 Jun 2012 13:58:25 +0100 Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5ECwOQF2678962 for ; Thu, 14 Jun 2012 13:58:24 +0100 Received: from d06av10.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5EChoSq025477 for ; Thu, 14 Jun 2012 08:43:51 -0400 Received: from localhost (stefanha-thinkpad.manchester-maybrook.uk.ibm.com [9.174.219.145]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5EChoZh025467; Thu, 14 Jun 2012 08:43:50 -0400 From: Stefan Hajnoczi To: Kevin Wolf Date: Thu, 14 Jun 2012 13:58:17 +0100 Message-Id: <1339678698-17726-3-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1339678698-17726-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1339678698-17726-1-git-send-email-stefanha@linux.vnet.ibm.com> x-cbid: 12061412-6892-0000-0000-00000220B490 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.114 Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v2 2/3] qemu-iotests: add qcow2.py set-feature-bit command 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 This new command sets feature bits in the image file header: qcow2.py set-feature-bit incompatible|compatible|autoclear The bit number must be in the range [0, 64). Signed-off-by: Stefan Hajnoczi --- tests/qemu-iotests/qcow2.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py index e27196a..97f3770 100755 --- a/tests/qemu-iotests/qcow2.py +++ b/tests/qemu-iotests/qcow2.py @@ -181,10 +181,33 @@ def cmd_del_header_ext(fd, magic): h.update(fd) +def cmd_set_feature_bit(fd, group, bit): + try: + bit = int(bit, 0) + if bit < 0 or bit >= 64: + raise ValueError + except: + print "'%s' is not a valid bit number in range [0, 64)" % bit + sys.exit(1) + + h = QcowHeader(fd) + if group == 'incompatible': + h.incompatible_features |= 1 << bit + elif group == 'compatible': + h.compatible_features |= 1 << bit + elif group == 'autoclear': + h.autoclear_features |= 1 << bit + else: + print "'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group + sys.exit(1) + + h.update(fd) + cmds = [ [ 'dump-header', cmd_dump_header, 0, 'Dump image header and header extensions' ], [ 'add-header-ext', cmd_add_header_ext, 2, 'Add a header extension' ], [ 'del-header-ext', cmd_del_header_ext, 1, 'Delete a header extension' ], + [ 'set-feature-bit', cmd_set_feature_bit, 2, 'Set a feature bit'], ] def main(filename, cmd, args):