History | View | Annotate | Download (37.2 kB)
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
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.
Ask for read-write permissions when opening files
Found some places that seems needs this explicitly, now thatread-write is not the default.
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block/qcow2.c: fix warnings with _FORTIFY_SOURCE
CC block/qcow2.occ1: warnings being treated as errorsblock/qcow2.c: In function 'qcow_create2':block/qcow2.c:829: error: ignoring return value of 'write', declared with attribute warn_unused_resultblock/qcow2.c:838: error: ignoring return value of 'write', declared with attribute warn_unused_result...
qcow2: Fix error handling in qcow_save_vmstate
Don't assume success but pass the bdrv_pwrite return value on.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Return 0/-errno in qcow2_alloc_cluster_offset
Returning 0/-errno allows it to distingush different errors classes. Thecluster offset of newly allocated clusters is now returned in the QCowL2Metastruct.
block: Add bdrv_change_backing_file
Introduce the functions needed to change the backing file of an image. Thefunction is implemented for qcow2.
qcow/qcow2: implement bdrv_aio_flush
Now that we do not have to flush the backing device anymore implementingthe bdrv_aio_flush method for image formats is trivial.
[hch: forward ported to qemu mainline from a product tree]
qcow2: Store exact backing format length
Currently qcow2 unnecessarily rounds up the length of the backing format stringto the next multiple of 8. At the same time, the array in BlockDriverState canonly hold 15 characters, so in effect backing formats with 9 characters or more...
qcow2: Allow qcow2 disk images with size zero
Images with disk size 0 may be used forVM snapshots, but not to save normal block data.
It is possible to create such images usingqemu-img, but opening them later fails.
So even "qemu-img info image.qcow2" is not...
Revert "qcow2: Bring synchronous read/write back to life"
It was merely a workaround and the real fix is done now.This reverts commit ef845c3bf421290153154635dc18eaa677cecb43.
qcow2: Bring synchronous read/write back to life
When the synchronous read and write functions were dropped, they were replacedby generic emulation functions. Unfortunately, these emulation functions don'tprovide the same semantics as the original functions did....
Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there aresome additions and it's not entirely compatible. Because of that, there havebeen conflicts with system headers on BSD systems. Some hacks have beenintroduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...
qcow2: Fix metadata preallocation
The wrong version of the preallocation patch has been applied, so this is theremaining diff.
We can't use truncate to grow the image file to the right size because we don'tknow if metadata has been written after the last data cluster. In this case...
qcow2: Order concurrent AIO requests on the same unallocated cluster
When two AIO requests write to the same cluster, and this cluster isunallocated, currently both requests allocate a new cluster and the second onemerges the first one when it is completed. This means an cluster allocation, a...
Fix gcc 3 warning about uninitialized variable
If nb_sectors is 0, cluster_offset will not be initialized.
qcow2: Metadata preallocation
This introduces a qemu-img create option for qcow2 which allows the metadata tobe preallocated, i.e. clusters are reserved in the refcount table and L1/L2tables, but no data is written to them. Metadata is quite small, so this...
replace bdrv_{get, put}_buffer with bdrv_{load, save}_vmstate
The VM state offset is a concept internal to the image format. Replacethe old bdrv_{get,put}_buffer method that require an index into theimage file that is constructed from the VM state offset and an offset...
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: Make cache=writethrough default
The performance of qcow2 has improved meanwhile, so we don't need tospecial-case it any more. Switch the default to write-through cachinglike all other block drivers.
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: Change default cluster size to 64k
Larger cluster sizes mean less metadata. This has been discussion a few times,let's do it now. This turns 64k clusters on by default for new images.
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: 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...
qemu-img: Print available options with -o ?
This patch adds a small help text to each of the options in the block driverswhich can be displayed by using qemu-img create -f fmt -o ?
fully split aio_pool from BlockDriver
Now that we have a separate aio pool structure we can remove thoseaio pool details from BlockDriver.
Every driver supporting AIO now needs to declare a static AIOPoolwith the aiocb size and the cancellation method. This cleans up the...
qcow2: Update multiple refcounts at once
Don't write each single changed refcount block entry to the disk after it iswritten, but update all entries of the block and write all of them at once.
qcow2: Refactor update_refcount
This is a preparation patch with no functional changes. It moves the allocationof new refcounts block to a new function and makes update_cluster_refcount (forone cluster) call update_refcount (for multiple clusters) instead the other way...
qcow/qcow2: Drop synchronous qcow_write()
There is only one (internal) user left and it can be switched to the normalemulation provided in block.c
qcow2: Allow different cluster sizes
Add an option to specify the cluster size of a newly created qcow2 image.Default is 4k which is the same value that was hard-coded before.
Convert all block drivers to new bdrv_create
Now we can make use of the newly introduced option structures. Instead ofhaving bdrv_create carry more and more parameters (which are format specific inmost cases), just pass a option structure as defined by the driver itself....
Do not attempt to allocate sn_tab when there are no snapshots
This was caught by a7d27b536ffc0773028a90f14580552c0c3ddb2a whichaborted on this attempt, thanks to Alex Ivanov for report.
Signed-off-by: malc <av1474@comtv.ru>
Move block drivers into their own directory