Statistics
| Branch: | Revision:

root / block / qcow2.h @ f53ec699

History | View | Annotate | Download (13 kB)

# Date Author Comment
64aa99d3 07/26/2013 10:59 pm Kevin Wolf

qcow2: Use dashes instead of underscores in options

This is what QMP wants to use. The options haven't been enabled in any
release yet, so we're still free to change them.

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

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

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...
753d9b82 04/13/2013 02:51 pm Aurelien Jarno

aes: move aes.h from include/block to include/qemu

Move aes.h from include/block to include/qemu to show it can be reused
by other subsystems.

Cc: Kevin Wolf <>
Reviewed-by: Stefan Hajnoczi <>
Reviewed-by: Edgar E. Iglesias <>...

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

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

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

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

acdfb480 03/19/2013 12:48 pm Kevin Wolf

qcow2: Fix segfault in qcow2_invalidate_cache

Need to pass an options QDict to qcow2_open() now. This fixes a segfault
on the migration target with qcow2.

Signed-off-by: Kevin Wolf <>

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

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

qcow2: introduce dirty bit

This patch adds an incompatible feature bit to mark images that have not
been closed cleanly. When a dirty image file is opened a consistency
check and repair is performed.

Update qemu-iotests 031 and 036 since the extension header size changes...

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

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

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

qcow2: Support for fixing refcount inconsistencies

Signed-off-by: Kevin Wolf <>

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

qcow2: Zero write support

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

6744cbab 04/20/2012 04:57 pm Kevin Wolf

qcow2: Version 3 images

This adds the basic infrastructure to qcow2 to handle version 3 images.
It includes code to create v3 images, allow header updates for v3 images
and checks feature bits.

It still misses support for zero clusters, so this is not a fully...

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

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

qcow2: Support for feature table header extension

Instead of printing an ugly bitmask, qemu can now print a more helpful
string even for yet unknown features.

Signed-off-by: Kevin Wolf <>

90b27759 04/20/2012 04:57 pm Kevin Wolf

qcow2: Save disk size in snapshot header

This allows that different snapshots of an image can have different
sizes, which is a requirement for enabling image resizing even with
images that have internal snapshots.

We don't do the actual support for it now, but make sure that the...

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

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

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

e24e49e6 02/09/2012 05:17 pm Kevin Wolf

qcow2: Update whole header at once

In order to switch the backing file, qcow2 issues multiple write
requests that only changed a part of the image header. Any failure after
the first one would leave the header in an corrupted state. With this
patch, the whole header is written at once, so we can't fail in the...

75bab85c 02/09/2012 05:17 pm Kevin Wolf

qcow2: Keep unknown header extension when rewriting header

If we want header extensions to work as compatible extensions, we can't
destroy yet unknown header extensions when rewriting the header (e.g.
for changing the backing file). Save all unknown header extensions in a...

c2c9a466 12/15/2011 01:40 pm Kevin Wolf

qcow2: Allow >4 GB VM state

This is a compatible extension to the snapshot header format that allows
saving a 64 bit VM state size.

Signed-off-by: Kevin Wolf <>

06d9260f 11/21/2011 10:58 pm Anthony Liguori

qcow2: implement bdrv_invalidate_cache (v2)

We don't reopen the actual file, but instead invoke the close and open routines.
We specifically ignore the backing file since it's contents are read-only and
therefore immutable.

Signed-off-by: Anthony Liguori <>

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

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

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

qcow2: Use coroutines

Signed-off-by: Kevin Wolf <>

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

99cce9fa 06/08/2011 12:56 pm Kevin Wolf

qemu-img create: Fix displayed default cluster size

When not specifying a cluster size on the command line, qemu-img printed
a cluster size of 0:

Formatting '/tmp/test.qcow2', fmt=qcow2 size=67108864
encryption=off cluster_size=0

This patch adds the default cluster size to the QEMUOptionParameter list, so...

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

49381094 01/24/2011 12:08 pm Kevin Wolf

qcow2: Add QcowCache

This adds some new cache functions to qcow2 which can be used for caching
refcount blocks and L2 tables. When used with cache=writethrough they work
like the old caching code which is spread all over qcow2, so for this case we
have merely a cleanup....

80465c50 11/24/2010 06:31 pm Kevin Wolf

block: Remove unused s->hd in various drivers

All drivers use bs->file instead of s->hd for quite a while now, so it's time
to remove s->hd.

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

51ef6727 10/22/2010 03:49 pm edison

Copy snapshots out of QCOW2 disk

In order to backup snapshots, created from QCOW2 iamge, we want to copy snapshots out of QCOW2 disk to a seperate storage.
The following patch adds a new option in "qemu-img": qemu-img convert -f qcow2 -O qcow2 -s snapshot_name src_img bck_img....

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

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

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

419b19d9 05/03/2010 11:07 am Stefan Hajnoczi

qcow2: Implement bdrv_truncate() for growing images

This patch adds the ability to grow qcow2 images in-place using
bdrv_truncate(). This enables qemu-img resize command support for
qcow2.

Snapshots are not supported and bdrv_truncate() will return -ENOTSUP....

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

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

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

72ecf02d 10/27/2009 07:28 pm Kevin Wolf

Revert "qcow2: Bring synchronous read/write back to life"

It was merely a workaround and the real fix is done now.
This reverts commit ef845c3bf421290153154635dc18eaa677cecb43.

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

ef845c3b 10/15/2009 05:32 pm Kevin Wolf

qcow2: Bring synchronous read/write back to life

When the synchronous read and write functions were dropped, they were replaced
by generic emulation functions. Unfortunately, these emulation functions don't
provide the same semantics as the original functions did....

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

72cf2d4f 09/12/2009 10:36 am Blue Swirl

Fix sys-queue.h conflict for good

Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...

f214978a 09/10/2009 01:31 am Kevin Wolf

qcow2: Order concurrent AIO requests on the same unallocated cluster

When two AIO requests write to the same cluster, and this cluster is
unallocated, currently both requests allocate a new cluster and the second one
merges the first one when it is completed. This means an cluster allocation, a...

14899cdf 06/29/2009 04:52 pm Filip Navara

Fix QCOW2 debugging code to compile again

Updated to use C99 comments.

Signed-off-by: Filip Navara <>
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...

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

qcow2: Split out snapshot functions

qcow2-snapshot.c contains the code related to snapshotting.

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

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