block: remove QED .bdrv_make_empty implementation
The QED .bdrv_make_empty() implementation does nothing but return-ENOTSUP, which causes problems in bdrv_commit(). Since the functionstub exists for QED, it is called, which then always returns an error....
block: remove qcow2 .bdrv_make_empty implementation
The QCOW2 .bdrv_make_empty implementation always returns 0 for success,but does not actually do anything.
The proper way to not support an optional driver function stub is tojust not implement it, so let's remove the stub....
block/vmdk: add basic .bdrv_check support
this adds a basic vmdk corruption check. it should detect severetable corruptions and file truncation.
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/vhdx: Error checking fixes
Errors are inadvertently ignored in a few places. Has always beenbroken. Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Reviewed-by: Jeff Cody <jcody@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Merge remote-tracking branch 'bonzini/scsi-next' into staging
qemu-iotests: Test pwritev RMW logic
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Max Reitz <mreitz@redhat.com>
iscsi: Set bs->request_alignment
The iSCSI backend already gets the block size from the READ CAPACITYcommand it sends. Save it so that the generic block layer gets ittoo.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
blkdebug: Make required alignment configurable
The new 'align' option of blkdebug can be used in order to emulatebackends with a required 4k alignment on hosts which only really require512 byte alignment.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
raw: Probe required direct I/O alignment
Add a bs->request_alignment field that contains the requiredoffset/length alignment for I/O requests and fill it in the raw blockdrivers. Use ioctls if possible, else see what alignment it takes forO_DIRECT to succeed....
block: Switch BdrvTrackedRequest to byte granularity
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>
block: Move initialisation of BlockLimits to bdrv_refresh_limits()
This function separates filling the BlockLimits from bdrv_open(), whichallows it to call it from other operations which may change the limits(e.g. modifications to the backing file chain or bdrv_reopen)...
block: Update BlockLimits when they might have changed
When reopening with different flags, or when backing files disappearfrom the chain, the limits may change. Make sure they get updated inthese cases.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>...
block: resize backing image during active layer commit, if needed
If the top image to commit is the active layer, and also larger thanthe base image, then an I/O error will likely be returned duringblock-commit.
For instance, if we have a base image with a virtual size 10G, and a...
qmp: Add QMP query-named-block-nodes to list the named BlockDriverState nodes.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Create authorizations mechanism for external snapshot and resize.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/curl: Implement the libcurl timer callback interface
libcurl versions 7.16.0 and later have a timer callback interface whichmust be implemented in order for libcurl to make forward progress (itwill sometimes rely on being called back on the timeout if there are...
qapi: Add "backing" to BlockStats
Currently there is no way to query BlockStats of the backing chain. Thisadds "backing" field into BlockStats to make it possible.
The comment of "parent" is reworded.
Signed-off-by: Fam Zheng <famz@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>...
qcow2: fix wrong value of L1E_OFFSET_MASK, L2E_OFFSET_MASK and REFT_OFFSET_MASK
Accoring to qcow spec, the offset fields in l1e, l2e and ref table entrystart at bit 9. The offset is cluster offset, and the smallest possiblecluster size is 512 bytes.
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>...
vmdk: Check for overhead when opening
Report an error if file size is even smaller than metadata.
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
sheepdog: fix 'qemu-img map'
It was muted in the previous commit 4bc74be9. Let's revive it since nothingprevents us to do it.
With this patch, following command will work as other formats:
$ qemu-img map sheepdog:image
Cc: qemu-devel@nongnu.orgCc: Kevin Wolf <kwolf@redhat.com>...
drive mirror:fix memory leak
In the function mirror_iteration() > qemu_iovec_init(),it allocates memory for op>qiov.iov, when the write request calls back,but in the function mirror_iteration_done(), it only frees the op,not free the op->qiov.iov, so this causes memory leak....
vmdk: Fix format specific information (create type) for streamOptimized
Previously the field is wrong:
$ ./qemu-img create -f vmdk -o subformat=streamOptimized /tmp/a.vmdk 1G
$ ./qemu-img info /tmp/a.vmdk image: /tmp/a.vmdk file format: vmdk...
blkdebug: Allow command-line file configuration
Introduce the "image" option as an alternative to specifying the imagethrough the filename.
Signed-off-by: Max Reitz <mreitz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blkverify: Allow command-line configuration
Introduce the "test" and "raw" options for specifying images.
blkverify: Don't require protocol filename
If the filename is not prefixed by "blkverify:" inblkverify_parse_filename(), the blkverify driver was not selectedthrough that protocol prefix, but by an explicit command line (or QMP)option (like driver=blkverify)....
blkdebug: Use errp for read_config()
Use an Error variable in the read_config() function.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blkdebug: Don't require sophisticated filename
If the filename is not prefixed by "blkdebug:" inblkdebug_parse_filename(), the blkdebug driver was not selected throughthat protocol prefix, but by an explicit command line option(file.driver=blkdebug or something similar). Contrary to the current...
blkdebug: Always call read_config()
Move the check whether there actually is a config file into theread_config() function.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
blkdebug: Use command-line in read_config()
Use qemu_config_parse_qdict() to parse the command-line options inaddition to the config file.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Allow reference for bdrv_file_open()
Allow specifying a reference to an existing block device (by name) forbdrv_file_open() instead of a filename and/or options.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>...
rbd: switch from pipe to QEMUBH completion notification
rbd callbacks are called from non-QEMU threads. Up until now a pipe wasused to signal completion back to the QEMU iothread.
The pipe writer code handles EAGAIN using select(2). The select(2) API...
block/iscsi: return -ENOMEM if an async call fails immediately
if an async libiscsi call fails directly it can only be dueto an out of memory condition. All other errors are returnedthrough the callback.
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>...
gluster: Convert aio routines into coroutines
Convert the read, write, flush and discard implementations from aio-basedones to coroutine based ones.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>...
gluster: Implement .bdrv_co_write_zeroes for gluster
Support .bdrv_co_write_zeroes() from gluster driver by using GlusterFS APIglfs_zerofill() that off-loads the writing of zeroes to GlusterFS server.
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>...
gluster: Add support for creating zero-filled image
GlusterFS supports creation of zero-filled file on GlusterFS volumeby means of an API called glfs_zerofill(). Use this API from QEMU tocreate an image that is filled with zeroes by using the preallocation...
sheepdog: fix clone operation by 'qemu-img create -b'
We should pass base_inode->vdi_id to base_vdi_id of SheepdogVdiReq so that sheepcan create a clone instead a fresh volume.
This fixes following command:
qemu-create -b sheepdog:base sheepdog:clone...
vmdk: Fix big flat extent IO
Local variable "n" as int64_t avoids overflow with large sector numbercalculation. See test case change for failure case.
block: add .bdrv_reopen_prepare() stub for iscsi
To suppport reopen(), the .bdrv_reopen_prepare() stub must exist.iSCSI does not have anything that needs to be done to support reopen,so we can just implement the _prepare() stub.
Signed-off-by: Jeff Cody <jcody@redhat.com>...
Merge remote branch 'luiz/queue/qmp' into qmpq
Message-id: 1387720926-11421-1-git-send-email-pbonzini@redhat.com...
qemu-option: Remove qemu_opts_create_nofail
This is a boiler-plate _nofail variant of qemu_opts_create. Remove anduse error_abort in call sites.
null/0 arguments needs to be added for the id and fail_if_exists fieldsin affected callsites due to argument inconsistency between the normal and...
mirror: Don't close target
Let reference count manage target and don't call bdrv_close here.
Signed-off-by: Fam Zheng <famz@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
mirror: Move base to MirrorBlockJob
This allows setting the base before entering mirror_run, commit willmake use of it.
block: Add commit_active_start()
commit_active_start is implemented in block/mirror.c, It will create ajob with "commit" type and designated base in block-commit command. Thiswill be used for committing active layer of device.
Sync mode is removed from MirrorBlockJob because there's no proper type...
commit: Support commit active layer
If active is top, it will be mirrored to base, (with block/mirror.ccode), then the image is switched when user completes the block job.
QMP documentation is updated.
Signed-off-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
commit: Remove unused check
We support top == active for commit now, remove the check and add anassertion here.
vmdk: Allow vmdk_create to work with protocol
This improves vmdk_create to use bdrv_* functions to replace qemu_openand other fd functions. The error handling are improved as well. Onedifference is that bdrv_pwrite will round up buffer to sectors, so for...
block/iscsi: Fix compilation for libiscsi 1.4.0 (API change)
Function iscsi_read10_task got additional parameters starting with versionlibiscsi 1.5.0.
libiscsi 1.4.0 is still widely used (Debian wheezy, jessie and other Linuxdistributions currently provide packages for QEMU which use it), so we...
block: vhdx - improve error message, and .bdrv_check implementation
If there is a dirty log file to be replayed in a VHDX image, it isreplayed in .vhdx_open(). However, if the file is opened read-only,then a somewhat cryptic error message results.
This adds a more helpful error message for the user. If an image file...
vmdk: Check VMFS extent line field number
VMFS extent line in description file should be with 4 fields:
RW <size> VMFS "file-name.vmdk"
Check the number explicitly and report error if offset is appended asFLAT, which should be invalid format.
Reported-by: Paolo Bonzini <pbonzini@redhat.com>...
sheepdog: fix dynamic grow for running qcow2 format
When running qcow2 over sheepdog, we might meet following problem
qemu-system-x86_64: shrinking is not supported
And cause IO errors to Guest. This is because we abuse bs->total_sectors, whichis manipulated by generic block layer and race with sheepdog code....
Merge remote-tracking branch 'spice/tags/pull-spice-1' into staging
Collection of little cleanups anf bugfixes.nbd patches in preparation of spice-nbd.
Merge remote-tracking branch 'kwolf/tags/for-anthony' into staging
Block patches
block/iscsi: use a bh to schedule co reentrance
this fixes a potential segfault and performance regression.
If the coroutine is reentered directly in the iscsi_co_generic_cbiscsi_process_{read,write} are interrupted and reentered anytime later. One the one hand this could happen after an iscsi_close...
Split nbd block client code
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
nbd: don't change socket block during negotiate
The caller might handle non-blocking using coroutine. Leave the choiceto the caller to use a blocking or non-blocking negotiate.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>...
nbd: pass export name as init argument
There is no need to keep the export name around, and it seems a betterfit as an argument in the init() call.
nbd: make nbd_client_session_close() idempotent
nbd: finish any pending coroutine
Make sure all pending coroutines are finished when closing the session.
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
nbd: avoid uninitialized warnings
blkdebug: Use QLIST_FOREACH_SAFE to resume IO
Qemu-iotest 030 was broken.
When the coroutine runs and finishes, it will remove itself from the reqlist, so let's use safe version of foreach to avoid use after free.
Signed-off-by: Fam Zheng <famz@redhat.com>...
sheepdog: check if '-o redundancy' is passed from user
This fix a segfault (that is caused by b3af018f3) of following command:
$ qemu-img convert some_img sheepdog:some_img
Cc: qemu-devel@nongnu.orgCc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>...
block/vvfat: Fix compiler warnings for OpenBSD
The buildbot shows these compiler warnings:
block/vvfat.c: In function 'create_short_and_long_name':block/vvfat.c:620: warning: array size (8) smaller than bound length (11)block/vvfat.c:620: warning: array size (8) smaller than bound length (11)...
block/iscsi: introduce bdrv_co_{readv, writev, flush_to_disk}
this converts read, write and flush functions from aio to coroutineseliminating almost 200 lines of code.
The requirement for libiscsi is bumped to version 1.4.0 which wasreleased in may 2012....
qcow2: use start_of_cluster() and offset_into_cluster() everywhere
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>Reviewed-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/iscsi: set bdi->cluster_size
this patch aims to set bdi->cluster_size to the internal page sizeof the iscsi target so that enabled callers can align requestsproperly.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>...
block/iscsi: set bs->bl.opt_transfer_length
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
snapshot: distinguish id and name in load_tmp
Since later this function will be used so improve it. The only caller of itnow is qemu-img, and it is not impacted by introduce functionbdrv_snapshot_load_tmp_by_id_or_name() that call bdrv_snapshot_load_tmp()...
qemu-nbd: support internal snapshot export
Now it is possible to directly export an internal snapshot, whichcan be used to probe the snapshot's contents without qemu-imgconvert.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qcow2: Zero-initialise first cluster for new images
Strictly speaking, this is only required for has_zero_init() == false,but it's easy enough to just do a cluster-aligned write that is paddedwith zeros after the header.
This fixes that after 'qemu-img create' header extensions are attempted...
block: handle ENOTSUP from discard in generic code
Similar to write_zeroes, let the generic code receive a ENOTSUP fordiscard operations. Since bdrv_discard has advisory semantics,we can just swallow the error.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
vpc, vhdx: add get_info
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block drivers: add discard/write_zeroes properties to bdrv_get_info implementation
block drivers: expose requirement for write same alignment from formats
This will let misaligned but large requests use zero clusters. Thisis important because the cluster size is not guest visible.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Peter Lieven <pl@kamp.de>...
block/iscsi: remove .bdrv_has_zero_init
since commit 3ac21627 the default value changed to 0.
Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/iscsi: updated copyright
added myself to reflect recent work on the iscsi block driver.
block/iscsi: check WRITE SAME support differently depending on MAY_UNMAP
The current check is right for MAY_UNMAP=1. For MAY_UNMAP=0, justtry and fall back to regular writes as soon as a WRITE SAME commandfails.
raw-posix: implement write_zeroes with MAY_UNMAP for files
Writing zeroes to a file can be done by punching a hole ifMAY_UNMAP is set.
Note that in this case ENOTSUP is not ignored, but makesthe block layer fall back to the generic implementation.
raw-posix: implement write_zeroes with MAY_UNMAP for block devices
See the next commit for the description of the Linux kernel problemthat is worked around in raw_open_common.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
raw-posix: add support for write_zeroes on XFS and block devices
The code is similar to the implementation of discard and write_zeroeswith UNMAP. However, failure must be propagated up to block.c.
The stale page cache problem can be reproduced as follows:...
vmdk: Fix creating big description file
The buffer for description file was 4096 which only covers a fewhundred of extents. This changes the buffer to dynamic allocated withg_strdup_printf in order to support bigger cases.
vmdk: Allow read only open of VMDK version 3
block: Use BDRV_O_NO_BACKING where appropriate
If you open an image temporarily just because you want to check its sizeor get it flushed, there's no real reason to open the whole backing filechain.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Fam Zheng <famz@redhat.com>...
sheepdog: refactor do_sd_create()
We can actually use BDRVSheepdogState *s to pass most of the parameters.
Cc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Liu Yuan <namei.unix@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
sheepdog: support user-defined redundancy option
Sheepdog support two kinds of redundancy, full replication and erasure coding.
blkdebug: add "remove_break" command
This adds "remove_break" command which is the reverse of blkdebugcommand "break": it removes all breakpoints with given tag and resumesall the requests.
qapi: Change BlockDirtyInfo to list
We have multiple dirty bitmaps in BDS now, switch QAPI to allow queryit (BlockInfo.dirty_bitmaps), and also drop old BlockInfo.dirty.
COW: Speed up writes
Process a whole sector's worth of COW bits by reading a sector, settingthe bits after skipping any already set bits, then writing it out again.Make sure we only flush once before writing metadata, and only if weneed to write metadata....
COW: Extend checking allocated bits to beyond one sector
cow_co_is_allocated() only checks one sector's worth of allocated bitsbefore returning. This is allowed but (slightly) inefficient, so extendit to check all of the file's metadata sectors.
Signed-off-by: Charlie Shepherd <charlie@ctshepherd.com>...
block: per caller dirty bitmap
Previously a BlockDriverState has only one dirty bitmap, so only onecaller (e.g. a block job) can keep track of writing. This changes thedirty bitmap to a list and creates a BdrvDirtyBitmap for each caller, thelifecycle is managed with these new functions:...
block/stream: Don't stream unbacked devices
If a block device is unbacked, a streaming blockjob should immediatelyfinish instead of beginning to try to stream, then noticing the backingfile does not contain even the first sector (since it does not exist)...
iscsi: set limits in BlockDriverState
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
iscsi: simplify iscsi_co_discard
now that bdrv_co_discard can handle limits we do not needthe request split logic here anymore.
iscsi: add bdrv_co_write_zeroes
Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
sheepdog: implement .bdrv_get_allocated_file_size
With this patch, qemu-img info sheepdog:image will show disk size for sheepdogimages.
Cc: Kevin Wolf <kwolf@redhat.com>Cc: Stefan Hajnoczi <stefanha@redhat.com>Cc: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
block: add flags to bdrv_*_write_zeroes
block: introduce BDRV_REQ_MAY_UNMAP request flag
block/iscsi: add .bdrv_get_info
block/raw: copy BlockLimits on raw_open
qcow2: fix possible corruption when reading multiple clusters
if multiple sectors spanning multiple clusters are read thefunction count_contiguous_clusters should ensure that thecluster type should not change between the clusters.
Especially the for-loop should break when we have one...