Statistics
| Branch: | Revision:

root / block / qcow2-refcount.c @ a77cffe7

History | View | Annotate | Download (39.2 kB)

# Date Author Comment
83e3f76c 10/13/2010 09:38 pm Blue Swirl

block: avoid a write only variable

Compiling with GCC 4.6.0 20100925 produced a warning:
/src/qemu/block/qcow2-refcount.c: In function 'update_refcount':
/src/qemu/block/qcow2-refcount.c:552:13: error: variable 'dummy' set but not used [-Werror=unused-but-set-variable]...

c01828fb 09/21/2010 04:39 pm Kevin Wolf

qcow2: Move sync out of write_refcount_block_entries

Signed-off-by: Kevin Wolf <>

1c4c2814 09/21/2010 04:39 pm Kevin Wolf

qcow2: Move sync out of update_refcount

Note that the flush is omitted intentionally in qcow2_free_clusters. If
anything, we can leak clusters here if we lose the writes.

Signed-off-by: Kevin Wolf <>

29216ed1 09/21/2010 04:39 pm Kevin Wolf

qcow2: Move sync out of qcow2_alloc_clusters

Signed-off-by: Kevin Wolf <>

9ac228e0 07/06/2010 06:05 pm Kevin Wolf

qcow2/vdi: Change check to distinguish error cases

This distinguishes between harmless leaks and real corruption. Hopefully users
better understand what qemu-img check wants to tell them.

Signed-off-by: Kevin Wolf <>

8b3b7206 06/22/2010 03:38 pm Kevin Wolf

qcow2: Use bdrv_(p)write_sync for metadata writes

Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.

Signed-off-by: Kevin Wolf <>

6882c8fa 06/22/2010 03:38 pm Kevin Wolf

qcow2: Fix qemu-img check segfault on corrupted images

With corrupted images, we can easily get an cluster index that exceeds the
array size of the temporary refcount table.

Signed-off-by: Kevin Wolf <>

f74550fd 06/22/2010 03:38 pm Kevin Wolf

qcow2: Don't try to check tables that couldn't be loaded

Trying to check them leads to a second error message which is more confusing
than helpful:

Can't get refcount for cluster 0: Invalid argument
ERROR cluster 0 refcount=-22 reference=1

Signed-off-by: Kevin Wolf <>

018faafd 06/15/2010 10:41 am Kevin Wolf

qcow2: Allow get_refcount to return errors

get_refcount might need to load a refcount block from disk, so errors may
happen. Return the error code instead of assuming a refcount of 1 and change
the callers to respect error return values.

Signed-off-by: Kevin Wolf <>

2eaa8f63 06/15/2010 10:41 am Kevin Wolf

qcow2: Allow alloc_clusters_noref to return errors

Currently it would consider blocks for which get_refcount fails used. However,
it's unlikely that get_refcount would succeed for the next cluster, so it's not
really helpful. Return an error instead.

Signed-off-by: Kevin Wolf <>

e14e8ba5 06/15/2010 10:41 am Kevin Wolf

qcow2: Return real error code in load_refcount_block

This fixes load_refcount_block which completely ignored the return value of
write_refcount_block and always returned -EIO for bdrv_pwrite failure.

Signed-off-by: Kevin Wolf <>

86fa8da8 05/28/2010 02:29 pm Kevin Wolf

qcow2: Fix corruption after error in update_refcount

After it is done with updating refcounts in the cache, update_refcount writes
all changed entries to disk. If a refcount block allocation fails, however,
there was no change yet and therefore first_index = last_index = -1. Don't...

25408c09 05/28/2010 02:29 pm Kevin Wolf

qcow2: Fix corruption after refblock allocation

Refblock allocation code needs to take into consideration that update_refcount
will load a different refcount block into the cache, so it must initialize the
cache for a new refcount block only afterwards. Not doing this means that not...

ed0df867 05/28/2010 02:29 pm Kevin Wolf

qcow2: Return right error code in write_refcount_block_entries

write_refcount_block_entries used to return -EIO for any errors. Change this to
return the real error code.

Signed-off-by: Kevin Wolf <>

003fad6e 05/03/2010 11:07 am Kevin Wolf

qcow2: Remove abort on free_clusters failure

While it's true that during regular operation free_clusters failure would be a
bug, an I/O error can always happen. There's no need to kill the VM, the worst
thing that can happen (and it will) is that we leak some clusters....

508e0893 05/03/2010 11:07 am Stefan Hajnoczi

qcow2: Avoid shadowing variable in alloc_clusters_noref()

The i loop iterator is shadowed by the next free cluster index. Both
using the variable name 'i' makes the code harder to read.

Signed-off-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

66f82cee 05/03/2010 11:07 am Kevin Wolf

block: Open the underlying image file in generic code

Format drivers shouldn't need to bother with things like file names, but rather
just get an open BlockDriverState for the underlying protocol. This patch
introduces this behaviour for bdrv_open implementation. For protocols which...

8252278a 04/23/2010 05:08 pm Kevin Wolf

qcow2: Trigger blkdebug events

This adds blkdebug events to qcow2 to allow injecting I/O errors in specific
places.

Signed-off-by: Kevin Wolf <>

05121aed 02/23/2010 09:23 pm Kevin Wolf

qcow2: Factor next_refcount_table_size out

When the refcount table grows, it doesn't only grow by one entry but reserves
some space for future refcount blocks. The algorithm to calculate the number of
entries stays the same with the fixes, so factor it out before replacing the...

92dcb59f 02/23/2010 09:23 pm Kevin Wolf

qcow2: Rewrite alloc_refcount_block/grow_refcount_table

The current implementation of alloc_refcount_block and grow_refcount_table has
fundamental problems regarding error handling. There are some places where an
I/O error means that the image is going to be corrupted. I have found that the...

746c3cb5 02/23/2010 09:23 pm Kevin Wolf

qcow2: More checks for qemu-img check

Implement some more refcount block related checks

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

f2b7c8b3 01/26/2010 10:59 pm Kevin Wolf

qcow2: Fix error handling in grow_refcount_table

Return the appropriate error code instead of -EIO.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

09508d13 01/26/2010 10:59 pm Kevin Wolf

qcow2: Improve error handling in update_refcount

If update_refcount fails, try to undo any changes made so far to avoid
inconsistencies in the image file.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

7322afe7 01/26/2010 10:59 pm Kevin Wolf

qcow2: Allow updating no refcounts

There's absolutely no problem with updating the refcounts of 0 clusters.
At least snapshot code is doing this and would fail once the result of
update_refcount isn't ignored any more.

Signed-off-by: Kevin Wolf <>...

db3a964f 01/26/2010 10:59 pm Kevin Wolf

qcow2: Don't ignore update_refcount return value

update_refcount can return errors that need to be handled by the callers.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

5d757b56 01/26/2010 10:59 pm Kevin Wolf

qcow2: Don't ignore qcow2_alloc_clusters return value

Now that qcow2_alloc_clusters can return error codes, we must handle them in
the callers of qcow2_alloc_clusters.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

f7dcfac0 01/14/2010 01:14 am Amit Shah

qcow2-refcount: remove dead assignment

clang-analyzer points out a redundant assignment.

Signed-off-by: Amit Shah <>
Signed-off-by: Anthony Liguori <>

702ef63f 12/03/2009 07:45 pm Kevin Wolf

qcow2: Fix some more qemu_malloc fallout

Oh joy...

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

c5baaa48 10/27/2009 07:28 pm Kevin Wolf

qcow2: Fix grow_refcount_table error handling

In case of failure, we haven't increased the refcount for the newly allocated
cluster yet. Therefore we must not free the cluster or its refcount will become
negative (and endless recursion is possible).

Signed-off-by: Kevin Wolf <>...

80ee15a6 10/05/2009 05:32 pm Kevin Wolf

qcow2: Increase maximum cluster size to 2 MB

This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128k
clusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bit
truncation and wraparound of signed integers. Therefore some variables need to...

0bf9e31a 07/20/2009 08:19 pm Blue Swirl

Fix most warnings (errors with -Werror) when debugging is enabled

I used the following command to enable debugging:
perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * /* *//*

Signed-off-by: Blue Swirl <>

3f6a3ee5 07/10/2009 09:44 pm Kevin Wolf

qcow2: Fix L1 table memory allocation

Contrary to what one could expect, the size of L1 tables is not cluster
aligned. So as we're writing whole sectors now instead of single entries,
we need to ensure that the L1 table in memory is large enough; otherwise...

3b88e52b 06/29/2009 10:18 pm Kevin Wolf

qcow2: Cache refcount blocks during snapshot creation

The really time consuming part of snapshotting is to adjust the reference count
of all clusters. Currently after each adjusted cluster the refcount block is
written to disk.

Don't write each single byte immediately to disk but cache all writes to the...

9923e05e 06/16/2009 11:18 pm Kevin Wolf

update_refcount: Write complete sectors

When updating the refcount blocks in update_refcount(), write complete sectors
instead of updating single entries.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

f7d0fe02 06/16/2009 11:18 pm Kevin Wolf

qcow2: Split out refcount handling

qcow2-refcount.c contains all functions which are related to cluster
allocation and management in the image file. A large part of this is the
reference counting of these clusters.

Also a header file qcow2.h is introduced which will contain the interface of...

45aba42f 06/16/2009 11:18 pm Kevin Wolf

qcow2: Split out guest cluster functions

qcow2-cluster.c contains all functions related to the management of guest
clusters, i.e. what the guest sees on its virtual disk. This code is about
mapping these guest clusters to host clusters in the image file using the...

ed6ccf0f 06/16/2009 11:18 pm Kevin Wolf

qcow2: Rename global functions

The qcow2 source is now split into several more manageable files. During the
conversion quite some functions that were static before needed to be changed to
be global to make the source compile again.

We were lucky enough not to get name conflicts with these additional global...