thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qcow2.py-Subcommand-for-changing-header-fields.patch

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