History | View | Annotate | Download (50.2 kB)
qcow2: introduce dirty bit
This patch adds an incompatible feature bit to mark images that have notbeen closed cleanly. When a dirty image file is opened a consistencycheck and repair is performed.
Update qemu-iotests 031 and 036 since the extension header size changes...
qcow2: implement lazy refcounts
Lazy refcounts is a performance optimization for qcow2 that postponesrefcount metadata updates and instead marks the image dirty. In thecase of crash or power failure the image will be left in a dirty stateand repaired next time it is opened....
Merge remote-tracking branch 'mjt/mjt-iov2' into staging
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: always operate caches in writeback mode
Writethrough does not need special-casing anymore in the qcow2 caches.The block layer adds flushes after every guest-initiated data write,and these will also flush the qcow2 caches to the OS.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
qcow2: fix autoclear image header update
The autoclear feature bits can be used for qcow2 file format featuresthat are safe to "drop" by old programs that do not understand thefeature. Upon opening the image file unknown autoclear feature bits arecleared and the image file header is rewritten, but this was happening...
qemu-img check -r for repairing images
The QED block driver already provides the functionality to not onlydetect inconsistencies in images, but also fix them. However, thisfunctionality cannot be manually invoked with qemu-img, but thecheck happens only automatically during bdrv_open()....
qcow2: Support for fixing refcount inconsistencies
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
allow qemu_iovec_from_buffer() to specify offset from which to start copying
Similar to qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, int c, size_t bytes);the new prototype is: qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset,...
consolidate qemu_iovec_copy() and qemu_iovec_concat() and make them consistent
qemu_iovec_concat() is currently a wrapper forqemu_iovec_copy(), use the former (with extra"0" arg) in a few places where it is used.
Change skip argument of qemu_iovec_copy() from...
change qemu_iovec_to_buf() to match other to,from_buf functions
It now allows specifying offset within qiov to start from andamount of bytes to copy. Actual implementation is just a callto iov_to_buf().
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
consolidate qemu_iovec_memset{,_skip}() into single function and use existing iov_memset()
This patch combines two functions into one, and replacesthe implementation with already existing iov_memset() fromiov.c.
The new prototype of qemu_iovec_memset():...
qcow2: don't leak buffer for unexpected qcow_version in header
Signed-off-by: Jim Meyering <meyering@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Don't ignore failure to clear autoclear flags
block: push bdrv_change_backing_file error checking up from drivers
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 prealloc
preallocate() will be locked. This is required becauseqcow2_alloc_cluster_link_l2() assumes that it runs under a lock that itcan 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()
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 support
qcow2: Version 3 images
This adds the basic infrastructure to qcow2 to handle version 3 images.It includes code to create v3 images, allow header updates for v3 imagesand checks feature bits.
It still misses support for zero clusters, so this is not a fully...
qcow2: Support reading zero clusters
This adds support for reading zero clusters in version 3 images.
qcow2: Support for feature table header extension
Instead of printing an ugly bitmask, qemu can now print a more helpfulstring even for yet unknown features.
qcow2: Ignore reserved bits in get_cluster_offset
With this change, reading from a qcow2 image ignores all reserved bitsthat are set in an L1 or L2 table entry.
Now get_cluster_offset() assigns *cluster_offset only the offset withoutany other flags. The cluster type is not longer encoded in the offset,...
block: push recursive flushing up from drivers
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Add some tracing
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qcow2: Add error messages in qcow2_truncate
qemu-img resize has some limitations with qcow2, but the user is onlytold that "this image format does not support resize". Quite confusing,so add some more detailed error_report() calls and change "this image...
qcow2: Fix build with DEBUG_EXT enabled
qcow2: Fix offset in qcow2_read_extensions
The spec says that the length of extensions is padded to 8 bytes, notthe offset. Currently this is the same because the header size is amultiple of 8, so this is only about compatibility with future changesto the header size....
qcow2: Reject too large header extensions
Image files that make qemu-img info read several gigabytes into theunknown header extensions list are bad. Just fail opening the imageif an extension claims to be larger than the header extension area.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
qcow2: Update whole header at once
In order to switch the backing file, qcow2 issues multiple writerequests that only changed a part of the image header. Any failure afterthe first one would leave the header in an corrupted state. With thispatch, the whole header is written at once, so we can't fail in the...
qcow2: Keep unknown header extension when rewriting header
If we want header extensions to work as compatible extensions, we can'tdestroy yet unknown header extensions when rewriting the header (e.g.for changing the backing file). Save all unknown header extensions in a...
block/qcow2.c: call qcow2_free_snapshots in the function of qcow2_close
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 staging
coroutine: add qemu_co_queue_restart_all()
It's common to wake up all waiting coroutines. Introduce theqemu_co_queue_restart_all() function to do this instead of looping overqemu_co_queue_next() in every caller.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: convert qcow2, qcow2, and vmdk to .bdrv_co_is_allocated()
The qcow2, qcow, and vmdk block drivers are based on coroutines. They have acoroutine mutex which protects internal state. We can convert the.bdrv_is_allocated() function to .bdrv_co_is_allocated() by holding the mutex...
block: Add coroutine_fn marker to coroutine functions
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>
qcow2: Return real error code in qcow2_read_snapshots
fix spelling in block sub directory
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)
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 andtherefore immutable.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: Rename bdrv_co_flush to bdrv_co_flush_to_disk
There are two different types of flush that you can do: Flushing one level upto the OS (i.e. writing data to the host page cache) or flushing it all the waydown to the disk. The existing functions flush to the disk, reflect this in the...
block: Introduce bdrv_co_flush_to_os
qcow2 has a writeback metadata cache, so flushing a qcow2 image actuallyconsists of writing back that cache to the protocol and only then flushes theprotocol in order to get everything stable on disk.
This introduces a separate bdrv_co_flush_to_os to reflect the split....
block: fix qcow2_co_flush deadlock
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 flush to co_flush
Since coroutine operation is now mandatory, convert all bdrv_flushimplementations to coroutines. For qcow2, this means taking the lock.Other implementations are simpler and just forward bdrv_flush to theunderlying protocol, so they can avoid the lock....
block: change discard to co_discard
Since coroutine operation is now mandatory, convert both bdrv_discardimplementations to coroutines. For qcow2, this means taking the lockaround the operation. raw-posix remains synchronous.
The bdrv_discard callback is then unused and can be eliminated....
block: drop redundant bdrv_flush implementation
Block drivers now only need to provide either of .bdrv_co_flush,.bdrv_aio_flush() or for legacy drivers .bdrv_flush(). Removethe redundant .bdrv_flush() implementations.
[Paolo Bonzini: change raw driver to bdrv_co_flush]...
qcow2: Fix bdrv_write_compressed error handling
If during allocation of compressed clusters the cluster was already allocateduncompressed, fail and properly release the l2_table (the latter avoids afailed assertion).
While at it, make it return some real error numbers instead of -1....
qcow2: align cluster_data to block to improve performance using O_DIRECT
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Properly initialise QcowL2Meta
Dependency list pointers filled with random garbage from the stack aren't agood idea.
qcow2: Fix error cases to run depedent requests
Requests depending on a failed request would end up waiting forever. This fixesthe error path to continue dependent requests even when the request has failed.
qcow2: remove memory leak
qcow/qcow2: Allocate QCowAIOCB structure using stack
instead of calling qemi_aio_get use stack
qcow2: Removed unused AIOCB fields
qcow2: removed cur_nr_sectors field in QCowAIOCB
qcow2: remove l2meta from QCowAIOCB
qcow2: remove cluster_offset from QCowAIOCB
qcow2: remove common from QCowAIOCB
qcow2: reindent and use while before the big jump
prepare to remove read/write callbacks
qcow2: Removed QCowAIOCB entirely
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.
qcow2: Use coroutines
Strip trailing '\n' from error_report()'s first argument
error_report() prepends location, and appends a newline. The messageconstructed from the arguments should not contain a newline. Fix theobvious offenders.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
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 processingin a BH to avoid this situation.
qemu-img create: Fix displayed default cluster size
When not specifying a cluster size on the command line, qemu-img printeda 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...
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 alsospecify BDRV_O_CACHE_WB to give them writeback semantics.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
qcow2: Report error for version > 2
The qcow2 driver is now declared responsible for any QCOW image that hasversion 2 or greater (before this, version 3 would be detected as raw).
For everything newer than version 2, an error is reported.
QCOW2: bug fix - read base image beyond its size
This patch fixes the following bug in QCOW2. For a QCOW2 image that is largerthan its base image, when handling a read request straddling over the end of thebase image, the QCOW2 driver attempts to read beyond the end of the base image...
qcow2: Fix error handling for immediate backing file read failure
Requests could return success even though they failed when bdrv_aio_readvreturned NULL for a backing file read.
Reported-by: Chunqiang Tang <ctang@us.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Fix error handling for reading compressed clusters
When reading a compressed cluster failed, qcow2 falsely returned success.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>
qcow2: Really use cache=unsafe for image creation
For cache=unsafe we also need to set BDRV_O_CACHE_WB, otherwise we have somestrange unsafe writethrough mode.
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, butthe space can be reused by future writes to the image.
qcow2: Use QcowCache
Use the new functions of qcow2-cache.c for everything that works on refcountblock and L2 tables.
Add proper -errno error return values to qcow2_open()
In addition this adds missing braces to the function to be consistentwith the coding style.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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.
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.
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....
qcow2: Simplify image creation
Instead of doing lots of magic for setting up initial refcount blocks and stuffcreate a minimal (inconsistent) image, open it and initialize the rest withregular qcow2 functions.
This is a complete rewrite of the image creation function. The old...
qcow2: Remove old image creation function
They have been #ifdef'd out by the previous patch.
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: Avoid bounce buffers for AIO write requests
qcow2 used to use bounce buffers for any AIO requests. This does not only implyunnecessary copying, but also unbounded allocations which should be avoided.
This patch removes bounce buffers from the normal AIO write path. Encrypted...
qcow2: Avoid bounce buffers for AIO read requests
This patch removes bounce buffers from the normal AIO read path, and constrains...
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: Fix error handling during metadata preallocation
People were wondering why qemu-img check failed after they tried to preallocatea large qcow2 file and ran out of disk space.
qcow2: Use bdrv_(p)write_sync for metadata writes
Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash.
qcow2: Allow qcow2_get_cluster_offset to return errors
qcow2_get_cluster_offset() looks up a given virtual disk offset and returns theoffset of the corresponding cluster in the image file. Errors (e.g. L2 tablecan't be read) are currenctly indicated by a return value of 0, which is...
Fix %lld or %llx printf format use
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
block: Avoid unchecked casts for AIOCBs
Use container_of for one direction and &acb->common for the other one.
qcow2: Remove static forward declaration
OpenBSDs gcc is said to generate warnings for this declaration, so don'treference bdrv_qcow2 directly, but look it up using bdrv_find_format.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Revert "Fix OpenBSD build"
This reverts commit 20d97356c9df6d68fbd37d6334fdb7063f24eab6.The BlockDriver definition should stay at the end of source files.
Conflicts:
block/qcow2.c
qcow2: Implement bdrv_truncate() for growing images
This patch adds the ability to grow qcow2 images in-place usingbdrv_truncate(). This enables qemu-img resize command support forqcow2.
Snapshots are not supported and bdrv_truncate() will return -ENOTSUP....
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...
Fix OpenBSD build
GCC 3.3.5 generates warnings for static forward declarations of data, sorearrange code to use static forward declarations of functions instead.
qcow2: Use QLIST_FOREACH_SAFE macro
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Trigger blkdebug events
This adds blkdebug events to qcow2 to allow injecting I/O errors in specificplaces.
qcow2: Fix creation of large images
qcow_create2 assumes that the new image will only need one cluster for itsrefcount table initially. Obviously that's not true any more when the image isbig enough (exact value depends on the cluster size).
This patch calculates the refcount table size dynamically....
Replace calls of old bdrv_open
What is known today as bdrv_open2 becomes the new bdrv_open. All remainingcallers of the old function are converted to the new one. In some places theyeven know the right format, so they should have used bdrv_open2 from the...
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 ofrequests that are in flight. If we don't do it, the next time the same AIOCB isused for a cluster allocation it will create a loop in the list and qemu will...
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 <kwolf@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
qcow2: return errno instead of -1
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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 anerror has occured, we can't preallocate the image (it's likely broken)....
qcow2: rename two QCowAIOCB members
The n member is not very descriptive and very hard to grep, rename it tocur_nr_sectors to better indicate what it is used for. Also renamenb_sectors to remaining_sectors as that is what it is used for.