summaryrefslogtreecommitdiffstats
path: root/block/qcow2.c
Commit message (Collapse)AuthorAgeFilesLines
* qcow2: don't leak buffer for unexpected qcow_version in headerJim Meyering2012-05-251-1/+2
| | | | | Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Don't ignore failure to clear autoclear flagsKevin Wolf2012-05-141-1/+4
| | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: push bdrv_change_backing_file error checking up from driversPaolo Bonzini2012-05-101-5/+0
| | | | | | | | This check applies to all drivers, but QED lacks it. Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: lock on preallocZhi Yong Wu2012-05-071-0/+3
| | | | | | | | | preallocate() will be locked. This is required because qcow2_alloc_cluster_link_l2() assumes that it runs under a lock that it can drop while COW is being performed. Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block/qcow2: Add missing GCC_FMT_ATTR to function report_unsupported()Stefan Weil2012-05-021-1/+2
| | | | | | Cc: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Zero write supportKevin Wolf2012-04-201-0/+21
| | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Support for feature table header extensionKevin Wolf2012-04-201-9/+57
| | | | | | | Instead of printing an ugly bitmask, qemu can now print a more helpful string even for yet unknown features. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Support reading zero clustersKevin Wolf2012-04-201-0/+8
| | | | | | This adds support for reading zero clusters in version 3 images. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Version 3 imagesKevin Wolf2012-04-201-14/+132
| | | | | | | | | | | | | 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 compliant implementation of v3 yet. The default for creating new images stays at v2 for now. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Ignore reserved bits in get_cluster_offsetKevin Wolf2012-04-201-3/+14
| | | | | | | | | | | 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, but a positive return value in case of success. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: push recursive flushing up from driversPaolo Bonzini2012-04-051-6/+0
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Add error messages in qcow2_truncateKevin Wolf2012-03-121-0/+3
| | | | | | | | | | qemu-img resize has some limitations with qcow2, but the user is only told that "this image format does not support resize". Quite confusing, so add some more detailed error_report() calls and change "this image format" into "this image". Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Add some tracingKevin Wolf2012-03-121-0/+9
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Reject too large header extensionsKevin Wolf2012-02-291-0/+5
| | | | | | | | | Image files that make qemu-img info read several gigabytes into the unknown header extensions list are bad. Just fail opening the image if an extension claims to be larger than the header extension area. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Fix offset in qcow2_read_extensionsKevin Wolf2012-02-291-3/+2
| | | | | | | | | | | | | The spec says that the length of extensions is padded to 8 bytes, not the offset. Currently this is the same because the header size is a multiple of 8, so this is only about compatibility with future changes to the header size. While touching it, move the calculation to a common place instead of duplicating it for each header extension type. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Fix build with DEBUG_EXT enabledKevin Wolf2012-02-291-1/+0
| | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Keep unknown header extension when rewriting headerKevin Wolf2012-02-091-2/+42
| | | | | | | | | 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 list of blobs and include them in a new header. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Update whole header at onceKevin Wolf2012-02-091-60/+94
| | | | | | | | | | | | | 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 middle. At the same time, this gives us a reusable functions that updates all fields of the qcow2 header and not only the backing file. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block/qcow2.c: call qcow2_free_snapshots in the function of qcow2_closeLi Zhi Hui2011-12-151-0/+1
| | | | | | Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori2011-12-051-12/+16
|\
| * coroutine: add qemu_co_queue_restart_all()Stefan Hajnoczi2011-12-051-1/+1
| | | | | | | | | | | | | | | | | | It's common to wake up all waiting coroutines. Introduce the qemu_co_queue_restart_all() function to do this instead of looping over qemu_co_queue_next() in every caller. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * block: convert qcow2, qcow2, and vmdk to .bdrv_co_is_allocated()Stefan Hajnoczi2011-12-051-5/+8
| | | | | | | | | | | | | | | | | | | | The qcow2, qcow, and vmdk block drivers are based on coroutines. They have a coroutine mutex which protects internal state. We can convert the .bdrv_is_allocated() function to .bdrv_co_is_allocated() by holding the mutex around the cluster lookup operation. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
| * qcow2: Return real error code in qcow2_read_snapshotsKevin Wolf2011-12-051-2/+3
| | | | | | | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
| * block: Add coroutine_fn marker to coroutine functionsDong Xu Wang2011-12-051-4/+4
| | | | | | | | | | | | | | | | Looks better when reviewing these source files. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | fix spelling in block sub directoryDong Xu Wang2011-12-021-2/+2
|/ | | | | | Cc: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: implement bdrv_invalidate_cache (v2)Anthony Liguori2011-11-211-0/+34
| | | | | | | | 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 <aliguori@us.ibm.com>
* block: Introduce bdrv_co_flush_to_osKevin Wolf2011-11-111-2/+8
| | | | | | | | | | qcow2 has a writeback metadata cache, so flushing a qcow2 image actually consists of writing back that cache to the protocol and only then flushes the protocol in order to get everything stable on disk. This introduces a separate bdrv_co_flush_to_os to reflect the split. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Rename bdrv_co_flush to bdrv_co_flush_to_diskKevin Wolf2011-11-111-3/+3
| | | | | | | | | There are two different types of flush that you can do: Flushing one level up to the OS (i.e. writing data to the host page cache) or flushing it all the way down to the disk. The existing functions flush to the disk, reflect this in the function name. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: fix qcow2_co_flush deadlockDong Xu Wang2011-10-281-0/+2
| | | | | | | If qcow2_cache_flush failed, s->lock will not be unlock. Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: change discard to co_discardPaolo Bonzini2011-10-211-4/+10
| | | | | | | | | | | | Since coroutine operation is now mandatory, convert both bdrv_discard implementations to coroutines. For qcow2, this means taking the lock around the operation. raw-posix remains synchronous. The bdrv_discard callback is then unused and can be eliminated. Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: change flush to co_flushPaolo Bonzini2011-10-211-7/+7
| | | | | | | | | | | | Since coroutine operation is now mandatory, convert all bdrv_flush implementations to coroutines. For qcow2, this means taking the lock. Other implementations are simpler and just forward bdrv_flush to the underlying protocol, so they can avoid the lock. The bdrv_flush callback is then unused and can be eliminated. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Fix bdrv_write_compressed error handlingKevin Wolf2011-10-211-11/+18
| | | | | | | | | | | If during allocation of compressed clusters the cluster was already allocated uncompressed, fail and properly release the l2_table (the latter avoids a failed assertion). While at it, make it return some real error numbers instead of -1. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
* block: drop redundant bdrv_flush implementationStefan Hajnoczi2011-10-211-19/+0
| | | | | | | | | | | | Block drivers now only need to provide either of .bdrv_co_flush, .bdrv_aio_flush() or for legacy drivers .bdrv_flush(). Remove the redundant .bdrv_flush() implementations. [Paolo Bonzini: change raw driver to bdrv_co_flush] Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: align cluster_data to block to improve performance using O_DIRECTFrediano Ziglio2011-09-121-7/+7
| | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Fix error cases to run depedent requestsKevin Wolf2011-09-061-3/+4
| | | | | | | Requests depending on a failed request would end up waiting forever. This fixes the error path to continue dependent requests even when the request has failed. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Properly initialise QcowL2MetaKevin Wolf2011-09-061-2/+3
| | | | | | | Dependency list pointers filled with random garbage from the stack aren't a good idea. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: remove memory leakFrediano Ziglio2011-08-231-0/+2
| | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Removed QCowAIOCB entirelyFrediano Ziglio2011-08-231-127/+80
| | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: reindent and use while before the big jumpFrediano Ziglio2011-08-231-137/+135
| | | | | | | prepare to remove read/write callbacks Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: remove common from QCowAIOCBFrediano Ziglio2011-08-231-4/+4
| | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: remove cluster_offset from QCowAIOCBFrediano Ziglio2011-08-231-11/+11
| | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: remove l2meta from QCowAIOCBFrediano Ziglio2011-08-231-7/+8
| | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: removed cur_nr_sectors field in QCowAIOCBFrediano Ziglio2011-08-231-55/+43
| | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Removed unused AIOCB fieldsFrediano Ziglio2011-08-231-7/+3
| | | | | Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow/qcow2: Allocate QCowAIOCB structure using stackFrediano Ziglio2011-08-231-27/+11
| | | | | | | instead of calling qemi_aio_get use stack Signed-off-by: Frediano Ziglio <freddy77@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qcow2: Fix DEBUG_* compilationPhilipp Hahn2011-08-231-1/+5
| | | | | | | | | | | | 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. Signed-off-by: Philipp Hahn <hahn@univention.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-201-18/+18
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qcow2: Use coroutinesKevin Wolf2011-08-021-154/+86
| | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Strip trailing '\n' from error_report()'s first argumentMarkus Armbruster2011-06-241-1/+1
| | | | | | | | | 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 <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qcow2: Avoid direct AIO callbackKevin Wolf2011-06-141-9/+30
| | | | | | | | 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 <kwolf@redhat.com>
OpenPOWER on IntegriCloud