History | View | Annotate | Download (22.4 kB)
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: 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...
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....
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>
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:...
blockjob: rename BlockJobType to BlockJobDriver
We will use BlockJobType as the enum type name of block jobs in QAPI,rename current BlockJobType to BlockJobDriver, which will eventuallybecome a set of operations, similar to block drivers.
Signed-off-by: Fam Zheng <famz@redhat.com>...
qapi: make use of new BlockJobType
Switch the string to enum type BlockJobType in BlockJobDriver.
Signed-off-by: Fam Zheng <famz@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Error parameter for open functions
Add an Error ** parameter to bdrv_open, bdrv_file_open and associatedfunctions to allow more specific error messages.
Signed-off-by: Max Reitz <mreitz@redhat.com>
block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction
Now that bdrv_is_allocated detects coroutine context, the two canuse the same code.
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
block: make bdrv_delete() static
Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is nolonger public and should be called by bdrv_unref() if refcnt isdecreased to 0.
This is an identical change because effectively, there's no multiplereference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets...
aio / timers: convert block_job_sleep_ns and co_sleep_ns to new API
Convert block_job_sleep_ns and co_sleep_ns to use the new timerAPI.
Signed-off-by: Alex Bligh <alex@alex.org.uk>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
aio / timers: Switch entire codebase to the new timer API
This is an autogenerated patch using scripts/switch-timer-api.
Switch the entire code base to using the new timer API.
Note this patch may introduce some line length issues.
Signed-off-by: Alex Bligh <alex@alex.org.uk>...
block: Make BlockJobTypes const
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: mirror_complete(): use error_setg_file_open()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Acked-by: Kevin Wolf <kwolf@redhat.com>
block: Add driver-specific options for backing files
Options starting in "backing." are passed to the backing file now. Ifyou don't need to specify the filename for the backing file, you can addit on the command line instead of in the image file:
$ qemu-nbd -t /tmp/test.img...
mirror: support more than one in-flight AIO operation
With AIO support in place, we can start copying more than one chunkin parallel. This patch introduces the required infrastructure forthis: the buffer is split into multiple granularity-sized chunks,...
mirror: support arbitrarily-sized iterations
Yet another optimization is to extend the mirroring iteration to include moreadjacent dirty blocks. This limits the number of I/O operations and makesmirroring efficient even with a small granularity. Most of the infrastructure...
mirror: do nothing on zero-sized disk
On a zero-sized disk we need to break out of the job successfullybefore bdrv_dirty_iter_init is called, otherwise you will get anassertion failure with the next patch.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
block: allow customizing the granularity of the dirty bitmap
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
mirror: allow customizing the granularity
The desired granularity may be very different depending on the kind ofoperation (e.g. continuous replication vs. collapse-to-raw) and whetherthe VM is expected to perform lots of I/O while mirroring is in progress....
mirror: switch mirror_iteration to AIO
There is really no change in the behavior of the job here, sincethere is still a maximum of one in-flight I/O operation betweenthe source and the target. However, this patch already introducesthe AIO callbacks (which are unmodified in the next patch)...
mirror: add buf-size argument to drive-mirror
This makes sense when the next commit starts using the extra buffer spaceto perform many I/O operations asynchronously.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: implement dirty bitmap using HBitmap
This actually uses the dirty bitmap in the block layer, and convertsmirroring to use an HBitmapIter.
Reviewed-by: Laszlo Ersek <lersek@redhat.com> (except block/mirror.c parts)Reviewed-by: Eric Blake <eblake@redhat.com>...
mirror: perform COW if the cluster size is bigger than the granularity
When mirroring runs, the backing files for the target may not yet beready. However, this means that a copy-on-write operation on the targetwould fill the missing sectors with zeros. Copy-on-write only happens...
block: return count of dirty sectors, not chunks
Reviewed-by: Laszlo Ersek <lersek@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Fix how mirror_run() frees its buffer
It allocates with qemu_blockalign(), therefore it must free withqemu_vfree(), not g_free().
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: move include files to include/block/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
aio: Get rid of qemu_aio_flush()
There are no remaining users, and new users should probably beusing bdrv_drain_all() in the first place.
mirror: implement completion
Switching to the target of the migration is done mostly asynchronously,and reported to management via the BLOCK_JOB_COMPLETED event; the onlysynchronous phase is opening the backing files. bdrv_open_backing_filecan always be done, even for migration of the full image (aka sync:...
mirror: add support for on-source-error/on-target-error
Error management is important for mirroring; otherwise, an error on thetarget (even something as "innocent" as ENOSPC) requires to start againwith a full copy. Similar to on_read_error/on_write_error, two separate...
mirror: introduce mirror job
This patch adds the implementation of a new job that mirrors a disk toa new image while letting the guest continue using the old image.The target is treated as a "black box" and data is copied from thesource to the target in the background. This can be used for several...