render / rpms / qemu

Forked from rpms/qemu 5 months ago
Clone

Blame qemu-fix-qcow2-corruption.patch

Mark McLoughlin 35588f
From: Kevin Wolf <kwolf@redhat.com>
Mark McLoughlin 35588f
To: qemu-devel@nongnu.org
Mark McLoughlin 35588f
Subject: [Qemu-devel] [PATCH] qcow2 corruption: Fix alloc_cluster_link_l2
Mark McLoughlin 35588f
Mark McLoughlin 35588f
This patch fixes a qcow2 corruption bug introduced in SVN Rev 5861. L2 tables
Mark McLoughlin 35588f
are big endian, so entries must be converted before being passed to functions.
Mark McLoughlin 35588f
Mark McLoughlin 35588f
This bug is easy to trigger. The following script will create and destroy a
Mark McLoughlin 35588f
qcow2 image (the header is gone after three loop iterations):
Mark McLoughlin 35588f
Mark McLoughlin 35588f
    #!/bin/bash
Mark McLoughlin 35588f
    qemu-img create -f qcow2 test.qcow 1M
Mark McLoughlin 35588f
    for i in $(seq 1 10); do
Mark McLoughlin 35588f
    qemu-system-x86_64 -hda test.qcow -monitor stdio > /dev/null 2>&1 <
Mark McLoughlin 35588f
    savevm test-$i
Mark McLoughlin 35588f
    quit
Mark McLoughlin 35588f
    EOF
Mark McLoughlin 35588f
    done
Mark McLoughlin 35588f
Mark McLoughlin 35588f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Mark McLoughlin 35588f
---
Mark McLoughlin 35588f
 block-qcow2.c |    2 +-
Mark McLoughlin 35588f
 1 files changed, 1 insertions(+), 1 deletions(-)
Mark McLoughlin 35588f
Mark McLoughlin 35588f
diff -up qemu-kvm-0.10/qemu/block-qcow2.c.qcow2-corruption qemu-kvm-0.10/qemu/block-qcow2.c
Mark McLoughlin 35588f
--- qemu-kvm-0.10/qemu/block-qcow2.c.qcow2-corruption	2009-04-20 14:41:22.000000000 +0100
Mark McLoughlin 35588f
+++ qemu-kvm-0.10/qemu/block-qcow2.c	2009-04-20 14:41:54.000000000 +0100
Mark McLoughlin 35588f
@@ -912,7 +912,7 @@ static int alloc_cluster_link_l2(BlockDr
Mark McLoughlin 35588f
         goto err;
Mark McLoughlin 35588f
 
Mark McLoughlin 35588f
     for (i = 0; i < j; i++)
Mark McLoughlin 35588f
-        free_any_clusters(bs, old_cluster[i], 1);
Mark McLoughlin 35588f
+        free_any_clusters(bs, be64_to_cpu(old_cluster[i]), 1);
Mark McLoughlin 35588f
 
Mark McLoughlin 35588f
     ret = 0;
Mark McLoughlin 35588f
 err: