History | View | Annotate | Download (38.1 kB)
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qcow2: remove unused qcow2_create_refcount_update function
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: use always stderr for debugging
let all DEBUG_ALLOC2 printf goes to stderr
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: Use Qcow2Cache in writeback mode during loadvm/savevm
In snapshotting there is no guest involved, so we can safely use a writebackmode and do the flushes in the right place (i.e. at the very end). Thisimproves the time that creating/restoring an internal snapshot takes with an...
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 <kwolf@redhat.com>
Fix typos in comments and code (occured -> occurred and related)
The code changed here is an unused data type name (evt_flush_occurred).
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qcow2-refcount: remove write-only variables
Variables l2_modified and l2_size are not really used, remove them.Spotted by GCC 4.6.0: CC block/qcow2-refcount.o/src/qemu/block/qcow2-refcount.c: In function 'qcow2_update_snapshot_refcount':/src/qemu/block/qcow2-refcount.c:708:37: error: variable 'l2_modified' set but not used [-Werror=unused-but-set-variable]...
qcow2: Use QcowCache
Use the new functions of qcow2-cache.c for everything that works on refcountblock and L2 tables.
qcow2: Invalidate cache after failed read
The cache content may be destroyed after a failed read, better not use it anymore.
block: avoid a write only variable
Compiling with GCC 4.6.0 20100925 produced a warning:/src/qemu/block/qcow2-refcount.c: In function 'update_refcount':/src/qemu/block/qcow2-refcount.c:552:13: error: variable 'dummy' set but not used [-Werror=unused-but-set-variable]...
qcow2: Move sync out of write_refcount_block_entries
qcow2: Move sync out of update_refcount
Note that the flush is omitted intentionally in qcow2_free_clusters. Ifanything, we can leak clusters here if we lose the writes.
qcow2: Move sync out of qcow2_alloc_clusters
qcow2/vdi: Change check to distinguish error cases
This distinguishes between harmless leaks and real corruption. Hopefully usersbetter understand what qemu-img check wants to tell them.
qcow2: Use bdrv_(p)write_sync for metadata writes
Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.
qcow2: Fix qemu-img check segfault on corrupted images
With corrupted images, we can easily get an cluster index that exceeds thearray size of the temporary refcount table.
qcow2: Don't try to check tables that couldn't be loaded
Trying to check them leads to a second error message which is more confusingthan helpful:
Can't get refcount for cluster 0: Invalid argument ERROR cluster 0 refcount=-22 reference=1
qcow2: Allow get_refcount to return errors
get_refcount might need to load a refcount block from disk, so errors mayhappen. Return the error code instead of assuming a refcount of 1 and changethe callers to respect error return values.
qcow2: Allow alloc_clusters_noref to return errors
Currently it would consider blocks for which get_refcount fails used. However,it's unlikely that get_refcount would succeed for the next cluster, so it's notreally helpful. Return an error instead.
qcow2: Return real error code in load_refcount_block
This fixes load_refcount_block which completely ignored the return value ofwrite_refcount_block and always returned -EIO for bdrv_pwrite failure.
qcow2: Fix corruption after error in update_refcount
After it is done with updating refcounts in the cache, update_refcount writesall changed entries to disk. If a refcount block allocation fails, however,there was no change yet and therefore first_index = last_index = -1. Don't...
qcow2: Fix corruption after refblock allocation
Refblock allocation code needs to take into consideration that update_refcountwill load a different refcount block into the cache, so it must initialize thecache for a new refcount block only afterwards. Not doing this means that not...
qcow2: Return right error code in write_refcount_block_entries
write_refcount_block_entries used to return -EIO for any errors. Change this toreturn the real error code.
qcow2: Remove abort on free_clusters failure
While it's true that during regular operation free_clusters failure would be abug, an I/O error can always happen. There's no need to kill the VM, the worstthing that can happen (and it will) is that we leak some clusters....
qcow2: Avoid shadowing variable in alloc_clusters_noref()
The i loop iterator is shadowed by the next free cluster index. Bothusing the variable name 'i' makes the code harder to read.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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: Trigger blkdebug events
This adds blkdebug events to qcow2 to allow injecting I/O errors in specificplaces.
qcow2: Factor next_refcount_table_size out
When the refcount table grows, it doesn't only grow by one entry but reservessome space for future refcount blocks. The algorithm to calculate the number ofentries stays the same with the fixes, so factor it out before replacing the...
qcow2: Rewrite alloc_refcount_block/grow_refcount_table
The current implementation of alloc_refcount_block and grow_refcount_table hasfundamental problems regarding error handling. There are some places where anI/O error means that the image is going to be corrupted. I have found that the...
qcow2: More checks for qemu-img check
Implement some more refcount block related checks
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Fix error handling in grow_refcount_table
Return the appropriate error code instead of -EIO.
qcow2: Improve error handling in update_refcount
If update_refcount fails, try to undo any changes made so far to avoidinconsistencies in the image file.
qcow2: Allow updating no refcounts
There's absolutely no problem with updating the refcounts of 0 clusters.At least snapshot code is doing this and would fail once the result ofupdate_refcount isn't ignored any more.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
qcow2: Don't ignore update_refcount return value
update_refcount can return errors that need to be handled by the callers.
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.
qcow2-refcount: remove dead assignment
clang-analyzer points out a redundant assignment.
Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Fix some more qemu_malloc fallout
Oh joy...
qcow2: Fix grow_refcount_table error handling
In case of failure, we haven't increased the refcount for the newly allocatedcluster yet. Therefore we must not free the cluster or its refcount will becomenegative (and endless recursion is possible).
qcow2: Increase maximum cluster size to 2 MB
This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128kclusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bittruncation and wraparound of signed integers. Therefore some variables need to...
Fix most warnings (errors with -Werror) when debugging is enabled
I used the following command to enable debugging:perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * /* *//*
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
qcow2: Fix L1 table memory allocation
Contrary to what one could expect, the size of L1 tables is not clusteraligned. 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...
qcow2: Cache refcount blocks during snapshot creation
The really time consuming part of snapshotting is to adjust the reference countof all clusters. Currently after each adjusted cluster the refcount block iswritten to disk.
Don't write each single byte immediately to disk but cache all writes to the...
update_refcount: Write complete sectors
When updating the refcount blocks in update_refcount(), write complete sectorsinstead of updating single entries.
qcow2: Split out refcount handling
qcow2-refcount.c contains all functions which are related to clusterallocation and management in the image file. A large part of this is thereference counting of these clusters.
Also a header file qcow2.h is introduced which will contain the interface of...
qcow2: Split out guest cluster functions
qcow2-cluster.c contains all functions related to the management of guestclusters, i.e. what the guest sees on its virtual disk. This code is aboutmapping these guest clusters to host clusters in the image file using the...
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...