[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/18] commit: Support commit active layer
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 16/18] commit: Support commit active layer |
Date: |
Fri, 20 Dec 2013 16:46:54 +0100 |
From: Fam Zheng <address@hidden>
If active is top, it will be mirrored to base, (with block/mirror.c
code), then the image is switched when user completes the block job.
QMP documentation is updated.
Signed-off-by: Fam Zheng <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/mirror.c | 11 +++++++++++
blockdev.c | 9 +++++++--
qapi-schema.json | 5 +++--
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/block/mirror.c b/block/mirror.c
index 04af341..2932bab 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -481,6 +481,13 @@ immediate_exit:
bdrv_reopen(s->target, bdrv_get_flags(s->common.bs), NULL);
}
bdrv_swap(s->target, s->common.bs);
+ if (s->common.driver->job_type == BLOCK_JOB_TYPE_COMMIT) {
+ /* drop the bs loop chain formed by the swap: break the loop then
+ * trigger the unref from the top one */
+ BlockDriverState *p = s->base->backing_hd;
+ s->base->backing_hd = NULL;
+ bdrv_unref(p);
+ }
}
bdrv_unref(s->target);
block_job_completed(&s->common, ret);
@@ -623,6 +630,10 @@ void commit_active_start(BlockDriverState *bs,
BlockDriverState *base,
BlockDriverCompletionFunc *cb,
void *opaque, Error **errp)
{
+ if (bdrv_reopen(base, bs->open_flags, errp)) {
+ return;
+ }
+ bdrv_ref(base);
mirror_start_job(bs, base, speed, 0, 0,
on_error, on_error, cb, opaque, errp,
&commit_active_job_driver, false, base);
diff --git a/blockdev.c b/blockdev.c
index 6a85961..2c3242b 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1820,8 +1820,13 @@ void qmp_block_commit(const char *device,
return;
}
- commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs,
- &local_err);
+ if (top_bs == bs) {
+ commit_active_start(bs, base_bs, speed, on_error, block_job_cb,
+ bs, &local_err);
+ } else {
+ commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs,
+ &local_err);
+ }
if (local_err != NULL) {
error_propagate(errp, local_err);
return;
diff --git a/qapi-schema.json b/qapi-schema.json
index 5aa4581..b9b051c 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1967,9 +1967,11 @@
#
# @top: The file name of the backing image within the image chain,
# which contains the topmost data to be committed down.
-# Note, the active layer as 'top' is currently unsupported.
#
# If top == base, that is an error.
+# If top == active, the job will not be completed by itself,
+# user needs to complete the job with the block-job-complete
+# command after getting the ready event. (Since 2.0)
#
#
# @speed: #optional the maximum speed, in bytes per second
@@ -1979,7 +1981,6 @@
# If @device does not exist, DeviceNotFound
# If image commit is not supported by this device, NotSupported
# If @base or @top is invalid, a generic error is returned
-# If @top is the active layer, or omitted, a generic error is returned
# If @speed is invalid, InvalidParameter
#
# Since: 1.3
--
1.8.4.2
- [Qemu-devel] [PULL 07/18] block/iscsi: Fix compilation for libiscsi 1.4.0 (API change), (continued)
- [Qemu-devel] [PULL 07/18] block/iscsi: Fix compilation for libiscsi 1.4.0 (API change), Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 06/18] qapi-schema: fix QEMU 1.8 references, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 08/18] block: vhdx - improve error message, and .bdrv_check implementation, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 09/18] docs: updated qemu-img man page and qemu-doc to reflect VHDX support., Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 10/18] vmdk: Check VMFS extent line field number, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 11/18] vmdk: Allow vmdk_create to work with protocol, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 12/18] qemu-iotests: drop duplicate virtio-blk initialization failure, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 13/18] mirror: Don't close target, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 14/18] mirror: Move base to MirrorBlockJob, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 15/18] block: Add commit_active_start(), Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 16/18] commit: Support commit active layer,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 17/18] qemu-iotests: Update test cases for commit active, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 18/18] commit: Remove unused check, Stefan Hajnoczi, 2013/12/20