block/curl: Handle failed reads gracefully.
Current behaviour if a read fails is for the acb to not get finished.This causes an infinite loop in bdrv_read_em (block.c). The read failurenever gets reported to the guest and if the error condition clears, the...
qcow/qcow2: Allocate QCowAIOCB structure using stack
instead of calling qemi_aio_get use stack
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow: QCowAIOCB field cleanup
remove unused field from this structure and put some of them in qcow_aio_read_cb and qcow_aio_write_cb
qcow: move some blocks of code to avoid useless variable initialization
qcow: Remove QCowAIOCB
Embed qcow_aio_read_cb into qcow_co_readv and qcow_aio_write_cb into qcow_co_writev
qcow: remove old #undefined code
qcow2: Removed unused AIOCB fields
qcow2: removed cur_nr_sectors field in QCowAIOCB
qcow2: remove l2meta from QCowAIOCB
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....
qcow2: fix typo in documentation for qcow2_get_cluster_offset()
Documentation states the num is measured in clusters, but itsactually measured in sectors
Signed-off-by: Devin Nakamura <devin122@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow: initialize coroutine mutex
commit 52b8eb60132b27ad53476490e9d7579003390cfa added a mutex,but never initialized it. This caused a segfault.
Reported-by: Alexander Graf <agraf@suse.de>Signed-off-by: Scott Wood <scottwood@freescale.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
w32: Fix qemu_ftruncate64
SetFilePointer returns INVALID_SET_FILE_POINTER when it fails.In addition, GetLastError must be checked.
The first call of SetFilePointer did not use INVALID_SET_FILE_POINTER,the second call used wrong error handling.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
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: Fix L1 table size after bdrv_snapshot_goto
When loading an internal snapshot whose L1 table is smaller than the current L1table, the size of the current L1 would be shrunk to the snapshot's L1 size inmemory, but not on disk. This lead to incorrect refcount updates and eventuelly...
qcow2: Use coroutines
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow: Use coroutines
The old qcow format is another user of the AsyncContext infrastructure.Converting it to coroutines (and therefore CoMutexes) allows to removeAsyncContexts.
async: Remove AsyncContext
The purpose of AsyncContexts was to protect qcow and qcow2 against reentrancyduring an emulated bdrv_read/write (which includes a qemu_aio_wait() call andcan run AIO callbacks of different requests if it weren't for AsyncContexts)....
raw-posix: Typo fix
raw-posix: Always check paio_init result
block/raw-win32: Drop disabled code for removable host devices
It's been disabled since the start (commit 19cb3738, Aug 2006), andhas been untouched except for spelling fixes and such. I don't feellike dragging it along any further.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
block: Make BlockDriver method bdrv_set_locked() return void
The only caller is bdrv_set_locked(), and it ignores the value.
Callees always return 0, except for FreeBSD's cdrom_set_locked(),which returns -ENOTSUP when the device is in a terminally wedged...
block: Make BlockDriver method bdrv_eject() return void
Callees always return 0, except for FreeBSD's cdrom_eject(), whichreturns -ENOTSUP when the device is in a terminally wedged state.
The only caller is bdrv_eject(), and it maps -ENOTSUP to 0 since...
block/vpc.c: Detect too-large vpc file
VHD files technically can be up to 2Tb, but virtual pc is limitedto 127G. Currently qemu-img refused to create vpc files > 127G,but it is failing to return error when converting from a non-vpcVHD file which is >127G. It returns success, but creates a truncated...
Wrap recv to avoid warnings
Avoid warnings like these by wrapping recv(): CC slirp/ip_icmp.o/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror]...
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...
block: add bdrv_get_allocated_file_size() operation
qemu-img.c wants to count allocated file size of image. Previously itcounts a single bs->file by 'stat' or Window API. As VMDK introducesmultiple file support, the operation becomes format specific with...
VMDK: move 'static' cid_update flag to bs field
Cid_update is the flag for updating CID on first write after opening theimage. This should be per image open rather than per program life cycle,so change it from static var of vmdk_write to a field in BDRVVmdkState....
VMDK: change get_cluster_offset return type
The return type of get_cluster_offset was an offset that use 0 to denote'not allocated', this will be no longer true for flat extents, as we seeflat extent file as a single huge cluster whose offset is 0 and length...
VMDK: open/read/write for monolithicFlat image
Parse vmdk decriptor file and open mono flat image.Read/write the flat extent.
Signed-off-by: Fam Zheng <famcool@gmail.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
VMDK: create different subformats
Add create option 'format', with enums: monolithicSparse monolithicFlat twoGbMaxExtentSparse twoGbMaxExtentFlatEach creates a subformat image file. The default is monolithicSparse.
Signed-off-by: Fam Zheng <famcool@gmail.com>...
VMDK: fix coding style
Conform coding style in vmdk.c to pass scripts/checkpatch.pl checks.
VMDK: bugfix, align offset to cluster in get_whole_cluster
In get_whole_cluster, the offset is not aligned to cluster when readingfrom backing_hd. When the first write to child is not at the clusterboundary, wrong address data from parent is copied to child....
VMDK: probe for monolithicFlat images
Probe as the same behavior as VMware does.Recognize image as monolithicFlat descriptor file when the file is textand the first effective line (not '#' leaded comment or space line) iseither 'version=1' or 'version=2'. No space or upper case charactors...
VMDK: separate vmdk_open by format version
VMDK: add field BDRVVmdkState.desc_offset
There are several occurrence of magic number 0x200 as the descriptoroffset within mono sparse image file. This is not the case for imageswith separate descriptor file. So a field is added to BDRVVmdkState tohold the correct value....
VMDK: flush multiple extents
Flush all the file that referenced by the image.
VMDK: introduce VmdkExtent
Introduced VmdkExtent array into BDRVVmdkState, enable holding multipleimage extents for multiple file image support.
sheepdog: add full data preallocation support
This introduces qemu-img create option for sheepdog which allows thedata to be fully preallocated (note that sheepdog always preallocatesmetadata).
The option is disabled by default and you need to enable it like the...
block/raw-posix: Linux compat-ioctl warning workaround
On Linux x86_64 host with 32bit userspace, runningqemu or even just "qemu-img create -f qcow2 some.img 1G" causes a kernel warning:
ioctl32(qemu-img:5296): Unknown cmd fd(3) cmd(00005326){t:'S';sz:0} arg(7fffffff) on some.img...
sheepdog: qemu_bh_new() can't return null pointer, drop check
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
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.
qcow2: Fix in-flight list after qcow2_cache_put failure
If qcow2_cache_put returns an error during cluster allocation and theallocation fails, it must be removed from the list of in-flight allocations.Otherwise we'd get a loop in the list when the ACB is used for the next...
vdi: Avoid direct AIO callback
bdrv_aio_* must not call the callback before returning to its caller. In vdi,this could happen in some error cases. This starts the real requests processingin a BH to avoid this situation.
qcow: Avoid direct AIO callback
bdrv_aio_* must not call the callback before returning to its caller. In qcow,this could happen in some error cases. This starts the real requests processingin a BH to avoid this situation.
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.
block/rbd: Remove unused local variable
Variable 'snap' is assigned a value that is never used.Remove snap and the related code.
Cc: Christian Brunner <chb@muc.de>Cc: Josh Durgin <josh.durgin@dreamhost.com>Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
rbd: allow configuration of rados from the rbd filename
The new format is rbd:pool/image[@snapshot][:option1=value1[:option2=value2...]]Each option is used to configure rados, and may be any Ceph option, or "conf".The "conf" option specifies a Ceph configuration file to read....
rbd: check return values when scheduling aio
If scheduling fails, the number of outstanding I/Os must be correct,or there will be a hang when waiting for everything to be flushed.
Reviewed-by: Christian Brunner <chb@muc.de>Reported-by: Stefan Hajnoczi <stefanha@gmail.com>...
rbd: Add bdrv_truncate implementation
Reviewed-by: Christian Brunner <chb@muc.de>Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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.
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/raw-posix: get right partition size
use the correct way to get the size of a disk device or partition
From: Adam Hamsik <haad@netbsd.org>Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
rbd: use the higher level librbd instead of just librados
librbd stacks on top of librados to provide accessto rbd images.
Using librbd simplifies the qemu code, and allowsqemu to use new versions of the rbd formatwith few (if any) changes.
Reviewed-by: Christian Brunner <chb@muc.de>...
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>...
vmdk: fix endianness bugs
The vmdk code is sloppy when handling the header descriptor duringcreation of an image. Fix all header accesses in the create path toeither store native endianness or convert it when appropriate.
Reported-by: Yury Tsarev <ytsarev@novell.com>...
block/raw-posix: use a character device if a block device is given
On NetBSD a userland process is better with the character deviceinterface. In addition, a block device can't be opened twice; if a Xenbackend opens it, qemu can't and vice-versa.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>...
Fix compilation warning due to missing header for sigaction (followup)
This patch removes all references to signal.h when qemu-common.h is includedas they become redundant.
Signed-off-by: Alexandre Raymond <cerbere@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qed: support for growing images
The .bdrv_truncate() operation resizes images and growing is easy toimplement in QED. Simply check that the new size is valid and thenupdate the image_size header field to reflect the new size.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
qed: Periodically flush and clear need check bit
One strategy to limit the startup delay of consistency check whenopening image files is to ensure that the file is marked dirty for aslittle time as possible.
QED currently marks the image dirty when the first allocating write...
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>
Fix typo in code and comments
Replace writeable -> writable
NBD: Avoid leaking a couple of strings when the NBD device is closed
Signed-off-by: Nick Thomas <nick@bytemark.co.uk>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qed: Fix consistency check on 32-bit hosts
The qed_bytes_to_clusters() function is normally used with size_tlengths. Consistency check used it with file size length and thereforefailed on 32-bit hosts when the image file is 4 GB or more.
Make qed_bytes_to_clusters() explicitly 64-bit and update consistency...
vpc.c: Use get_option_parameter() does the search
Use get_option_parameter() to instead of duplicating the loop, anduse BDRV_SECTOR_SIZE to instead of 512
Signed-off-by: Mitnick Lyu <mitnick.lyu@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qed: Add support for zero clusters
Zero clusters are similar to unallocated clusters except instead of readingtheir value from a backing file when one is available, the cluster is alwaysread as zero.
This implements read support only. At this stage, QED will never write a...
NBD device: Separate out parsing configuration and opening sockets.
We also change the way the file parameter is parsed so IPv6 IPaddresses can be used, e.g.: "drive=nbd:[::1]:5000"
Fix trivial "endianness bugs"
Replace endianess -> endianness.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
get rid of private bitmap functions in block/sheepdog.c, use generic ones
qemu now has generic bitmap functions,so don't redefine them in sheepdog.c,use common header instead. A small cleanup.
Here's only one function which is actuallyused in sheepdog and gets replaced with...
block/vdi: Don't ignore immediate read/write failures
This patch is similar to 171e3d6b9997c98a97d0c525867f7cd9b640caddwhich fixed qcow2:
Returning -EIO is far from optimal, but at least it's an error code.
Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
block/qcow: Don't ignore immediate read/write and other failures
In addition to read/write failures, -EIO is also returned when...
qcow2: Fix order in L2 table COW
When copying L2 tables (this happens only with internal snapshots), the orderwasn't completely safe, so that after a crash you could end up with a L2 tablethat has too low refcount, possibly leading to corruption in the long run....
qed: Report error for unsupported features
Instead of just returning -ENOTSUP, generate a more detailed error.
Unfortunately we don't have a helpful text for features that we don't know yet,so just print the feature mask. It might be useful at least if someone asks for...
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>
block/vdi: Fix wrong size in conditionally used memset, memcmp
Error report from cppcheck:block/vdi.c:122: error: Using sizeof for array given as function argument returns the size of pointer.block/vdi.c:128: error: Using sizeof for array given as function argument returns the size of pointer....
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-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]...
Reorganize struct Qcow2Cache for better struct packing
Move size after the two pointers in struct Qcow2Cache to get betterpacking of struct elements on 64 bit architectures.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
sheepdog: support creating images on remote hosts
This patch parses the input filename in sd_create(), and enables usspecifying a target server to create sheepdog images.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Signed-off-by: Kevin Wolf <kwolf@redhat.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.
qed: Images with backing file do not require QED_F_NEED_CHECK
The consistency check on open is necessary in order to fix inconsistenttable offsets left as a result of a crash mid-operation. Images with abacking file actually flush before updating table offsets and are...
raw-win32: Fix bdrv_flush return value
qed: Refuse to create images on block devices
QED relies on the underlying filesystem to extend the file and maintainits size. Check that images are not created on a block device.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qcow2: Use QcowCache
Use the new functions of qcow2-cache.c for everything that works on refcountblock and L2 tables.
qcow2: Batch flushes for COW
qcow2 calls bdrv_flush() after performing COW in order to ensure that theL2 table change is never written before the copy is safe on disk. Now that theL2 table is cached, we can wait with flushing until we write out the next L2...
qcow2: Add QcowCache
This adds some new cache functions to qcow2 which can be used for cachingrefcount blocks and L2 tables. When used with cache=writethrough they worklike the old caching code which is spread all over qcow2, so for this case wehave merely a cleanup....
qcow2: fix unaligned access
cpu_to_be64w() is called with an obviously non-aligned pointer. Usecpu_to_be64wu() instead. It fixes unaligned accesses errors on IA64hosts.
Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>...
vpc: fix a file descriptor leak
Fix a file descriptor leak, reported by cppcheck:[/src/qemu/block/vpc.c:524]: (error) Resource leak: fd
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
vvfat: fix a file descriptor leak
Fix a file descriptor leak, reported by cppcheck:[/src/qemu/block/vvfat.c:759]: (error) Resource leak: dir
Add proper -errno error return values to qcow2_open()
In addition this adds missing braces to the function to be consistentwith the coding style.
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.
qed: Add QEMU Enhanced Disk image format
This patch introduces the qed on-disk layout and implements imagecreation. Later patches add read/write and other functionality.
qed: Table, L2 cache, and cluster functions
This patch adds code to look up data cluster offsets in the image viathe L1/L2 tables. The L2 tables are writethrough cached in memory forperformance (each read/write requires a lookup so it is essential tocache the tables)....
qed: Read/write support
This patch implements the read/write state machine. Operations arefully asynchronous and multiple operations may be active at any time.
Allocating writes lock tables to ensure metadata updates do notinterfere with each other. If two allocating writes need to update the...
qed: Consistency check support
This patch adds support for the qemu-img check command. It alsointroduces a dirty bit in the qed header to mark modified images asneeding a check. This bit is cleared when the image file is closedcleanly.
If an image file is opened and it has the dirty bit set, a consistency...
raw-posix: add discard support
Add support to discard blocks in a raw image residing on an XFS filesystemby calling the XFS_IOC_UNRESVSP64 ioctl to punch holes. Support for otherhole punching mechanisms can be added when they become available.