Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > aadbe78a25743146bb784eee19f007c5 > files > 506

kvm-83-164.el5_5.9.src.rpm

From 20affa3eb508c99977def3f4a15808e42181a63d Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Thu, 16 Apr 2009 10:52:40 +0200
Subject: [PATCH 07/11] qcow2 corruption: Fix alloc_cluster_link_l2

[Fixes BZ 496041. Sent upstream to qemu-devel, but not yet applied. Rebased for
kvm-userspace-rhel5.git]

This patch fixes a qcow2 corruption bug introduced in SVN Rev 5861. L2 tables
are big endian, so entries must be converted before being passed to functions.

This bug is easy to trigger. The following script will create and destroy a
qcow2 image (the header is gone after three loop iterations):

    #!/bin/bash
    qemu-img create -f qcow2 test.qcow 1M
    for i in $(seq 1 10); do
    qemu-system-x86_64 -hda test.qcow -monitor stdio > /dev/null 2>&1 <<EOF
    savevm test-$i
    quit
    EOF
    done

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Message-Id: <1239871960-25229-1-git-send-email-kwolf@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
RH-Upstream-status: submitted(qemu-devel)
Acked-by: Rik van Riel <riel@redhat.com>
Acked-by: Avi Kivity <avi@redhat.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Bugzilla: 497886
---
 qemu/block-qcow2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c
index e9df43a..8ec2d87 100644
--- a/qemu/block-qcow2.c
+++ b/qemu/block-qcow2.c
@@ -1033,7 +1033,7 @@ static int alloc_cluster_link_l2(BlockDriverState *bs, uint64_t cluster_offset,
         goto err;
 
     for (i = 0; i < j; i++)
-        free_any_clusters(bs, old_cluster[i], 1);
+        free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1);
 
     ret = 0;
 err:
-- 
1.6.1