[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/15] stream: Add 'job-id' parameter to 'block-comm
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH 09/15] stream: Add 'job-id' parameter to 'block-commit' |
Date: |
Thu, 9 Jun 2016 11:20:14 +0300 |
This patch adds a new optional 'job-id' parameter to 'block-commit',
allowing the user to specify the ID of the block job to be created.
Signed-off-by: Alberto Garcia <address@hidden>
---
block/commit.c | 7 ++++---
block/mirror.c | 6 +++---
blockdev.c | 9 +++++----
include/block/block_int.h | 16 ++++++++++------
qapi/block-core.json | 4 +++-
qemu-img.c | 2 +-
qmp-commands.hx | 3 ++-
7 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/block/commit.c b/block/commit.c
index 3535ba7..6e576d9 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -211,8 +211,8 @@ static const BlockJobDriver commit_job_driver = {
.set_speed = commit_set_speed,
};
-void commit_start(BlockDriverState *bs, BlockDriverState *base,
- BlockDriverState *top, int64_t speed,
+void commit_start(const char *job_id, BlockDriverState *bs,
+ BlockDriverState *base, BlockDriverState *top, int64_t speed,
BlockdevOnError on_error, BlockCompletionFunc *cb,
void *opaque, const char *backing_file_str, Error **errp)
{
@@ -236,7 +236,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState
*base,
return;
}
- s = block_job_create(NULL, &commit_job_driver, bs, speed, cb, opaque,
errp);
+ s = block_job_create(job_id, &commit_job_driver, bs, speed,
+ cb, opaque, errp);
if (!s) {
return;
}
diff --git a/block/mirror.c b/block/mirror.c
index ab08da8..f70d6b6 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -880,8 +880,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
&mirror_job_driver, is_none_mode, base);
}
-void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
- int64_t speed,
+void commit_active_start(const char *job_id, BlockDriverState *bs,
+ BlockDriverState *base, int64_t speed,
BlockdevOnError on_error,
BlockCompletionFunc *cb,
void *opaque, Error **errp)
@@ -922,7 +922,7 @@ void commit_active_start(BlockDriverState *bs,
BlockDriverState *base,
}
}
- mirror_start_job(NULL, bs, base, NULL, speed, 0, 0,
+ mirror_start_job(job_id, bs, base, NULL, speed, 0, 0,
on_error, on_error, false, cb, opaque, &local_err,
&commit_active_job_driver, false, base);
if (local_err) {
diff --git a/blockdev.c b/blockdev.c
index f4ff025..0f4c433 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3070,7 +3070,7 @@ out:
aio_context_release(aio_context);
}
-void qmp_block_commit(const char *device,
+void qmp_block_commit(bool has_job_id, const char *job_id, const char *device,
bool has_base, const char *base,
bool has_top, const char *top,
bool has_backing_file, const char *backing_file,
@@ -3161,10 +3161,11 @@ void qmp_block_commit(const char *device,
" but 'top' is the active layer");
goto out;
}
- commit_active_start(bs, base_bs, speed, on_error, block_job_cb,
- bs, &local_err);
+ commit_active_start(has_job_id ? job_id : NULL, 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,
+ commit_start(has_job_id ? job_id : NULL, bs, base_bs, top_bs, speed,
+ on_error, block_job_cb, bs,
has_backing_file ? backing_file : NULL, &local_err);
}
if (local_err != NULL) {
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 9693cf4..14dc9fc 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -634,6 +634,8 @@ void stream_start(const char *job_id, BlockDriverState *bs,
/**
* commit_start:
+ * @job_id: The id of the newly-created job, or %NULL to have one
+ * generated automatically.
* @bs: Active block device.
* @top: Top block device to be committed.
* @base: Block device that will be written into, and become the new top.
@@ -645,12 +647,14 @@ void stream_start(const char *job_id, BlockDriverState
*bs,
* @errp: Error object.
*
*/
-void commit_start(BlockDriverState *bs, BlockDriverState *base,
- BlockDriverState *top, int64_t speed,
- BlockdevOnError on_error, BlockCompletionFunc *cb,
- void *opaque, const char *backing_file_str, Error **errp);
+void commit_start(const char *job_id, BlockDriverState *bs,
+ BlockDriverState *base, BlockDriverState *top, int64_t speed,
+ BlockdevOnError on_error, BlockCompletionFunc *cb,
+ void *opaque, const char *backing_file_str, Error **errp);
/**
* commit_active_start:
+ * @job_id: The id of the newly-created job, or %NULL to have one
+ * generated automatically.
* @bs: Active block device to be committed.
* @base: Block device that will be written into, and become the new top.
* @speed: The maximum speed, in bytes per second, or 0 for unlimited.
@@ -660,8 +664,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState
*base,
* @errp: Error object.
*
*/
-void commit_active_start(BlockDriverState *bs, BlockDriverState *base,
- int64_t speed,
+void commit_active_start(const char *job_id, BlockDriverState *bs,
+ BlockDriverState *base, int64_t speed,
BlockdevOnError on_error,
BlockCompletionFunc *cb,
void *opaque, Error **errp);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 14073f7..f754c29 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1008,6 +1008,8 @@
# Live commit of data from overlay image nodes into backing nodes - i.e.,
# writes data between 'top' and 'base' into 'base'.
#
+# @job-id: #optional identifier for the newly-created block job (Since 2.7)
+#
# @device: the name of the device
#
# @base: #optional The file name of the backing image to write data into.
@@ -1059,7 +1061,7 @@
#
##
{ 'command': 'block-commit',
- 'data': { 'device': 'str', '*base': 'str', '*top': 'str',
+ 'data': { '*job-id': 'str', 'device': 'str', '*base': 'str', '*top': 'str',
'*backing-file': 'str', '*speed': 'int' } }
##
diff --git a/qemu-img.c b/qemu-img.c
index 4b56ad3..1fc01eb 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -910,7 +910,7 @@ static int img_commit(int argc, char **argv)
.bs = bs,
};
- commit_active_start(bs, base_bs, 0, BLOCKDEV_ON_ERROR_REPORT,
+ commit_active_start(NULL, bs, base_bs, 0, BLOCKDEV_ON_ERROR_REPORT,
common_block_job_cb, &cbi, &local_err);
if (local_err) {
goto done;
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 1818e43..5f801a9 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1123,7 +1123,7 @@ EQMP
{
.name = "block-commit",
- .args_type = "device:B,base:s?,top:s?,backing-file:s?,speed:o?",
+ .args_type =
"job-id:s?,device:B,base:s?,top:s?,backing-file:s?,speed:o?",
.mhandler.cmd_new = qmp_marshal_block_commit,
},
@@ -1136,6 +1136,7 @@ data between 'top' and 'base' into 'base'.
Arguments:
+- "job-id": identifier for the newly-created block job (json-string, optional)
- "device": The device's ID, must be unique (json-string)
- "base": The file name of the backing image to write data into.
If not specified, this is the deepest backing image
--
2.8.1
- [Qemu-devel] [PATCH 00/15] Add an 'id' field to block jobs, Alberto Garcia, 2016/06/09
- [Qemu-devel] [PATCH 08/15] stream: Add 'job-id' parameter to 'block-stream', Alberto Garcia, 2016/06/09
- [Qemu-devel] [PATCH 07/15] backup: Add 'job-id' parameter to 'blockdev-backup' and 'drive-backup', Alberto Garcia, 2016/06/09
- [Qemu-devel] [PATCH 09/15] stream: Add 'job-id' parameter to 'block-commit',
Alberto Garcia <=
- [Qemu-devel] [PATCH 06/15] mirror: Add 'job-id' parameter to 'blockdev-mirror' and 'drive-mirror', Alberto Garcia, 2016/06/09
- [Qemu-devel] [PATCH 05/15] blockjob: Add 'job_id' parameter to block_job_create(), Alberto Garcia, 2016/06/09
- [Qemu-devel] [PATCH 13/15] blockjob: Add 'id' parameter to 'block-job-resume', Alberto Garcia, 2016/06/09
- [Qemu-devel] [PATCH 01/15] stream: Fix prototype of stream_start(), Alberto Garcia, 2016/06/09