提交 4c828dc6 编写于 作者: B Benoît Canet 提交者: Kevin Wolf

block: Add node-name argument to drive-mirror

This new argument can be used to specify the node-name of the new mirrored BDS.
Signed-off-by: NBenoit Canet <benoit@irqsave.net>
Reviewed-by: NMax Reitz <mreitz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 cf29a570
...@@ -2099,6 +2099,7 @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp) ...@@ -2099,6 +2099,7 @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp)
void qmp_drive_mirror(const char *device, const char *target, void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format, bool has_format, const char *format,
bool has_node_name, const char *node_name,
enum MirrorSyncMode sync, enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode, bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed, bool has_speed, int64_t speed,
...@@ -2112,6 +2113,7 @@ void qmp_drive_mirror(const char *device, const char *target, ...@@ -2112,6 +2113,7 @@ void qmp_drive_mirror(const char *device, const char *target,
BlockDriverState *source, *target_bs; BlockDriverState *source, *target_bs;
BlockDriver *drv = NULL; BlockDriver *drv = NULL;
Error *local_err = NULL; Error *local_err = NULL;
QDict *options = NULL;
int flags; int flags;
int64_t size; int64_t size;
int ret; int ret;
...@@ -2213,12 +2215,17 @@ void qmp_drive_mirror(const char *device, const char *target, ...@@ -2213,12 +2215,17 @@ void qmp_drive_mirror(const char *device, const char *target,
return; return;
} }
if (has_node_name) {
options = qdict_new();
qdict_put(options, "node-name", qstring_from_str(node_name));
}
/* Mirroring takes care of copy-on-write using the source's backing /* Mirroring takes care of copy-on-write using the source's backing
* file. * file.
*/ */
target_bs = NULL; target_bs = NULL;
ret = bdrv_open(&target_bs, target, NULL, NULL, flags | BDRV_O_NO_BACKING, ret = bdrv_open(&target_bs, target, NULL, options,
drv, &local_err); flags | BDRV_O_NO_BACKING, drv, &local_err);
if (ret < 0) { if (ret < 0) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
return; return;
......
...@@ -933,6 +933,7 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict) ...@@ -933,6 +933,7 @@ void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
} }
qmp_drive_mirror(device, filename, !!format, format, qmp_drive_mirror(device, filename, !!format, format,
false, NULL,
full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
true, mode, false, 0, false, 0, false, 0, true, mode, false, 0, false, 0, false, 0,
false, 0, false, 0, &err); false, 0, false, 0, &err);
......
...@@ -765,6 +765,9 @@ ...@@ -765,6 +765,9 @@
# @format: #optional the format of the new destination, default is to # @format: #optional the format of the new destination, default is to
# probe if @mode is 'existing', else the format of the source # probe if @mode is 'existing', else the format of the source
# #
# @node-name: #optional the new block driver state node name in the graph
# (Since 2.1)
#
# @mode: #optional whether and how QEMU should create a new image, default is # @mode: #optional whether and how QEMU should create a new image, default is
# 'absolute-paths'. # 'absolute-paths'.
# #
...@@ -797,6 +800,7 @@ ...@@ -797,6 +800,7 @@
## ##
{ 'command': 'drive-mirror', { 'command': 'drive-mirror',
'data': { 'device': 'str', 'target': 'str', '*format': 'str', 'data': { 'device': 'str', 'target': 'str', '*format': 'str',
'*node-name': 'str',
'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode',
'*speed': 'int', '*granularity': 'uint32', '*speed': 'int', '*granularity': 'uint32',
'*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError',
......
...@@ -1293,6 +1293,7 @@ EQMP ...@@ -1293,6 +1293,7 @@ EQMP
{ {
.name = "drive-mirror", .name = "drive-mirror",
.args_type = "sync:s,device:B,target:s,speed:i?,mode:s?,format:s?," .args_type = "sync:s,device:B,target:s,speed:i?,mode:s?,format:s?,"
"node-name:s?,"
"on-source-error:s?,on-target-error:s?," "on-source-error:s?,on-target-error:s?,"
"granularity:i?,buf-size:i?", "granularity:i?,buf-size:i?",
.mhandler.cmd_new = qmp_marshal_input_drive_mirror, .mhandler.cmd_new = qmp_marshal_input_drive_mirror,
...@@ -1314,6 +1315,8 @@ Arguments: ...@@ -1314,6 +1315,8 @@ Arguments:
- "device": device name to operate on (json-string) - "device": device name to operate on (json-string)
- "target": name of new image file (json-string) - "target": name of new image file (json-string)
- "format": format of new image (json-string, optional) - "format": format of new image (json-string, optional)
- "node-name": the name of the new block driver state in the node graph
(json-string, optional)
- "mode": how an image file should be created into the target - "mode": how an image file should be created into the target
file/device (NewImageMode, optional, default 'absolute-paths') file/device (NewImageMode, optional, default 'absolute-paths')
- "speed": maximum speed of the streaming job, in bytes per second - "speed": maximum speed of the streaming job, in bytes per second
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册