Statistics
| Branch: | Revision:

root / block / qcow2.c @ 7fa60fa3

History | View | Annotate | Download (40.9 kB)

# Date Author Comment
6daf194d 06/24/2011 11:13 am Markus Armbruster

Strip trailing '\n' from error_report()'s first argument

error_report() prepends location, and appends a newline. The message
constructed from the arguments should not contain a newline. Fix the
obvious offenders.

Signed-off-by: Markus Armbruster <>...

42496d62 06/14/2011 06:03 pm Kevin Wolf

qcow2: Avoid direct AIO callback

bdrv_aio_* must not call the callback before returning to its caller. In qcow2,
this could happen in some error cases. This starts the real requests processing
in a BH to avoid this situation.

Signed-off-by: Kevin Wolf <>

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

a6599793 06/08/2011 11:39 am Christoph Hellwig

block: clarify the meaning of BDRV_O_NOCACHE

Change BDRV_O_NOCACHE to only imply bypassing the host OS file cache,
but no writeback semantics. All existing callers are changed to also
specify BDRV_O_CACHE_WB to give them writeback semantics.

Signed-off-by: Christoph Hellwig <>...

e8cdcec1 02/10/2011 02:23 pm Kevin Wolf

qcow2: Report error for version > 2

The qcow2 driver is now declared responsible for any QCOW image that has
version 2 or greater (before this, version 3 would be detected as raw).

For everything newer than version 2, an error is reported.

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

e0d9c6f9 02/10/2011 02:23 pm Chunqiang Tang

QCOW2: bug fix - read base image beyond its size

This patch fixes the following bug in QCOW2. For a QCOW2 image that is larger
than its base image, when handling a read request straddling over the end of the
base image, the QCOW2 driver attempts to read beyond the end of the base image...

3ab4c7e9 02/10/2011 02:23 pm Kevin Wolf

qcow2: Fix error handling for immediate backing file read failure

Requests could return success even though they failed when bdrv_aio_readv
returned NULL for a backing file read.

Reported-by: Chunqiang Tang <>
Signed-off-by: Kevin Wolf <>

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

e1a7107f 02/07/2011 10:44 am Kevin Wolf

qcow2: Really use cache=unsafe for image creation

For cache=unsafe we also need to set BDRV_O_CACHE_WB, otherwise we have some
strange unsafe writethrough mode.

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

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

6d85a57e 12/17/2010 05:15 pm Jes Sorensen

Add proper -errno error return values to qcow2_open()

In addition this adds missing braces to the function to be consistent
with the coding style.

Signed-off-by: Jes Sorensen <>
Signed-off-by: Kevin Wolf <>

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

205ef796 11/04/2010 01:52 pm Kevin Wolf

block: Allow bdrv_flush to return errors

This changes bdrv_flush to return 0 on success and -errno in case of failure.
It's a requirement for implementing proper error handle in users of bdrv_flush.

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

a9420734 10/22/2010 03:49 pm Kevin Wolf

qcow2: Simplify image creation

Instead of doing lots of magic for setting up initial refcount blocks and stuff
create a minimal (inconsistent) image, open it and initialize the rest with
regular qcow2 functions.

This is a complete rewrite of the image creation function. The old...

9b036055 10/22/2010 03:49 pm Kevin Wolf

qcow2: Remove old image creation function

They have been #ifdef'd out by the previous patch.

Signed-off-by: Kevin Wolf <>

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

6f5f060b 09/21/2010 04:39 pm Kevin Wolf

qcow2: Avoid bounce buffers for AIO write 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 write path. Encrypted...

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

19dbcbf7 07/02/2010 02:18 pm Kevin Wolf

qcow2: Fix error handling during metadata preallocation

People were wondering why qemu-img check failed after they tried to preallocate
a large qcow2 file and ran out of disk space.

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

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

0bfcd599 05/22/2010 11:02 am Blue Swirl

Fix %lld or %llx printf format use

Signed-off-by: Blue Swirl <>

b666d239 05/17/2010 11:20 am Kevin Wolf

block: Avoid unchecked casts for AIOCBs

Use container_of for one direction and &acb->common for the other one.

Signed-off-by: Kevin Wolf <>

92b30744 05/07/2010 08:11 pm Kevin Wolf

qcow2: Remove static forward declaration

OpenBSDs gcc is said to generate warnings for this declaration, so don't
reference bdrv_qcow2 directly, but look it up using bdrv_find_format.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Blue Swirl <>

de5f3f40 05/07/2010 08:11 pm Kevin Wolf

Revert "Fix OpenBSD build"

This reverts commit 20d97356c9df6d68fbd37d6334fdb7063f24eab6.
The BlockDriver definition should stay at the end of source files.

Conflicts:

block/qcow2.c

Signed-off-by: Kevin Wolf <>
Signed-off-by: Blue Swirl <>

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

20d97356 04/23/2010 11:19 pm Blue Swirl

Fix OpenBSD build

GCC 3.3.5 generates warnings for static forward declarations of data, so
rearrange code to use static forward declarations of functions instead.

Signed-off-by: Blue Swirl <>

d4c146f0 04/23/2010 05:21 pm Stefan Hajnoczi

qcow2: Use QLIST_FOREACH_SAFE macro

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

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

4768fa90 04/23/2010 05:08 pm Kevin Wolf

qcow2: Fix creation of large images

qcow_create2 assumes that the new image will only need one cluster for its
refcount table initially. Obviously that's not true any more when the image is
big enough (exact value depends on the cluster size).

This patch calculates the refcount table size dynamically....

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

Replace calls of old bdrv_open

What is known today as bdrv_open2 becomes the new bdrv_open. All remaining
callers of the old function are converted to the new one. In some places they
even know the right format, so they should have used bdrv_open2 from the...

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

171e3d6b 04/10/2010 02:23 am Kevin Wolf

qcow2: Don't ignore immediate read/write failures

Returning -EIO is far from optimal, but at least it's an error code.

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

bef57da5 03/09/2010 07:23 pm Juan Quintela

qcow2: return errno instead of -1

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

6f745bda 02/23/2010 09:23 pm Kevin Wolf

qcow2: Fix image creation regression

When checking for errors, commit db89119d compares with the wrong values,
failing image creation even when there was no error. Additionally, if an
error has occured, we can't preallocate the image (it's likely broken)....

7b88e48b 01/26/2010 11:45 pm Christoph Hellwig

qcow2: rename two QCowAIOCB members

The n member is not very descriptive and very hard to grep, rename it to
cur_nr_sectors to better indicate what it is used for. Also rename
nb_sectors to remaining_sectors as that is what it is used for.

Signed-off-by: Christoph Hellwig <>...

058fc8c7 01/26/2010 11:42 pm Naphtali Sprei

Ask for read-write permissions when opening files

Found some places that seems needs this explicitly, now that
read-write is not the default.

Signed-off-by: Naphtali Sprei <>
Signed-off-by: Anthony Liguori <>

db89119d 01/26/2010 10:59 pm Kirill A. Shutemov

block/qcow2.c: fix warnings with _FORTIFY_SOURCE

CC block/qcow2.o
cc1: warnings being treated as errors
block/qcow2.c: In function 'qcow_create2':
block/qcow2.c:829: error: ignoring return value of 'write', declared with attribute warn_unused_result
block/qcow2.c:838: error: ignoring return value of 'write', declared with attribute warn_unused_result...

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

qcow2: Fix error handling in qcow_save_vmstate

Don't assume success but pass the bdrv_pwrite return value on.

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

756e6736 01/14/2010 01:14 am Kevin Wolf

block: Add bdrv_change_backing_file

Introduce the functions needed to change the backing file of an image. The
function is implemented for qcow2.

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

f8012c13 01/14/2010 01:14 am Kevin Wolf

qcow/qcow2: implement bdrv_aio_flush

Now that we do not have to flush the backing device anymore implementing
the bdrv_aio_flush method for image formats is trivial.

[hch: forward ported to qemu mainline from a product tree]

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

e1c7f0e3 12/03/2009 07:45 pm Kevin Wolf

qcow2: Store exact backing format length

Currently qcow2 unnecessarily rounds up the length of the backing format string
to the next multiple of 8. At the same time, the array in BlockDriverState can
only hold 15 characters, so in effect backing formats with 9 characters or more...

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

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

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

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

qcow2: Fix metadata preallocation

The wrong version of the preallocation patch has been applied, so this is the
remaining diff.

We can't use truncate to grow the image file to the right size because we don't
know if metadata has been written after the last data cluster. In this case...

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

2000cbc5 08/29/2009 04:37 pm Blue Swirl

Fix gcc 3 warning about uninitialized variable

If nb_sectors is 0, cluster_offset will not be initialized.

Signed-off-by: Blue Swirl <>

a35e1c17 08/28/2009 04:30 am Kevin Wolf

qcow2: Metadata preallocation

This introduces a qemu-img create option for qcow2 which allows the metadata to
be preallocated, i.e. clusters are reserved in the refcount table and L1/L2
tables, but no data is written to them. Metadata is quite small, so this...

45566e9c 07/16/2009 04:28 pm Christoph Hellwig

replace bdrv_{get, put}_buffer with bdrv_{load, save}_vmstate

The VM state offset is a concept internal to the image format. Replace
the old bdrv_{get,put}_buffer method that require an index into the
image file that is constructed from the VM state offset and an offset...

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

0aa217e4 07/10/2009 12:06 am Kevin Wolf

qcow2: Make cache=writethrough default

The performance of qcow2 has improved meanwhile, so we don't need to
special-case it any more. Switch the default to write-through caching
like all other block drivers.

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

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

9ccb258e 06/16/2009 11:18 pm Kevin Wolf

qcow2: Change default cluster size to 64k

Larger cluster sizes mean less metadata. This has been discussion a few times,
let's do it now. This turns 64k clusters on by default for new images.

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

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

db08adf5 06/06/2009 06:38 pm Kevin Wolf

qemu-img: Print available options with -o ?

This patch adds a small help text to each of the options in the block drivers
which can be displayed by using qemu-img create -f fmt -o ?

Signed-off-by: Kevin Wolf <>

c16b5a2c 05/27/2009 05:46 pm Christoph Hellwig

fully split aio_pool from BlockDriver

Now that we have a separate aio pool structure we can remove those
aio pool details from BlockDriver.

Every driver supporting AIO now needs to declare a static AIOPool
with the aiocb size and the cancellation method. This cleans up the...

a980c98c 05/27/2009 05:45 pm Kevin Wolf

qcow2: Update multiple refcounts at once

Don't write each single changed refcount block entry to the disk after it is
written, but update all entries of the block and write all of them at once.

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

44ff42de 05/27/2009 05:45 pm Kevin Wolf

qcow2: Refactor update_refcount

This is a preparation patch with no functional changes. It moves the allocation
of new refcounts block to a new function and makes update_cluster_refcount (for
one cluster) call update_refcount (for multiple clusters) instead the other way...

ade40677 05/27/2009 05:45 pm Kevin Wolf

qcow/qcow2: Drop synchronous qcow_write()

There is only one (internal) user left and it can be switched to the normal
emulation provided in block.c

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

73c632ed 05/22/2009 06:50 pm Kevin Wolf

qcow2: Allow different cluster sizes

Add an option to specify the cluster size of a newly created qcow2 image.
Default is 4k which is the same value that was hard-coded before.

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

0e7e1989 05/22/2009 06:50 pm Kevin Wolf

Convert all block drivers to new bdrv_create

Now we can make use of the newly introduced option structures. Instead of
having bdrv_create carry more and more parameters (which are format specific in
most cases), just pass a option structure as defined by the driver itself....

eb0b64f7 05/21/2009 04:40 am malc

Do not attempt to allocate sn_tab when there are no snapshots

This was caught by a7d27b536ffc0773028a90f14580552c0c3ddb2a which
aborted on this attempt, thanks to Alex Ivanov for report.

Signed-off-by: malc <>

019d6b8f 05/15/2009 12:13 am Anthony Liguori

Move block drivers into their own directory

Signed-off-by: Anthony Liguori <>