iscsi: fix indentation
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
iscsi: correctly propagate errors in iscsi_open
Before: $ ./qemu-io-old qemu-io-old> open -r -o file.driver=iscsi,file.filename=foo Failed to parse URL : foo qemu-io-old: can't open device (null): Could not open 'foo': Invalid argument
After:...
gluster: default scheme to gluster:// and host to localhost.
Currently, "gluster:///volname/img" and (using file. options)"file.driver=gluster,file.filename=foo" will segfault. Also,"//host/volname/img" will be rejected, but it is a valid URLthat should be accepted just fine with "file.driver=gluster"....
block: Add reference parameter to bdrv_open()
Allow bdrv_open() to handle references to existing block devices just asbdrv_file_open() is already capable of.
Signed-off-by: Max Reitz <mreitz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Make bdrv_file_open() static
Add the bdrv_open() option BDRV_O_PROTOCOL which results in passing thecall to bdrv_file_open(). Additionally, make bdrv_file_open() static andtherefore bdrv_open() the only way to call it.
Consequently, all existing calls to bdrv_file_open() have to be adjusted...
block: Remove bdrv_open_image()'s force_raw option
This option is now unnecessary since specifying BDRV_O_PROTOCOL as flagwill do exactly the same.
Signed-off-by: Max Reitz <mreitz@redhat.com>Reviewed-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Kevin Wolf <kwolf@redhat.com>...
nbd: produce a better error if neither host nor port is passed
Before: $ qemu-io-old qemu-io-old> open -r -o file.driver=nbd qemu-io-old: can't open device (null): Could not open image: Invalid argument $ ./qemu-io-old qemu-io-old> open -r -o file.driver=nbd,file.host=foo,file.path=bar...
nbd: correctly propagate errors
Before: $ ./qemu-io-old qemu-io-old> open -r -o file.driver=nbd one of path and host must be specified. qemu-io-old: can't open device (null): Could not open image: Invalid argument $ ./qemu-io-old qemu-io-old> open -r -o file.driver=nbd,file.host=foo,file.path=bar...
qcow2: Set zero flag for discarded clusters
Instead of making the backing file contents visible again after a discardrequest, set the zero flag if possible (i.e. on version >= 3).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
block: Change BDS parameter of bdrv_open() to **
Make bdrv_open() take a pointer to a BDS pointer, similarly tobdrv_file_open(). If a pointer to a NULL pointer is given, bdrv_open()will create a new BDS with an empty name; if the BDS pointer is notNULL, that existing BDS will be reused (in the same way as bdrv_open()...
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
Use error_is_set() only when necessary
error_is_set(&var) is the same as var != NULL, but it takeswhole-program analysis to figure that out. Unnecessarily hard foroptimizers, static checkers, and human readers. Dumb it down toobvious.
Gets rid of several dozen Coverity false positives....
block: mirror - use local_err to avoid NULL errp
When starting a block job, commit_active_start() relies on whether *errpis set by mirror_start_job. This allows it to determine if the mirrorjob start failed, so that it can clean up any changes to open flags from...
block: Don't throw away errno via error_setg
There are a handful of places in the block layer where a failure pathhas a valid -errno value, yet error_setg() is used. Those instancesshould instead use error_setg_errno(), to preserve as much errorinformation as possible....
block: Add notes to iSCSI's .bdrv_open and .bdrv_reopen_prepare
iSCSI currently does not need to do any actions to support thecurrent usage of bdrv_reopen(). However, it is important to notea couple of things: 1.) A connection will not be re-established to...
qcow2: remove n_start and n_end of qcow2_alloc_cluster_offset()
n_start can be actually calculated from offset. The number ofsectors to be allocated(n_end - n_start) can be passed in innum. By removing n_start and n_end, we can save two parameters.
The side effect is there is a bug in qcow2.c:preallocate() that...
qcow2: fix offset overflow in qcow2_alloc_clusters_at()
When cluster size is big enough it can lead to an offset overflowin qcow2_alloc_clusters_at(). This patch fixes it.
The allocation is stopped each time at L2 table boundary(see handle_alloc()), so the possible maximum bytes could be...
qcow2: check for NULL l2meta
In the case of a metadata preallocation with a large cluster size,qcow2_alloc_cluster_offset() can allocate nothing and returns aNULL l2meta. This patch checks for it and link2 l2 with only validl2meta.
Replace 9 and 512 with BDRV_SECTOR_BITS, BDRV_SECTOR_SIZE...
raw: Fix BlockLimits passthrough
raw copies over the BlockLimits of bs->file during bdrv_open().However, since commit d34682cd it is immediately overwritten duringbdrv_refresh_limits(). This caused all fields except foropt_transfer_length and opt_mem_alignment (which happen to be correctly...
blkdebug: Don't leak bs->file on failure
Reported-by: Laszlo Ersek <lersek@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Laszlo Ersek <lersek@redhat.com>
block: add native support for NFS
This patch adds native support for accessing images on NFSshares without the requirement to actually mount the entireNFS share on the host.
NFS Images can simply be specified by an url of the form:nfs://<host>/<export>/<filename>[?param=value[¶m2=value2[&...]]]...
block/iscsi: always fill bs->bl.opt_transfer_length
the opt_transfer_length has nothing to do with logicalblock provisioning stuff so always copy it fromthe block limits VPD page.
Reported-By: Benoit Canet <benoit@irqsave.net>Signed-off-by: Peter Lieven <pl@kamp.de>...
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.
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 drivers: add discard/write_zeroes properties to bdrv_get_info implementation
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: 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.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
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:...