0a122b
From a6f84b8fefe3225f3fb6969c5f763bb7151f740e Mon Sep 17 00:00:00 2001
0a122b
From: Max Reitz <mreitz@redhat.com>
0a122b
Date: Tue, 7 Jan 2014 21:57:12 +0100
0a122b
Subject: [PATCH 07/14] qcow2: Save refcount order in BDRVQcowState
0a122b
0a122b
RH-Author: Max Reitz <mreitz@redhat.com>
0a122b
Message-id: <1389131839-12920-8-git-send-email-mreitz@redhat.com>
0a122b
Patchwork-id: 56543
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 07/14] qcow2: Save refcount order in BDRVQcowState
0a122b
Bugzilla: 1033490
0a122b
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
0a122b
RH-Acked-by: Fam Zheng <famz@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
BZ: 1033490
0a122b
0a122b
Save the image refcount order in BDRVQcowState. This will be relevant
0a122b
for future code supporting different refcount orders than four and also
0a122b
for code that needs to verify a certain refcount order for an opened
0a122b
image.
0a122b
0a122b
Signed-off-by: Max Reitz <mreitz@redhat.com>
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
(cherry picked from commit b6481f376bc65894910dd98db3f299d698817106)
0a122b
0a122b
Signed-off-by: Max Reitz <mreitz@redhat.com>
0a122b
---
0a122b
 block/qcow2.c | 3 ++-
0a122b
 block/qcow2.h | 1 +
0a122b
 2 files changed, 3 insertions(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 block/qcow2.c |    3 ++-
0a122b
 block/qcow2.h |    1 +
0a122b
 2 files changed, 3 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/block/qcow2.c b/block/qcow2.c
0a122b
index f5f68f8..0a53a3c 100644
0a122b
--- a/block/qcow2.c
0a122b
+++ b/block/qcow2.c
0a122b
@@ -527,6 +527,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
0a122b
         ret = -ENOTSUP;
0a122b
         goto fail;
0a122b
     }
0a122b
+    s->refcount_order = header.refcount_order;
0a122b
 
0a122b
     if (header.cluster_bits < MIN_CLUSTER_BITS ||
0a122b
         header.cluster_bits > MAX_CLUSTER_BITS) {
0a122b
@@ -1255,7 +1256,7 @@ int qcow2_update_header(BlockDriverState *bs)
0a122b
         .incompatible_features  = cpu_to_be64(s->incompatible_features),
0a122b
         .compatible_features    = cpu_to_be64(s->compatible_features),
0a122b
         .autoclear_features     = cpu_to_be64(s->autoclear_features),
0a122b
-        .refcount_order         = cpu_to_be32(3 + REFCOUNT_SHIFT),
0a122b
+        .refcount_order         = cpu_to_be32(s->refcount_order),
0a122b
         .header_length          = cpu_to_be32(header_length),
0a122b
     };
0a122b
 
0a122b
diff --git a/block/qcow2.h b/block/qcow2.h
0a122b
index 2660483..9749f03 100644
0a122b
--- a/block/qcow2.h
0a122b
+++ b/block/qcow2.h
0a122b
@@ -208,6 +208,7 @@ typedef struct BDRVQcowState {
0a122b
     int flags;
0a122b
     int qcow_version;
0a122b
     bool use_lazy_refcounts;
0a122b
+    int refcount_order;
0a122b
 
0a122b
     bool discard_passthrough[QCOW2_DISCARD_MAX];
0a122b
 
0a122b
-- 
0a122b
1.7.1
0a122b