|
|
9ae3a8 |
From c8da29122142f498215881e8bb933de278a3809a Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Date: Sun, 29 Dec 2013 22:06:54 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 3/8] qcow2.py: Subcommand for changing header fields
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1388354817-3013-3-git-send-email-mreitz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56444
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 2/5] qcow2.py: Subcommand for changing header fields
|
|
|
9ae3a8 |
Bugzilla: 1004347
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
BZ: 1004347
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit c93331c9146719958a4b102435fcd0566da45ea2)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
tests/qemu-iotests/qcow2.py | 17 +++++++++++++++++
|
|
|
9ae3a8 |
1 file changed, 17 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
tests/qemu-iotests/qcow2.py | 17 +++++++++++++++++
|
|
|
9ae3a8 |
1 files changed, 17 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
|
|
|
9ae3a8 |
index fecf5b9..44a2b45 100755
|
|
|
9ae3a8 |
--- a/tests/qemu-iotests/qcow2.py
|
|
|
9ae3a8 |
+++ b/tests/qemu-iotests/qcow2.py
|
|
|
9ae3a8 |
@@ -149,6 +149,22 @@ def cmd_dump_header(fd):
|
|
|
9ae3a8 |
h.dump()
|
|
|
9ae3a8 |
h.dump_extensions()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+def cmd_set_header(fd, name, value):
|
|
|
9ae3a8 |
+ try:
|
|
|
9ae3a8 |
+ value = int(value, 0)
|
|
|
9ae3a8 |
+ except:
|
|
|
9ae3a8 |
+ print "'%s' is not a valid number" % value
|
|
|
9ae3a8 |
+ sys.exit(1)
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ fields = (field[2] for field in QcowHeader.fields)
|
|
|
9ae3a8 |
+ if not name in fields:
|
|
|
9ae3a8 |
+ print "'%s' is not a known header field" % name
|
|
|
9ae3a8 |
+ sys.exit(1)
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ h = QcowHeader(fd)
|
|
|
9ae3a8 |
+ h.__dict__[name] = value
|
|
|
9ae3a8 |
+ h.update(fd)
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
def cmd_add_header_ext(fd, magic, data):
|
|
|
9ae3a8 |
try:
|
|
|
9ae3a8 |
magic = int(magic, 0)
|
|
|
9ae3a8 |
@@ -205,6 +221,7 @@ def cmd_set_feature_bit(fd, group, bit):
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
cmds = [
|
|
|
9ae3a8 |
[ 'dump-header', cmd_dump_header, 0, 'Dump image header and header extensions' ],
|
|
|
9ae3a8 |
+ [ 'set-header', cmd_set_header, 2, 'Set a field in the header'],
|
|
|
9ae3a8 |
[ 'add-header-ext', cmd_add_header_ext, 2, 'Add a header extension' ],
|
|
|
9ae3a8 |
[ 'del-header-ext', cmd_del_header_ext, 1, 'Delete a header extension' ],
|
|
|
9ae3a8 |
[ 'set-feature-bit', cmd_set_feature_bit, 2, 'Set a feature bit'],
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|