History | View | Annotate | Download (51.6 kB)
qcow2: make is_allocated return true for zero clusters
Otherwise, live migration of the top layer will miss zero clusters andlet the backing file show through. This also matches what is done in qed.
QCOW2_CLUSTER_ZERO clusters are invalid in v2 image files. Check this...
block: Add options QDict to .bdrv_open()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: Add options QDict to bdrv_open() prototype
It doesn't do anything yet except storing the options QDict in theBlockDriverState.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>...
qcow2: Allow lazy refcounts to be enabled on the command line
qcow2 images now accept a boolean lazy_refcounts options. Use it likethis:
-drive file=test.qcow2,lazy_refcounts=on
If the option is specified on the command line, it overrides the default...
block: Use error code EMEDIUMTYPE for wrong format in some block drivers
This improves error reports for bochs, cow, qcow, qcow2, qed and vmdkwhen a file with the wrong format is selected.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Eric Blake <eblake@redhat.com>...
qcow2: Fix segfault on zero-length write
One of the recent refactoring patches (commit f50f88b9) didn't take careto initialise l2meta properly, so with zero-length writes, which don'teven enter the write loop, qemu just segfaulted.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
qapi: move include files to include/qobject/
block: move include files to include/block/
qcow2: Allocate l2meta dynamically
As soon as delayed COW is introduced, the l2meta struct is needed evenafter completion of the request, so it can't live on the stack.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Drop l2meta.cluster_offset
There's no real reason to have an l2meta for normal requests that don'tallocate anything. Before we can get rid of it, we must return the hostcluster offset in a different way.
qcow2: Allocate l2meta only for cluster allocations
Even for writes to already allocated clusters, an l2meta is allocated,though it stays effectively unused. After this patch, only allocatingrequests still have one. Each l2meta now describes an in-flight request...
qcow2: Enable dirty flag in qcow2_alloc_cluster_link_l2
This is closer to where the dirty flag is really needed, and it avoidshaving checks for special cases related to cluster allocation directlyin the writev loop.
qcow2: Execute run_dependent_requests() without lock
There's no reason for run_dependent_requests() to hold s->lock, and alater patch will require that in fact the lock is not held.
Also, before this patch, run_dependent_requests() not only does what its...
qcow2: Move BLKDBG_EVENT out of the lock
We want to use these events to suspend requests for testing concurrentAIO requests. Suspending requests while they are holding the CoMutex israther boring for this purpose.
qcow2: mark this file's sole strncpy use as justified
Acked-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Jim Meyering <meyering@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: qcow2 image file reopen
These are the stubs for the file reopen drivers for the qcow2 format.
There is currently nothing that needs to be done by the qcow2 driverin reopen.
Signed-off-by: Jeff Cody <jcody@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: mark image clean after repair succeeds
The dirty bit is cleared after image repair succeeds in qcow2_open().Move this into qcow2_check() so that all callers benefit from thisbehavior when fix mode is enabled.
This is necessary so qemu-img check can call .bdrv_check() and mark the...
block: add BLOCK_O_CHECK for qemu-img check
Image formats with a dirty bit, like qed and qcow2, repair dirty imagefiles upon open with BDRV_O_RDWR. Performing automatic repair whenqemu-img check runs is not ideal because the bdrv_open() call repairsthe image before the actual bdrv_check() call from qemu-img.c....
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
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.
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.