History | View | Annotate | Download (18.7 kB)
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 whetherclusters that reach a refcount of 0 should be discarded in the image...
qcow2: flush refcount cache correctly in qcow2_write_snapshots()
Since qcow2 metadata is cached we need to flush the caches, not just theunderlying file. Use bdrv_flush(bs) instead of bdrv_flush(bs->file).
Also add the error return path when bdrv_flush() fails and move the...
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() andqcow2_snapshot_delete() do not.
Solve this by moving the bdrv_flush() into...
block: move include files to include/block/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qcow2: fix #ifdef'd qcow2_check_refcounts() callers
The DEBUG_ALLOC qcow2.h macro enables additional consistency checksthroughout the code. This makes it easier to spot corruptions that areintroduced during development. Since consistency check is an expensive...
qcow2: fix the return value -ENOENT -> -EEXIST
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Save disk size in snapshot header
This allows that different snapshots of an image can have differentsizes, which is a requirement for enabling image resizing even withimages that have internal snapshots.
We don't do the actual support for it now, but make sure that the...
qcow2: Allow >4 GB VM state
This is a compatible extension to the snapshot header format that allowssaving a 64 bit VM state size.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Update snapshot table information at once
Failing in the middle wouldn't help with the integrity of the image, sodoing everything in a single request seems better.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qcow2: Cleanups and memleak fix in qcow2_snapshot_create
sn->id_str could be leaked before this. The rest of this patch changescomments, fixes coding style or removes checks that are unnecessary withg_malloc.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
qcow2: Rework qcow2_snapshot_create error handling
Increase refcounts only after allocating a new L1 table has succeeded inorder 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....
qcow2: Return real error in qcow2_snapshot_goto
Besides fixing the return code, this adds some comments that make clearhow the code works and that it potentially breaks images if we fail inthe wrong place. Actually fixing this is left for the next patch....
qcow2: Fix order of refcount updates in qcow2_snapshot_goto
The refcount updates must be moved so that in the worst case we can getcluster leaks, but refcounts may never be too low.
qcow2: Fix order in qcow2_snapshot_delete
First the snapshot must be deleted and only then the refcounts can bedecreased.
qcow2: Fix error path in qcow2_snapshot_load_tmp
If the bdrv_read() of the snapshot's L1 table fails, return the righterror code and make sure that the old L1 table is still loaded and wedon't break the BlockDriverState completely.
qcow2: Return real error code in qcow2_read_snapshots
qcow2: Return real error code in qcow2_write_snapshots
Doesn't immediately fix anything as the callers don't use the returnvalue, but they will be fixed next.
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/'...
qcow2: Fix DEBUG_* compilation
By introducing BlockDriverState compiling qcow2 with DEBUG_ALLOC and DEBUG_EXTdefined got broken.Define a BdrvCheckResult structure locally which is now needed as the secondargument.
Also fix qcow2_read_extensions() needing BDRVQcowState....
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Fix L1 table size after bdrv_snapshot_goto
When loading an internal snapshot whose L1 table is smaller than the current L1table, the size of the current L1 would be shrunk to the snapshot's L1 size inmemory, but not on disk. This lead to incorrect refcount updates and eventuelly...
block/qcow2.c: rename qcow_ functions to qcow2_
It doesn't really make sense for functions in qcow2.c to be namedqcow_ so convert the names to match correctly.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Support exact L1 table growth
The L1 table grow operation includes a size calculation that bumps upthe new L1 table size in order to anticipate the size needs of vmstatedata. This helps reduce the number of times that the L1 table has to begrown when vmstate data is appended....
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....
qcow2: Move sync out of qcow2_alloc_clusters
qcow2: Use bdrv_(p)write_sync for metadata writes
Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.
block: Open the underlying image file in generic code
Format drivers shouldn't need to bother with things like file names, but ratherjust get an open BlockDriverState for the underlying protocol. This patchintroduces this behaviour for bdrv_open implementation. For protocols which...
qcow2: Don't ignore qcow2_alloc_clusters return value
Now that qcow2_alloc_clusters can return error codes, we must handle them inthe callers of qcow2_alloc_clusters.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Fix some more qemu_malloc fallout
Oh joy...
Fix QCOW2 debugging code to compile again
Updated to use C99 comments.
Signed-off-by: Filip Navara <filip.navara@gmail.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Split out snapshot functions
qcow2-snapshot.c contains the code related to snapshotting.
qcow2: Rename global functions
The qcow2 source is now split into several more manageable files. During theconversion quite some functions that were static before needed to be changed tobe global to make the source compile again.
We were lucky enough not to get name conflicts with these additional global...