From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 08/11] qcow2.py: Subcommand for changing header fields
Date: Fri, 24 May 2013 16:32:24 +0200 [thread overview]
Message-ID: <1369405947-14818-9-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1369405947-14818-1-git-send-email-stefanha@redhat.com>
From: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/qcow2.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index fecf5b9..44a2b45 100755
--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -149,6 +149,22 @@ def cmd_dump_header(fd):
h.dump()
h.dump_extensions()
+def cmd_set_header(fd, name, value):
+ try:
+ value = int(value, 0)
+ except:
+ print "'%s' is not a valid number" % value
+ sys.exit(1)
+
+ fields = (field[2] for field in QcowHeader.fields)
+ if not name in fields:
+ print "'%s' is not a known header field" % name
+ sys.exit(1)
+
+ h = QcowHeader(fd)
+ h.__dict__[name] = value
+ h.update(fd)
+
def cmd_add_header_ext(fd, magic, data):
try:
magic = int(magic, 0)
@@ -205,6 +221,7 @@ def cmd_set_feature_bit(fd, group, bit):
cmds = [
[ 'dump-header', cmd_dump_header, 0, 'Dump image header and header extensions' ],
+ [ 'set-header', cmd_set_header, 2, 'Set a field in the header'],
[ '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'],
--
1.8.1.4
next prev parent reply other threads:[~2013-05-24 14:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-24 14:32 [Qemu-devel] [PULL 00/11] Block patches Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 01/11] block: package preparation code in qmp_transaction() Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 02/11] block: move input parsing " Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 03/11] block: package committing " Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 04/11] block: package rollback " Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 05/11] block: make all steps in qmp_transaction() as callback Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 06/11] blockdev: Rename BlockdevAction -> TransactionAction Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 07/11] qemu-io: Fix 'map' output Stefan Hajnoczi
2013-05-24 14:32 ` Stefan Hajnoczi [this message]
2013-05-24 14:32 ` [Qemu-devel] [PATCH 09/11] qemu-iotests: Try creating huge qcow2 image Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 10/11] coroutine: protect global pool with a mutex Stefan Hajnoczi
2013-05-24 14:32 ` [Qemu-devel] [PATCH 11/11] coroutine: stop using AioContext in CoQueue Stefan Hajnoczi
2013-06-17 21:18 ` [Qemu-devel] [PULL 00/11] Block patches Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369405947-14818-9-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).