block: Support Archipelago as a QEMU block backend
block: Free memory on AIO failure
block/gluster: Add missing argument to qemu_gluster_init() call
Commit adccfbcd6020e928db93b2b4faf0dbd05ffbe016 (block: gluster - addreopen support.) did not supply the qemu_gluster_init() Error **argument, needed since commit a7451cb850d115f257080aff3fbc54f255ebf8f7...
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request
Merge remote-tracking branch 'remotes/bonzini/scsi-next' into staging
block/vmdk: do not report file offset for compressed extents
Signed-off-by: Peter Lieven <pl@kamp.de>Reviewed-by: Fam Zheng <famz@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: gluster - code movements, state storage changes
In preparation for supporting reopen on gluster, move flagparsing out to a function. Also, add a NULL check in thegconf cleanup.
Signed-off-by: Jeff Cody <jcody@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: gluster - add reopen support.
Gluster does parse open flags in its .bdrv_open() implementation,and the .bdrv_reopen_* implementations need to do the same.
A new gluster connection to the image file to be created is establishedin the .bdrv_reopen_prepare(), and the image file opened with the new...
qmp: Make Quorum error events more palatable.
Insert quorum QMP events documentation alphabetically.
Also change the "ret" errno value by an optional "error" being an strerror(-ret)in the QUORUM_REPORT_BAD qmp event.
Signed-off-by: Benoit Canet <benoit@irqsave.net>...
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block patches
Merge remote-tracking branch 'remotes/bonzini/configure' into staging
block/iscsi: fix segfault if writesame fails
commit fa6252b0 introduced a segfault because it triesto read iTask.task->sense after iTask.task has beenfreed.
Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/iscsi: fix deadlock on scsi check condition
the retry logic was broken because the complete statusof the task structure was not reset. this resulted inan infinite loop retrying the command over and over.
CC: qemu-stable@nongnu.orgSigned-off-by: Peter Lieven <pl@kamp.de>...
block/iscsi: query for supported VPD pages
this patch ensures that we only query for block provisioning andblock limits vpd pages if they are advertised. It also cleansup the inquiry code and eliminates some redundant code.
Signed-off-by: Peter Lieven <pl@kamp.de>...
quorum: Simplify quorum_open()
Although it may not look like it, this patch simplifies quorum_open().qdict_array_split() is now able to return QLists with different objectsthan only QDicts, therefore it will now do all the work andquorum_open() does not have to handle reference strings by itself....
quorum: Add quorum_co_flush().
Makes a vote to select error if any.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Max Reitz <mreitz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
quorum: Implement recursive .bdrv_recurse_is_first_non_filter in quorum.
This is used to activate quorum snapshot.
quorum: Add quorum_open() and quorum_close().
Example of command line:
-drive if=virtio,driver=quorum,\children.0.file.filename=1.raw,\children.0.node-name=1.raw,\children.0.driver=raw,\children.1.file.filename=2.raw,\children.1.node-name=2.raw,\children.1.driver=raw,\...
quorum: Add quorum mechanism.
This patchset enables the core of the quorum mechanism.The num_children reads are compared to get the majority version and if thisversion exists more than threshold times the guest won't see the error at all.
If a block is corrupted or if an error occurs during an IO or if the quorum...
quorum: Add quorum_getlength().
Check that every bs file returns the same length.Otherwise, return -EIO to disable the quorum andavoid length discrepancy.
quorum: Add quorum_invalidate_cache().
We really want that live migration works with quorum so implementquorum_invalidate_cache().
quorum: Add quorum_aio_writev and its dependencies.
Writes are mirrored num_children times on num_children devices.
blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify.
qemu_iovec_compare() will be used to compare IOs vectors in quorum blkverifymode. The patch extracts these functions in order to factorize the code.
quorum: Add quorum_aio_readv.
Add code to do num_children reads in parallel and cleanup the structuresafterwards.
quorum: Create quorum.c, add QuorumChildRequest and QuorumAIOCB.
Quorum is a block filter mirroring writes to num_children children.For reads quorum reads each children and does a vote.If more than vote_threshold versions are identical the quorum is reached and...
quorum: Create BDRVQuorumState and BlkDriver and do init.
Create the structure holding the quorum settings and write the minimal blockdriver instanciation boilerplate.
Signed-off-by: Benoit Canet <benoit@irqsave.net>Reviewed-by: Max Reitz <mreitz@redhat.com>...
vmdk: extract vmdk_read_desc
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Fam Zheng <famz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vmdk: push vmdk_read_desc up to caller
Currently, we just try reading a VMDK file as both image and descriptor.This makes it hard to choose which of the two attempts gave the best error.We'll decide in advance if the file looks like an image or a descriptor,...
vmdk: do not try opening a file as both image and descriptor
This prepares for propagating errors from vmdk_open_sparse andvmdk_open_desc_file up to the caller of vmdk_open.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Fam Zheng <famz@redhat.com>...
vmdk: correctly propagate errors
Now that we can return the "right" errors, use the Error** parameterto pass them back instead of just printing them.
block: do not abuse EMEDIUMTYPE
Returning "Wrong medium type" for an image that does not have a validheader is a bit weird. Improve the error by mentioning what formatwas trying to open it.
vdi: say why an image is bad
Instead of just putting it in debugging output, we can now put thevalue in an Error.
iscsi: fix indentation
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"....
gluster: correctly propagate errors
cow: correctly propagate errors
curl: correctly propagate errors
qcow: correctly propagate errors
qed: correctly propagate errors
vhdx: correctly propagate errors
vvfat: correctly propagate errors
Before: $ ./qemu-io-old qemu-io-old> open -r -o driver=vvfat,fat-type=24,dir=i386-softmmu Valid FAT types are only 12, 16 and 32 qemu-io-old: can't open device (null): Could not open image: Invalid argument...
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()...
block: use per-object cflags and libs
No longer adds flags and libs for them to global variables, insteadcreate config-host.mak variables like FOO_CFLAGS and FOO_LIBS, which isused as per object cflags and libs.
This removes unwanted dependencies from libcacard....
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.
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>...