Statistics
| Branch: | Revision:

root / block / qcow2-refcount.c @ feature-archipelago

History | View | Annotate | Download (58.7 kB)

# Date Author Comment
33304ec9 02/09/2014 10:12 am Hu Tao

qcow2: fix offset overflow in qcow2_alloc_clusters_at()

When cluster size is big enough it can lead to an offset overflow
in qcow2_alloc_clusters_at(). This patch fixes it.

The allocation is stopped each time at L2 table boundary
(see handle_alloc()), so the possible maximum bytes could be...

ac95acdb 12/06/2013 05:53 pm Hu Tao

qcow2: use start_of_cluster() and offset_into_cluster() everywhere

Signed-off-by: Hu Tao <>
Reviewed-by: Fam Zheng <>
Signed-off-by: Stefan Hajnoczi <>

231bb267 10/11/2013 05:50 pm Max Reitz

qcow2: Use negated overflow check mask

In qcow2_check_metadata_overlap and qcow2_pre_write_overlap_check,
change the parameter signifying the checks to perform from its current
positive form to a negative one, i.e., it will no longer explicitly
specify every check to perform but rather a mask of checks not to...

3e355390 10/11/2013 05:50 pm Max Reitz

qcow2: Make overlap check mask variable

Replace the QCOW2_OL_DEFAULT macro by a variable overlap_check in
BDRVQcowState.

Signed-off-by: Max Reitz <>
Signed-off-by: Kevin Wolf <>

998b959c 10/11/2013 05:49 pm Max Reitz

qcow2: Use pread for inactive L1 in overlap check

Currently, qcow2_check_metadata_overlap uses bdrv_read to read inactive
L1 tables from disk. The number of sectors to read is calculated through
a truncating integer division, therefore, if the L1 table size is not a...

8f730dd2 10/11/2013 05:49 pm Max Reitz

qcow2: Free preallocated zero clusters

In qcow2_free_any_clusters, preallocated zero clusters should be freed
just as normal clusters are.

Signed-off-by: Max Reitz <>
Signed-off-by: Kevin Wolf <>

db074901 10/02/2013 12:40 pm Max Reitz

qcow2: CHECK_OFLAG_COPIED is obsolete

CHECK_OFLAG_COPIED as a parameter to check_refcounts_l1 and
check_refcounts_l2 is obselete now, since the OFLAG_COPIED consistency
check is actually no longer performed by these functions (but by
check_oflag_copied)....

1e242b55 10/02/2013 12:06 pm Max Reitz

qcow2: Correct endianness in overlap check

If an inactive L1 table is loaded from disk, its entries are in big
endian and have to be converted to host byte order before using them.

Signed-off-by: Max Reitz <>
Reviewed-by: Kevin Wolf <>...

7454d600 09/25/2013 11:08 am Max Reitz

qcow2: Don't shadow return value

When trying to update the refcounts for a snapshot, the return value of
update_refcount on a compressed cluster was pretty much ignored,
cancelling the update on error but returning 0. This is caused by an
inner "ret" variable shadowing the outer one (the latter is used in the...

32b6444d 09/12/2013 11:12 am Max Reitz

qcow2-cluster: Expand zero clusters

Add functionality for expanding zero clusters. This is necessary for
downgrading the image version to one without zero cluster support.

For non-backed images, this function may also just discard zero clusters
instead of truly expanding them....

afa50193 09/02/2013 11:06 am Max Reitz

qcow2-refcount: Repair shared refcount blocks

If the refcount of a refcount block is greater than one, we can at least
try to repair that problem by duplicating the affected block.

Signed-off-by: Max Reitz <>
Signed-off-by: Kevin Wolf <>

4f6ed88c 08/30/2013 04:48 pm Max Reitz

qcow2-refcount: Move OFLAG_COPIED checks

Move the OFLAG_COPIED checks out of check_refcounts_l1 and
check_refcounts_l2 and after the actual refcount checks/fixes (since the
refcounts might actually change there).

Signed-off-by: Max Reitz <>...

e23e400e 08/30/2013 04:48 pm Max Reitz

qcow2-refcount: Repair OFLAG_COPIED errors

Since the OFLAG_COPIED checks are now executed after the refcounts have
been repaired (if repairing), it is safe to assume that they are correct
but the OFLAG_COPIED flag may be not. Therefore, if its value differs...

a40f1c2a 08/30/2013 04:48 pm Max Reitz

qcow2: Metadata overlap checks

Two new functions are added; the first one checks a given range in the
image file for overlaps with metadata (main header, L1 tables, L2
tables, refcount table and blocks).

The second one should be used immediately before writing to the image...

8b81a7b6 08/30/2013 04:28 pm Max Reitz

qcow2-refcount: Snapshot update for zero clusters

Account for all cluster types in qcow2_update_snapshot_refcounts;
this prevents this function from updating the refcount of unallocated
zero clusters which effectively led to wrong adjustments of the refcount...

6cfcb9b8 06/24/2013 11:25 am Kevin Wolf

qcow2: Add refcount update reason to all callers

This adds a refcount update reason to all callers of update_refcounts(),
so that a follow-up patch can use this information to decide whether
clusters that reach a refcount of 0 should be discarded in the image...

67af674e 06/24/2013 11:25 am Kevin Wolf

qcow2: Options to enable discard for freed clusters

Deleted snapshots are discarded in the image file by default, discard
requests take their default from the -drive discard=... option and other
places that free clusters must always be enabled explicitly....

0b919fae 06/24/2013 11:25 am Kevin Wolf

qcow2: Batch discards

This optimises the discard operation for freed clusters by batching
discard requests (both snapshot deletion and bdrv_discard end up
updating the refcounts cluster by cluster).

Note that we don't discard asynchronously, but keep s->lock held. This...

c2bc78b6 04/05/2013 07:58 pm Kevin Wolf

qcow2: Return real error in qcow2_update_snapshot_refcount

This fixes the error message triggered by the following script:

cat > /tmp/blkdebug.cfg <&lt;EOF
[inject-error]
event = "cluster_free"
errno = "28"
immediately = "off"
EOF
$qemu_img create -f qcow2 test.qcow2 10G...
c2b6ff51 04/05/2013 07:58 pm Kevin Wolf

qcow2: Fix L1 write error handling in qcow2_update_snapshot_refcount

It ignored the error code, and at least the 'goto fail' is obvious
nonsense as it creates an endless loop (if the next attempt doesn't
magically succeed) and leaves the in-memory L1 table in big-endian...

c349ca4b 03/28/2013 12:52 pm Kevin Wolf

qcow2: Fix "total clusters" number in bdrv_check

This should be based on the virtual disk size, not on the size of the
image.

Interesting observation: With some VM state stored in the image file,
percentages higher than 100% are possible, even though snapshots...

c1f5bafd 03/15/2013 05:07 pm Stefan Hajnoczi

qcow2: set L2 cache dependency in qcow2_alloc_bytes()

Compressed writes use qcow2_alloc_bytes() to allocate space with byte
granularity. The affected clusters' refcounts will be incremented but
we do not need to flush yet.

Set a L2 cache dependency on the refcount block cache, so that the...

2154f24e 03/15/2013 05:07 pm Stefan Hajnoczi

qcow2: flush in qcow2_update_snapshot_refcount()

Users of qcow2_update_snapshot_refcount() do not flush consistently.
qcow2_snapshot_create() flushes but qcow2_snapshot_goto() and
qcow2_snapshot_delete() do not.

Solve this by moving the bdrv_flush() into...

f9cb2860 03/15/2013 05:07 pm Stefan Hajnoczi

qcow2: drop flush in update_cluster_refcount()

The update_cluster_refcount() function increments/decrements a cluster's
refcount and then returns the new refcount value.

There is no need to flush since both update_cluster_refcount() callers
already take care of this:...

36479179 03/15/2013 05:07 pm Stefan Hajnoczi

qcow2: drop unnecessary flush in qcow2_update_snapshot_refcount()

We already flush when the function completes. There is no need to flush
after every compressed cluster.

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

9991923b 03/15/2013 05:07 pm Stefan Hajnoczi

qcow2: flush refcount cache correctly in alloc_refcount_block()

update_refcount() affects the refcount cache, it does not write to disk.
Therefore bdrv_flush(bs->file) does nothing. We need to flush the
refcount cache in order to write out the refcount updates!...

801f7044 02/22/2013 10:21 pm Stefan Hajnoczi

qcow2: introduce check_refcounts_l1/l2() flags

The check_refcounts_l1/l2() functions have a check_copied argument to
check that the QCOW_O_COPIED flag is consistent with refcount == 1.
This should be a bool, not an int.

However, the next patch introduces qcow2 fragmentation statistics and...

fba31bae 02/22/2013 10:21 pm Stefan Hajnoczi

qcow2: record fragmentation statistics during check

The qemu-img check command can display fragmentation statistics: * Total number of clusters in virtual disk * Number of allocated clusters * Number of fragmented clusters

This patch adds fragmentation statistics support to qcow2....

4db35162 02/22/2013 10:21 pm Stefan Hajnoczi

qcow2: support compressed clusters in BlockFragInfo

Signed-off-by: Stefan Hajnoczi <>

c6bb9ad1 02/22/2013 10:21 pm Federico Simoncelli

qemu-img: find the image end offset during check

This patch adds the support for reporting the image end offset (in
bytes). This is particularly useful after a conversion (or a rebase)
where the destination is a block device in order to find the first
unused byte at the end of the image....

6528499f 01/30/2013 12:14 pm Markus Armbruster

g_malloc(0) and g_malloc0(0) return NULL; simplify

Once upon a time, it was decided that qemu_malloc(0) should abort.
Switching to glib retired that bright idea. Some code that was added
to cope with it (e.g. in commits 702ef63, b76b6e9) is still around....

737e150e 12/19/2012 09:31 am Paolo Bonzini

block: move include files to include/block/

Signed-off-by: Paolo Bonzini <>

a3548077 11/14/2012 07:19 pm Kevin Wolf

qcow2: Fix refcount table size calculation

A missing factor for the refcount table entry size in the calculation
could mean that too little memory was allocated for the in-memory
representation of the table, resulting in a buffer overflow.

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

206e6d85 07/09/2012 04:53 pm Stefan Hajnoczi

qcow2: preserve free_byte_offset when qcow2_alloc_bytes() fails

When qcow2_alloc_clusters() error handling code was introduced in commit
5d757b563d59142ca81e1073a8e8396750a0ad1a, the value of free_byte_offset
was clobbered in the error case. This patch keeps free_byte_offset at 0...

6af4e9ea 06/15/2012 03:03 pm Paolo Bonzini

qcow2: always operate caches in writeback mode

Writethrough does not need special-casing anymore in the qcow2 caches.
The block layer adds flushes after every guest-initiated data write,
and these will also flush the qcow2 caches to the OS.

Signed-off-by: Paolo Bonzini <>...

87267753 06/15/2012 03:03 pm Zhi Yong Wu

qcow2: fix endianness conversion

Signed-off-by: Zhi Yong Wu <>
Reviewed-by: Stefan Hajnoczi <>
Signed-off-by: Kevin Wolf <>

166acf54 06/15/2012 03:03 pm Kevin Wolf

qcow2: Support for fixing refcount inconsistencies

Signed-off-by: Kevin Wolf <>

76dc9e0c 04/20/2012 04:57 pm Kevin Wolf

qcow2: Ignore reserved bits in refcount table entries

Signed-off-by: Kevin Wolf <>

afdf0abe 04/20/2012 04:57 pm Kevin Wolf

qcow2: Ignore reserved bits in check_refcounts

Also don't infer the cluster type directly from the L2 entries, but use
qcow2_get_cluster_type() to keep everything in a single place.

Signed-off-by: Kevin Wolf <>

6377af48 04/20/2012 04:57 pm Kevin Wolf

qcow2: Support reading zero clusters

This adds support for reading zero clusters in version 3 images.

Signed-off-by: Kevin Wolf <>

8e37f681 04/20/2012 04:57 pm Kevin Wolf

qcow2: Ignore reserved bits in L1/L2 entries

This changes the still existing places that assume that the only flags
are QCOW_OFLAG_COPIED and QCOW_OFLAG_COMPRESSED to properly mask out
reserved bits.

It does not convert bdrv_check yet.

Signed-off-by: Kevin Wolf <>

c7a4c37a 04/20/2012 04:57 pm Kevin Wolf

qcow2: Refactor qcow2_free_any_clusters

Zero clusters will add another cluster type. Refactor the open-coded
cluster type detection into a switch of QCOW2_CLUSTER_* options so that
the detection is in a single place. This makes it easier to add new
cluster types....

f24423bd 04/20/2012 04:56 pm Kevin Wolf

qcow2: Fix refcount block allocation during qcow2_alloc_cluster_at()

Refcount block allocation and refcount table growth rely on
s->free_cluster_index pointing to somewhere after the current
allocation. Change qcow2_alloc_cluster_at() to fulfill this
assumption....

2795ecf6 04/19/2012 05:03 pm Kevin Wolf

qcow2: Fix return value of alloc_refcount_block

Someone forgot something in commit 29c1a730... Documenting the right
return value is not enough, you also need to actually return it in the
code.

This bug sometimes causes error return values even when everything has...

256900b1 03/12/2012 04:14 pm Kevin Wolf

qcow2: Add qcow2_alloc_clusters_at()

This function allows to allocate clusters at a given offset in the image
file. This is useful if you want to allocate the second part of an area
that must be contiguous.

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

43a0cac4 12/05/2011 03:51 pm Kevin Wolf

qcow2: Fix order of refcount updates in qcow2_snapshot_goto

The refcount updates must be moved so that in the worst case we can get
cluster leaks, but refcounts may never be too low.

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

2f4b7593 08/25/2011 04:23 pm Frediano Ziglio

qcow2: remove unused qcow2_create_refcount_update function

Signed-off-by: Frediano Ziglio <>
Signed-off-by: Kevin Wolf <>

35ee5e39 08/25/2011 04:22 pm Frediano Ziglio

qcow2: use always stderr for debugging

let all DEBUG_ALLOC2 printf goes to stderr

Signed-off-by: Frediano Ziglio <>
Signed-off-by: Kevin Wolf <>

7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

93913dfd 07/19/2011 04:39 pm Kevin Wolf

qcow2: Use Qcow2Cache in writeback mode during loadvm/savevm

In snapshotting there is no guest involved, so we can safely use a writeback
mode and do the flushes in the right place (i.e. at the very end). This
improves the time that creating/restoring an internal snapshot takes with an...

80fa3341 06/08/2011 12:56 pm Kevin Wolf

qcow2: Fix memory leaks in error cases

This fixes memory leaks that may be caused by I/O errors during L1 table growth
(can happen during save_vm) and in qemu-img check.

Signed-off-by: Kevin Wolf <>

a1c7273b 05/08/2011 12:02 pm Stefan Weil

Fix typos in comments and code (occured -> occurred and related)

The code changed here is an unused data type name (evt_flush_occurred).

Signed-off-by: Stefan Weil <>
Signed-off-by: Stefan Hajnoczi <>

1869a653 01/31/2011 11:05 am Blue Swirl

qcow2-refcount: remove write-only variables

Variables l2_modified and l2_size are not really used, remove them.
Spotted by GCC 4.6.0:
CC block/qcow2-refcount.o
/src/qemu/block/qcow2-refcount.c: In function 'qcow2_update_snapshot_refcount':
/src/qemu/block/qcow2-refcount.c:708:37: error: variable 'l2_modified' set but not used [-Werror=unused-but-set-variable]...

29c1a730 01/24/2011 05:41 pm Kevin Wolf

qcow2: Use QcowCache

Use the new functions of qcow2-cache.c for everything that works on refcount
block and L2 tables.

Signed-off-by: Kevin Wolf <>

1c02e2a1 11/04/2010 02:54 pm Kevin Wolf

qcow2: Invalidate cache after failed read

The cache content may be destroyed after a failed read, better not use it any
more.

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

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...