Statistics
| Branch: | Revision:

root / block / qcow2-cluster.c @ 34b5d2c6

History | View | Annotate | Download (52.9 kB)

# Date Author Comment
670df5e3 09/12/2013 11:12 am Kevin Wolf

qcow2: Pass discard type to qcow2_discard_clusters()

The function will be used internally instead of only being called for
guest discard requests.

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

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

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

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

qcow2: Employ metadata overlap checks

The pre-write overlap check function is now called before most of the
qcow2 writes (aborting it on collision or other error).

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

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

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

2cf7cfa1 05/14/2013 05:44 pm Kevin Wolf

qcow2: Catch some L1 table index overflows

This catches the situation that is described in the bug report at
https://bugs.launchpad.net/qemu/+bug/865518 and goes like this:

$ qemu-img create -f qcow2 huge.qcow2 $((1024*1024))T
Formatting 'huge.qcow2', fmt=qcow2 size=1152921504606846976 encryption=off cluster_size=65536 lazy_refcounts=off...
710c2496 03/28/2013 12:52 pm Kevin Wolf

qcow2: Use byte granularity in qcow2_alloc_cluster_offset()

This gets rid of the nb_clusters and keep_clusters and the associated
complicated calculations. Just advance the number of bytes that have
been processed and everything is fine.

This patch advances the variables even after the last operation even...

88c6588c 03/28/2013 12:52 pm Kevin Wolf

qcow2: Allow requests with multiple l2metas

Instead of expecting a single l2meta, have a list of them. This allows
to still have a single I/O request for the guest data, even though
multiple l2meta may be needed in order to describe both a COW overwrite
and a new cluster allocation (typical sequential write case)....

2c3b32d2 03/28/2013 12:52 pm Kevin Wolf

qcow2: Move cluster gathering to a non-looping loop

This patch is mainly to separate the indentation change from the
semantic changes. All that really changes here is that everything moves
into a while loop, all 'goto done' become 'break' and at the end of the...

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

qcow2: Gather clusters in a looping loop

Instead of just checking once in exactly this order if there are
dependendies, non-COW clusters and new allocation, this starts looping
around these. This way we can, for example, gather non-COW clusters after
new allocations as long as the host cluster offsets stay contiguous....

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

qcow2: Improve check for overlapping allocations

The old code detected an overlapping allocation even when the
allocations didn't actually overlap, but were only adjacent.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Eric Blake <>...

65eb2e35 03/28/2013 12:52 pm Kevin Wolf

qcow2: Change handle_dependency to byte granularity

This is a more precise description of what really constitutes a
dependency. The behaviour doesn't change at this point because the COW
area of the old request is still aligned to cluster boundaries and
therefore an overlap is detected wheneven the requests touch any part of...

037689d8 03/28/2013 12:52 pm Kevin Wolf

qcow2: Decouple cluster allocation from cluster reuse code

This moves some code that prepares the allocation of new clusters to
where the actual allocation happens. This is the minimum required to be
able to move it to a separate function in the next patch....

10f0ed8b 03/28/2013 12:52 pm Kevin Wolf

qcow2: Factor out handle_alloc()

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

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

qcow2: handle_alloc(): Get rid of nb_clusters parameter

We already communicate the same information in *bytes.

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

3b8e2e26 03/28/2013 12:52 pm Kevin Wolf

qcow2: handle_alloc(): Get rid of keep_clusters parameter

handle_alloc() is now called with the offset at which the actual new
allocation starts instead of the offset at which the whole write request
starts, part of which may already be processed.

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

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

qcow2: Finalise interface of handle_alloc()

The interface works completely on a byte granularity now and duplicated
parameters are removed.

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

83baa9a4 03/28/2013 12:52 pm Kevin Wolf

qcow2: Clean up handle_alloc()

Things can be simplified a bit now. No semantic changes.

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

0af729ec 03/28/2013 12:52 pm Kevin Wolf

qcow2: Factor out handle_copied()

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

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

qcow2: handle_copied(): Get rid of nb_clusters parameter

handle_copied() uses its bytes parameter now to determine how many
clusters it should try to find.

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

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

qcow2: handle_copied(): Get rid of keep_clusters parameter

Now *bytes is used to return the length of the area that can be written
to without performing an allocation or COW.

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

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

qcow2: handle_copied(): Implement non-zero host_offset

Look only for clusters that start at a given physical offset.

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

411d62b0 03/28/2013 12:52 pm Kevin Wolf

qcow2: Prepare handle_alloc/copied() for byte granularity

This makes handle_alloc() and handle_copied() return byte-granularity
host offsets instead of returning always the cluster start. This is
required so that qcow2_alloc_cluster_offset() can stop aligning...

17a71e58 03/28/2013 12:52 pm Kevin Wolf

qcow2: Handle dependencies earlier

Handling overlapping allocations isn't just a detail of cluster
allocation. It is rather one of three ways to get the host cluster
offset for a write request:

1. If a request overlaps an in-flight allocations, the cluster offset...

381b487d 03/15/2013 05:07 pm Paolo Bonzini

qcow2: make is_allocated return true for zero clusters

Otherwise, live migration of the top layer will miss zero clusters and
let the backing file show through. This also matches what is done in qed.

QCOW2_CLUSTER_ZERO clusters are invalid in v2 image files. Check this...

74c4510a 03/15/2013 05:07 pm Kevin Wolf

qcow2: Allow lazy refcounts to be enabled on the command line

qcow2 images now accept a boolean lazy_refcounts options. Use it like
this:

-drive file=test.qcow2,lazy_refcounts=on

If the option is specified on the command line, it overrides the default...

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

block: move include files to include/block/

Signed-off-by: Paolo Bonzini <>

1d3afd64 12/13/2012 04:37 pm Kevin Wolf

qcow2: Round QCowL2Meta.offset down to cluster boundary

The offset within the cluster is already present as n_start and this is
what the code uses. QCowL2Meta.offset is only needed at a cluster
granularity.

Signed-off-by: Kevin Wolf <>

593fb83c 12/13/2012 04:37 pm Kevin Wolf

qcow2: Introduce Qcow2COWRegion

This makes it easier to address the areas for which a COW must be
performed. As a nice side effect, the COW code in
qcow2_alloc_cluster_link_l2 becomes really trivial.

Signed-off-by: Kevin Wolf <>

060bee89 12/13/2012 04:37 pm Kevin Wolf

qcow2: Drop l2meta.cluster_offset

There's no real reason to have an l2meta for normal requests that don't
allocate anything. Before we can get rid of it, we must return the host
cluster offset in a different way.

Signed-off-by: Kevin Wolf <>

f50f88b9 12/13/2012 04:37 pm Kevin Wolf

qcow2: Allocate l2meta only for cluster allocations

Even for writes to already allocated clusters, an l2meta is allocated,
though it stays effectively unused. After this patch, only allocating
requests still have one. Each l2meta now describes an in-flight request...

280d3735 12/13/2012 04:37 pm Kevin Wolf

qcow2: Enable dirty flag in qcow2_alloc_cluster_link_l2

This is closer to where the dirty flag is really needed, and it avoids
having checks for special cases related to cluster allocation directly
in the writev loop.

Signed-off-by: Kevin Wolf <>

226c3c26 12/13/2012 04:37 pm Kevin Wolf

qcow2: Factor out handle_dependencies()

Signed-off-by: Kevin Wolf <>

bfe8043e 08/06/2012 11:39 pm Stefan Hajnoczi

qcow2: implement lazy refcounts

Lazy refcounts is a performance optimization for qcow2 that postpones
refcount metadata updates and instead marks the image dirty. In the
case of crash or power failure the image will be left in a dirty state
and repaired next time it is opened....

cdba7fee 06/15/2012 03:03 pm Kevin Wolf

qcow2: Simplify calculation for COW area at the end

copy_sectors() always uses the sum (cluster_offset + n_start) or
(start_sect + n_start), so if some value is added to both cluster_offset
and start_sect, and subtracted from n_start, it's cancelled out anyway....

b7ab0fea 06/15/2012 03:03 pm Kevin Wolf

qcow2: Fix avail_sectors in cluster allocation code

avail_sectors should really be the number of sectors from the start of
the allocation, not from the start of the write request.

We're lucky enough that this mistake didn't cause any real bug.
avail_sectors is only used in the intialiser of QCowL2Meta:...

833e4085 06/15/2012 03:03 pm Zhi Yong Wu

qcow2: remove a line of unnecessary code

Commit 3948d1d4 removed the pointer argument we filled in with l2_offset
but forgot to remove the unnecessary l2_offset assignment.

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

1417d7e4 06/15/2012 02:52 pm Kevin Wolf

qcow2: Silence false warning

Some gcc versions seem not to be able to figure out that the switch
statement covers all possible values and that c is therefore always
initialised. Add a default branch for them.

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

df021791 05/25/2012 07:12 pm Kevin Wolf

qcow2: Check qcow2_alloc_clusters_at() return value

When using qcow2_alloc_clusters_at(), the cluster allocation code
checked the wrong variable for an error code.

Signed-off-by: Kevin Wolf <>

54e68143 05/07/2012 08:33 pm Kevin Wolf

qcow2: Limit COW to where it's needed

This fixes a regression introduced in commit 250196f1. The bug leads to
data corruption, found during an Autotest run with a Fedora 8 guest.

Consider a write request whose first part is covered by an already
allocated cluster, but additional clusters need to be newly allocated....

60651f90 05/02/2012 07:39 pm Kevin Wolf

qcow2: Remove unused parameter in do_alloc_cluster_offset

Signed-off-by: Kevin Wolf <>

72424114 05/02/2012 07:39 pm Kevin Wolf

qcow2: Don't hold cache references across yield

If cache references are held while the coroutine has yielded, the cache
may get used up and abort() when it can't find a free entry.

Signed-off-by: Kevin Wolf <>

621f0589 04/20/2012 04:57 pm Kevin Wolf

qcow2: Zero write support

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

143550a8 04/20/2012 04:57 pm Kevin Wolf

qcow2: Simplify count_cow_clusters

count_cow_clusters() tries to reuse existing functions, and all it
achieves is to make things much more complicated than they really are:
Everything needs COW, unless it's a normal cluster with refcount 1.

This patch implements the obvious way of doing this, and by using...

68d000a3 04/20/2012 04:57 pm Kevin Wolf

qcow2: Ignore reserved bits in get_cluster_offset

With this change, reading from a qcow2 image ignores all reserved bits
that are set in an L1 or L2 table entry.

Now get_cluster_offset() assigns *cluster_offset only the offset without
any other flags. The cluster type is not longer encoded in the offset,...

2bfcc4a0 04/20/2012 04:57 pm Kevin Wolf

qcow2: Ignore reserved bits in count_contiguous_clusters()

Until now, count_contiguous_clusters() has an argument that allowed to
specify flags that should be ignored in the comparison, i.e. that are
allowed to change between contiguous clusters.

This patch changes the function so that it ignores all flags by default...

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

qcow2: Fail write_compressed when overwriting data

qcow2_alloc_compressed_cluster_offset() already fails if the copied flag
is set, because qcow2_write_compressed() doesn't perform COW as it would
have to do to allow this.

However, what we really want to check here is whether the cluster is...

8dc0a5e7 04/19/2012 05:03 pm Kevin Wolf

qcow2: Fix error handling in qcow2_alloc_cluster_offset

If do_alloc_cluster_offset() fails, the error handling code tried to
remove the request from the in-flight queue, to which it wasn't added
yet, resulting in a NULL pointer dereference.

m->nb_clusters really only becomes != 0 when the request is in the list....

3948d1d4 04/05/2012 03:54 pm Kevin Wolf

qcow2: Remove unused parameter in get_cluster_table()

Since everything goes through the cache, callers don't use the L2 table
offset any more.

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

bf319ece 03/12/2012 04:14 pm Kevin Wolf

qcow2: Factor out count_cow_clusters

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

250196f1 03/12/2012 04:14 pm Kevin Wolf

qcow2: Reduce number of I/O requests

If the first part of a write request is allocated, but the second isn't
and it can be allocated so that the resulting area is contiguous, handle
it at once. This is a common case for sequential writes.

After this patch, alloc_cluster_offset() only checks if the clusters are...

3cce16f4 03/12/2012 04:14 pm Kevin Wolf

qcow2: Add some tracing

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

aef4acb6 12/05/2011 03:49 pm Stefan Hajnoczi

qcow2: avoid reentrant bdrv_read() in copy_sectors()

A BlockDriverState should not issue requests on itself through the
public block layer interface. Nested, or reentrant, requests are
problematic because they do I/O throttling and request tracking twice....

1b9f1491 12/05/2011 03:49 pm Kevin Wolf

qcow2: Unlock during COW

Unlocking during COW allows for more parallelism. One change it requires is
that buffers are dynamically allocated instead of just using a per-image
buffer.

While touching the code, drop the synchronous qcow2_read() function and replace...

8f1efd00 10/21/2011 06:34 pm Kevin Wolf

qcow2: Fix bdrv_write_compressed error handling

If during allocation of compressed clusters the cluster was already allocated
uncompressed, fail and properly release the l2_table (the latter avoids a
failed assertion).

While at it, make it return some real error numbers instead of -1....

05140499 09/12/2011 04:17 pm Frediano Ziglio

qcow2: initialize metadata before inserting in cluster_allocs

QCow2Meta structure was inserted into list before many fields are
initialized. Currently is not a problem cause all occur in a lock
but if qcow2_alloc_clusters would in a future unlock this lock...

ee18e730 09/12/2011 04:17 pm Frediano Ziglio

qcow2: fix range check

QCowL2Meta::offset is not cluster aligned but only sector aligned
however nb_clusters count cluster from cluster start.
This fix range check. Note that old code have no corruption issues
related to this check cause it only cause intersection to occur...

a7912369 09/12/2011 04:17 pm Frediano Ziglio

qcow2: removed unused depends_on field

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

d57237f2 08/23/2011 03:15 pm Devin Nakamura

qcow2: fix typo in documentation for qcow2_get_cluster_offset()

Documentation states the num is measured in clusters, but its
actually measured in sectors

Signed-off-by: Devin Nakamura <>
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 <>

68d100e9 08/02/2011 04:53 pm Kevin Wolf

qcow2: Use coroutines

Signed-off-by: Kevin Wolf <>

9e2a3701 06/15/2011 03:36 pm Kevin Wolf

qcow2: Fix in-flight list after qcow2_cache_put failure

If qcow2_cache_put returns an error during cluster allocation and the
allocation fails, it must be removed from the list of in-flight allocations.
Otherwise we'd get a loop in the list when the ACB is used for the next...

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

16fde5f2 02/10/2011 02:24 pm Kevin Wolf

qcow2: Fix order in L2 table COW

When copying L2 tables (this happens only with internal snapshots), the order
wasn't completely safe, so that after a crash you could end up with a L2 table
that has too low refcount, possibly leading to corruption in the long run....

8af36488 02/10/2011 02:23 pm Kevin Wolf

qcow2: Fix error handling for reading compressed clusters

When reading a compressed cluster failed, qcow2 falsely returned success.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Markus Armbruster <>

5ea929e3 01/31/2011 11:03 am Kevin Wolf

qcow2: Add bdrv_discard support

This adds a bdrv_discard function to qcow2 that frees the discarded clusters.
It does not yet pass the discard on to the underlying file system driver, but
the space can be reused by future writes to the image.

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

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

3de0a294 01/24/2011 05:41 pm Kevin Wolf

qcow2: Batch flushes for COW

qcow2 calls bdrv_flush() after performing COW in order to ensure that the
L2 table change is never written before the copy is safe on disk. Now that the
L2 table is cached, we can wait with flushing until we write out the next L2...

653df36b 01/24/2011 12:08 pm Aurelien Jarno

qcow2: fix unaligned access

cpu_to_be64w() is called with an obviously non-aligned pointer. Use
cpu_to_be64wu() instead. It fixes unaligned accesses errors on IA64
hosts.

Cc: Kevin Wolf <>
Signed-off-by: Aurelien Jarno <>...

7c80ab3f 12/17/2010 05:15 pm Jes Sorensen

block/qcow2.c: rename qcow_ functions to qcow2_

It doesn't really make sense for functions in qcow2.c to be named
qcow_ so convert the names to match correctly.

Signed-off-by: Jes Sorensen <>
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 <>

72893756 10/22/2010 03:49 pm Stefan Hajnoczi

qcow2: Support exact L1 table growth

The L1 table grow operation includes a size calculation that bumps up
the new L1 table size in order to anticipate the size needs of vmstate
data. This helps reduce the number of times that the L1 table has to be
grown when vmstate data is appended....

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

qcow2: Move sync out of qcow2_alloc_clusters

Signed-off-by: Kevin Wolf <>

9f8e668e 09/21/2010 04:39 pm Kevin Wolf

qcow2: Get rid of additional sync on COW

We always have a sync for the refcount update when a new cluster is
allocated. If we move this past the COW, we can save an additional sync.

Signed-off-by: Kevin Wolf <>

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

qcow2: Avoid bounce buffers for AIO read requests

qcow2 used to use bounce buffers for any AIO requests. This does not only imply
unnecessary copying, but also unbounded allocations which should be avoided.

This patch removes bounce buffers from the normal AIO read path, and constrains...

7ec5e6a4 09/08/2010 01:39 pm Kevin Wolf

qcow2: Remove unnecessary flush after L2 write

When a new cluster was allocated, we only need a flush after the write to the
L2 table if it was a COW and we need to decrease the refcounts of the old
clusters.

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

68dba0bf 06/15/2010 10:41 am Kevin Wolf

qcow2: Restore L1 entry on l2_allocate failure

If writing the L1 table to disk failed, we need to restore its old content in
memory to avoid inconsistencies.

Reported-by: Juan Quintela <>
Signed-off-by: Kevin Wolf <>

55c17e98 05/28/2010 02:29 pm Kevin Wolf

qcow2: Change l2_load to return 0/-errno

Provide the error code to the caller instead of just indicating success/error.

Signed-off-by: Kevin Wolf <>

1c46efaa 05/28/2010 02:29 pm Kevin Wolf

qcow2: Allow qcow2_get_cluster_offset to return errors

qcow2_get_cluster_offset() looks up a given virtual disk offset and returns the
offset of the corresponding cluster in the image file. Errors (e.g. L2 table
can't be read) are currenctly indicated by a return value of 0, which is...

1b7c801b 05/28/2010 02:14 pm Kevin Wolf

qcow2: Clear L2 table cache after write error

If the L2 table was already updated in cache, but writing it to disk has
failed, we must not continue using the changed version in the cache to stay
consistent with what's on the disk.

Signed-off-by: Kevin Wolf <>

175e1152 05/28/2010 02:14 pm Kevin Wolf

qcow2: Fix error handling in l2_allocate

l2_allocate has some intermediate states in which the image is inconsistent.
Change the order to write to the L1 table only after the new L2 table has
successfully been initialized.

Also reset the L2 cache in failure case, it's very likely wrong....

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

79a31189 04/23/2010 05:08 pm Kevin Wolf

qcow2: Return 0/-errno in write_l2_entries

Change write_l2_entries to return the real error code instead of -1.

Signed-off-by: Kevin Wolf <>

c835d00f 04/23/2010 05:08 pm Kevin Wolf

qcow2: Fix error return code in qcow2_alloc_cluster_link_l2

Fix qcow2_alloc_cluster_link_l2 to return the real error code like it does in
all other error cases.

Signed-off-by: Kevin Wolf <>

f7defcb6 04/23/2010 05:08 pm Kevin Wolf

qcow2: Return 0/-errno in write_l1_entry

Change write_l1_entry to return the real error code instead of -1.

Signed-off-by: Kevin Wolf <>

c46e1167 04/23/2010 05:08 pm Kevin Wolf

qcow2: Return 0/-errno in l2_allocate

Returning NULL on error doesn't allow distinguishing between different errors.
Change the interface to return an integer for -errno.

Signed-off-by: Kevin Wolf <>

c644db3d 04/10/2010 02:25 am Kevin Wolf

qcow2: Remove request from in-flight list after error

If we complete a request with a failure we need to remove it from the list of
requests that are in flight. If we don't do it, the next time the same AIOCB is
used for a cluster allocation it will create a loop in the list and qemu will...

4805bb66 02/19/2010 11:53 pm Kevin Wolf

qcow2: Fix access after end of array

If a write requests crosses a L2 table boundary and all clusters until the
end of the L2 table are usable for the request, we must not look at the next
L2 entry because we already have arrived at the end of the array....

f4f0d391 02/10/2010 07:56 pm Kevin Wolf

qcow2: Fix signedness bugs

Checking for return codes < 0 isn't really going to work with unsigned
types. Use signed types instead.

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

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

qcow2: Fix error handling in qcow2_grow_l1_table

Return the appropriate error value instead of always using EIO. Don't free the
L1 table on errors, we still need it.

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

1e3e8f1a 01/26/2010 10:59 pm Kevin Wolf

qcow2: Return 0/-errno in get_cluster_table

Switching to 0/-errno allows it to distinguish different error cases.

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

148da7ea 01/26/2010 10:59 pm Kevin Wolf

qcow2: Return 0/-errno in qcow2_alloc_cluster_offset

Returning 0/-errno allows it to distingush different errors classes. The
cluster offset of newly allocated clusters is now returned in the QCowL2Meta
struct.

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

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

d191d12d 11/09/2009 04:43 pm Stefan Weil

qcow2: Allow qcow2 disk images with size zero

Images with disk size 0 may be used for
VM snapshots, but not to save normal block data.

It is possible to create such images using
qemu-img, but opening them later fails.

So even "qemu-img info image.qcow2" is not...