Blame qemu-fix-qcow2-corruption.patch
|
Mark McLoughlin |
35588f |
From: Kevin Wolf <kwolf@redhat.com>
|
|
Mark McLoughlin |
e1eede |
Subject: [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 |
92dcc1 |
diff -up qemu-kvm-devel-85/qemu/block-qcow2.c.qcow2-corruption qemu-kvm-devel-85/qemu/block-qcow2.c
|
|
Mark McLoughlin |
92dcc1 |
--- qemu-kvm-devel-85/qemu/block-qcow2.c.qcow2-corruption 2009-04-21 10:57:31.000000000 +0100
|
|
Mark McLoughlin |
92dcc1 |
+++ qemu-kvm-devel-85/qemu/block-qcow2.c 2009-04-24 19:29:44.000000000 +0100
|
|
Mark McLoughlin |
92dcc1 |
@@ -1007,7 +1007,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:
|