提交 fd62c609 编写于 作者: A Alberto Garcia 提交者: Kevin Wolf

commit: Add 'job-id' parameter to 'block-commit'

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: NAlberto Garcia <berto@igalia.com>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Reviewed-by: NMax Reitz <mreitz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 2323322e
...@@ -211,8 +211,8 @@ static const BlockJobDriver commit_job_driver = { ...@@ -211,8 +211,8 @@ static const BlockJobDriver commit_job_driver = {
.set_speed = commit_set_speed, .set_speed = commit_set_speed,
}; };
void commit_start(BlockDriverState *bs, BlockDriverState *base, void commit_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *top, int64_t speed, BlockDriverState *base, BlockDriverState *top, int64_t speed,
BlockdevOnError on_error, BlockCompletionFunc *cb, BlockdevOnError on_error, BlockCompletionFunc *cb,
void *opaque, const char *backing_file_str, Error **errp) void *opaque, const char *backing_file_str, Error **errp)
{ {
...@@ -236,7 +236,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, ...@@ -236,7 +236,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
return; 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) { if (!s) {
return; return;
} }
......
...@@ -931,8 +931,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs, ...@@ -931,8 +931,8 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
&mirror_job_driver, is_none_mode, base); &mirror_job_driver, is_none_mode, base);
} }
void commit_active_start(BlockDriverState *bs, BlockDriverState *base, void commit_active_start(const char *job_id, BlockDriverState *bs,
int64_t speed, BlockDriverState *base, int64_t speed,
BlockdevOnError on_error, BlockdevOnError on_error,
BlockCompletionFunc *cb, BlockCompletionFunc *cb,
void *opaque, Error **errp) void *opaque, Error **errp)
...@@ -973,7 +973,7 @@ void commit_active_start(BlockDriverState *bs, BlockDriverState *base, ...@@ -973,7 +973,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,
MIRROR_LEAVE_BACKING_CHAIN, MIRROR_LEAVE_BACKING_CHAIN,
on_error, on_error, false, cb, opaque, &local_err, on_error, on_error, false, cb, opaque, &local_err,
&commit_active_job_driver, false, base); &commit_active_job_driver, false, base);
......
...@@ -3077,7 +3077,7 @@ out: ...@@ -3077,7 +3077,7 @@ out:
aio_context_release(aio_context); 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_base, const char *base,
bool has_top, const char *top, bool has_top, const char *top,
bool has_backing_file, const char *backing_file, bool has_backing_file, const char *backing_file,
...@@ -3168,10 +3168,11 @@ void qmp_block_commit(const char *device, ...@@ -3168,10 +3168,11 @@ void qmp_block_commit(const char *device,
" but 'top' is the active layer"); " but 'top' is the active layer");
goto out; goto out;
} }
commit_active_start(bs, base_bs, speed, on_error, block_job_cb, commit_active_start(has_job_id ? job_id : NULL, bs, base_bs, speed,
bs, &local_err); on_error, block_job_cb, bs, &local_err);
} else { } 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); has_backing_file ? backing_file : NULL, &local_err);
} }
if (local_err != NULL) { if (local_err != NULL) {
......
...@@ -666,6 +666,8 @@ void stream_start(const char *job_id, BlockDriverState *bs, ...@@ -666,6 +666,8 @@ void stream_start(const char *job_id, BlockDriverState *bs,
/** /**
* commit_start: * commit_start:
* @job_id: The id of the newly-created job, or %NULL to use the
* device name of @bs.
* @bs: Active block device. * @bs: Active block device.
* @top: Top block device to be committed. * @top: Top block device to be committed.
* @base: Block device that will be written into, and become the new top. * @base: Block device that will be written into, and become the new top.
...@@ -677,12 +679,14 @@ void stream_start(const char *job_id, BlockDriverState *bs, ...@@ -677,12 +679,14 @@ void stream_start(const char *job_id, BlockDriverState *bs,
* @errp: Error object. * @errp: Error object.
* *
*/ */
void commit_start(BlockDriverState *bs, BlockDriverState *base, void commit_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *top, int64_t speed, BlockDriverState *base, BlockDriverState *top, int64_t speed,
BlockdevOnError on_error, BlockCompletionFunc *cb, BlockdevOnError on_error, BlockCompletionFunc *cb,
void *opaque, const char *backing_file_str, Error **errp); void *opaque, const char *backing_file_str, Error **errp);
/** /**
* commit_active_start: * commit_active_start:
* @job_id: The id of the newly-created job, or %NULL to use the
* device name of @bs.
* @bs: Active block device to be committed. * @bs: Active block device to be committed.
* @base: Block device that will be written into, and become the new top. * @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. * @speed: The maximum speed, in bytes per second, or 0 for unlimited.
...@@ -692,8 +696,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base, ...@@ -692,8 +696,8 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
* @errp: Error object. * @errp: Error object.
* *
*/ */
void commit_active_start(BlockDriverState *bs, BlockDriverState *base, void commit_active_start(const char *job_id, BlockDriverState *bs,
int64_t speed, BlockDriverState *base, int64_t speed,
BlockdevOnError on_error, BlockdevOnError on_error,
BlockCompletionFunc *cb, BlockCompletionFunc *cb,
void *opaque, Error **errp); void *opaque, Error **errp);
......
...@@ -1010,6 +1010,9 @@ ...@@ -1010,6 +1010,9 @@
# Live commit of data from overlay image nodes into backing nodes - i.e., # Live commit of data from overlay image nodes into backing nodes - i.e.,
# writes data between 'top' and 'base' into 'base'. # writes data between 'top' and 'base' into 'base'.
# #
# @job-id: #optional identifier for the newly-created block job. If
# omitted, the device name will be used. (Since 2.7)
#
# @device: the name of the device # @device: the name of the device
# #
# @base: #optional The file name of the backing image to write data into. # @base: #optional The file name of the backing image to write data into.
...@@ -1061,7 +1064,7 @@ ...@@ -1061,7 +1064,7 @@
# #
## ##
{ 'command': 'block-commit', { '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' } } '*backing-file': 'str', '*speed': 'int' } }
## ##
......
...@@ -920,7 +920,7 @@ static int img_commit(int argc, char **argv) ...@@ -920,7 +920,7 @@ static int img_commit(int argc, char **argv)
.bs = bs, .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); common_block_job_cb, &cbi, &local_err);
if (local_err) { if (local_err) {
goto done; goto done;
......
...@@ -1151,7 +1151,7 @@ EQMP ...@@ -1151,7 +1151,7 @@ EQMP
{ {
.name = "block-commit", .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, .mhandler.cmd_new = qmp_marshal_block_commit,
}, },
...@@ -1164,6 +1164,8 @@ data between 'top' and 'base' into 'base'. ...@@ -1164,6 +1164,8 @@ data between 'top' and 'base' into 'base'.
Arguments: Arguments:
- "job-id": Identifier for the newly-created block job. If omitted,
the device name will be used. (json-string, optional)
- "device": The device's ID, must be unique (json-string) - "device": The device's ID, must be unique (json-string)
- "base": The file name of the backing image to write data into. - "base": The file name of the backing image to write data into.
If not specified, this is the deepest backing image If not specified, this is the deepest backing image
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册