yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From a6f84b8fefe3225f3fb6969c5f763bb7151f740e Mon Sep 17 00:00:00 2001
From: Max Reitz <mreitz@redhat.com>
Date: Tue, 7 Jan 2014 21:57:12 +0100
Subject: [PATCH 07/14] qcow2: Save refcount order in BDRVQcowState

RH-Author: Max Reitz <mreitz@redhat.com>
Message-id: <1389131839-12920-8-git-send-email-mreitz@redhat.com>
Patchwork-id: 56543
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 07/14] qcow2: Save refcount order in BDRVQcowState
Bugzilla: 1033490
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

BZ: 1033490

Save the image refcount order in BDRVQcowState. This will be relevant
for future code supporting different refcount orders than four and also
for code that needs to verify a certain refcount order for an opened
image.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit b6481f376bc65894910dd98db3f299d698817106)

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/qcow2.c | 3 ++-
 block/qcow2.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 block/qcow2.c |    3 ++-
 block/qcow2.h |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index f5f68f8..0a53a3c 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -527,6 +527,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
         ret = -ENOTSUP;
         goto fail;
     }
+    s->refcount_order = header.refcount_order;
 
     if (header.cluster_bits < MIN_CLUSTER_BITS ||
         header.cluster_bits > MAX_CLUSTER_BITS) {
@@ -1255,7 +1256,7 @@ int qcow2_update_header(BlockDriverState *bs)
         .incompatible_features  = cpu_to_be64(s->incompatible_features),
         .compatible_features    = cpu_to_be64(s->compatible_features),
         .autoclear_features     = cpu_to_be64(s->autoclear_features),
-        .refcount_order         = cpu_to_be32(3 + REFCOUNT_SHIFT),
+        .refcount_order         = cpu_to_be32(s->refcount_order),
         .header_length          = cpu_to_be32(header_length),
     };
 
diff --git a/block/qcow2.h b/block/qcow2.h
index 2660483..9749f03 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -208,6 +208,7 @@ typedef struct BDRVQcowState {
     int flags;
     int qcow_version;
     bool use_lazy_refcounts;
+    int refcount_order;
 
     bool discard_passthrough[QCOW2_DISCARD_MAX];
 
-- 
1.7.1