Statistics
| Branch: | Revision:

root / block / qcow2-snapshot.c @ cc84d90f

History | View | Annotate | Download (20.6 kB)

# Date Author Comment
a89d89d3 09/12/2013 11:12 am Wenchao Xia

snapshot: distinguish id and name in snapshot delete

Snapshot creation actually already distinguish id and name since it take
a structured parameter *sn, but delete can't. Later an accurate delete
is needed in qmp_transaction abort and blockdev-snapshot-delete-sync,...

1ebf561c 09/12/2013 11:12 am Kevin Wolf

qcow2: Discard VM state in active L1 after creating snapshot

During savevm, the VM state is written to the active L1 of the image and
then a snapshot is taken. After that, the VM state isn't needed any more
in the active L1 and should be discarded. This is implemented by this...

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

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

qcow2: flush refcount cache correctly in qcow2_write_snapshots()

Since qcow2 metadata is cached we need to flush the caches, not just the
underlying file. Use bdrv_flush(bs) instead of bdrv_flush(bs->file).

Also add the error return path when bdrv_flush() fails and move 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...

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

block: move include files to include/block/

Signed-off-by: Paolo Bonzini <>

b35278f7 07/09/2012 04:53 pm Stefan Hajnoczi

qcow2: fix #ifdef'd qcow2_check_refcounts() callers

The DEBUG_ALLOC qcow2.h macro enables additional consistency checks
throughout the code. This makes it easier to spot corruptions that are
introduced during development. Since consistency check is an expensive...

647cc472 05/02/2012 07:39 pm Zhi Yong Wu

qcow2: fix the return value -ENOENT -> -EEXIST

Signed-off-by: Zhi Yong Wu <>
Reviewed-by: Stefan Hajnoczi <>
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...

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

d69969c4 12/05/2011 03:51 pm Kevin Wolf

qcow2: Update snapshot table information at once

Failing in the middle wouldn't help with the integrity of the image, so
doing everything in a single request seems better.

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

03343166 12/05/2011 03:51 pm Kevin Wolf

qcow2: Cleanups and memleak fix in qcow2_snapshot_create

sn->id_str could be leaked before this. The rest of this patch changes
comments, fixes coding style or removes checks that are unnecessary with
g_malloc.

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

d1ea98d5 12/05/2011 03:51 pm Kevin Wolf

qcow2: Rework qcow2_snapshot_create error handling

Increase refcounts only after allocating a new L1 table has succeeded in
order to make leaks less likely. If writing the snapshot table fails,
revert in-memory state to be consistent with that on disk.

While at it, make it return the real error codes instead of -1....

589f284b 12/05/2011 03:51 pm Kevin Wolf

qcow2: Return real error in qcow2_snapshot_goto

Besides fixing the return code, this adds some comments that make clear
how the code works and that it potentially breaks images if we fail in
the wrong place. Actually fixing this is left for the next patch....

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

9a476780 12/05/2011 03:51 pm Kevin Wolf

qcow2: Fix order in qcow2_snapshot_delete

First the snapshot must be deleted and only then the refcounts can be
decreased.

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

e3f652b3 12/05/2011 03:51 pm Kevin Wolf

qcow2: Fix error path in qcow2_snapshot_load_tmp

If the bdrv_read() of the snapshot's L1 table fails, return the right
error code and make sure that the old L1 table is still loaded and we
don't break the BlockDriverState completely.

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

42deb29f 12/05/2011 03:51 pm Kevin Wolf

qcow2: Return real error code in qcow2_read_snapshots

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

07fd8779 12/05/2011 03:51 pm Kevin Wolf

qcow2: Return real error code in qcow2_write_snapshots

Doesn't immediately fix anything as the callers don't use the return
value, but they will be fixed next.

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

541dc0d4 09/03/2011 01:45 pm Stefan Weil

Use new macro QEMU_PACKED for packed structures

Most changes were made using these commands:

git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'
git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'...

6cbc3031 08/23/2011 03:15 pm Philipp Hahn

qcow2: Fix DEBUG_* compilation

By introducing BlockDriverState compiling qcow2 with DEBUG_ALLOC and DEBUG_EXT
defined got broken.
Define a BdrvCheckResult structure locally which is now needed as the second
argument.

Also fix qcow2_read_extensions() needing BDRVQcowState....

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

35d7ace7 08/05/2011 03:15 pm Kevin Wolf

qcow2: Fix L1 table size after bdrv_snapshot_goto

When loading an internal snapshot whose L1 table is smaller than the current L1
table, the size of the current L1 would be shrunk to the snapshot's L1 size in
memory, but not on disk. This lead to incorrect refcount updates and eventuelly...

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

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

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

qcow2: Move sync out of qcow2_alloc_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 <>

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

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

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

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

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