All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, rjones@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 3/4] qcow2.py: Subcommand for changing header fields
Date: Tue, 14 May 2013 16:14:35 +0200	[thread overview]
Message-ID: <1368540876-30747-4-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1368540876-30747-1-git-send-email-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

  parent reply	other threads:[~2013-05-14 14:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 14:14 [Qemu-devel] [PATCH v2 for-1.5 0/4] qcow2: Catch some L1 table index overflows Kevin Wolf
2013-05-14 14:14 ` [Qemu-devel] [PATCH v2 for-1.5 1/4] " Kevin Wolf
2013-05-14 14:49   ` Stefan Hajnoczi
2013-05-14 14:14 ` [Qemu-devel] [PATCH v2 for-1.5 2/4] block: Add hint to -EFBIG error message Kevin Wolf
2013-05-14 14:49   ` Stefan Hajnoczi
2013-05-14 14:14 ` Kevin Wolf [this message]
2013-05-14 14:14 ` [Qemu-devel] [PATCH v2 4/4] qemu-iotests: Try creating huge qcow2 image Kevin Wolf
2013-05-14 16:18 ` [Qemu-devel] [PATCH v2 for-1.5 0/4] qcow2: Catch some L1 table index overflows Richard W.M. Jones
2013-05-15  8:28 ` Stefan Hajnoczi
2013-05-16  9:26   ` Stefan Hajnoczi

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=1368540876-30747-4-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.