From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWfk-00028m-4E for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfWfd-0004vg-CH for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20003) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfWfd-0004vJ-4c for qemu-devel@nongnu.org; Fri, 15 Jun 2012 09:34:37 -0400 From: Kevin Wolf Date: Fri, 15 Jun 2012 15:33:38 +0200 Message-Id: <1339767219-24297-39-git-send-email-kwolf@redhat.com> In-Reply-To: <1339767219-24297-1-git-send-email-kwolf@redhat.com> References: <1339767219-24297-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 38/39] qemu-iotests: add qcow2.py set-feature-bit command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Stefan Hajnoczi 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 Signed-off-by: Kevin Wolf --- tests/qemu-iotests/qcow2.py | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) 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): -- 1.7.6.5