This interface allow user to create internal snapshot on a single block device.
Signed-off-by: Wenchao Xia <xiaw...@linux.vnet.ibm.com> --- blockdev.c | 14 ++++++++++++++ qapi-schema.json | 21 ++++++++++++++++++++- qmp-commands.hx | 28 ++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletions(-) diff --git a/blockdev.c b/blockdev.c index 09eeb7f..b2e6b3d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1173,6 +1173,20 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, errp); } +void qmp_blockdev_snapshot_internal_sync(const char *device, + bool has_name, const char *name, + Error **errp) +{ + BlockdevSnapshotInternal snapshot = { + .device = (char *) device, + .has_name = has_name, + .name = (char *) name, + }; + blockdev_do_action(BLOCKDEV_ACTION_KIND_BLOCKDEV_SNAPSHOT_INTERNAL_SYNC, + &snapshot, + errp); +} + /* translation from qmp commands */ static int fill_blk_trs_ext_create_sync(BlockdevSnapshot *create_sync, BlkTransStatesSync *st_sync, diff --git a/qapi-schema.json b/qapi-schema.json index ea3ef77..459850a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1555,7 +1555,7 @@ ## # @blockdev-snapshot-sync # -# Generates a synchronous snapshot of a block device. +# Generates a synchronous external snapshot of a block device. # # @device: the name of the device to generate the snapshot from. # @@ -1578,6 +1578,25 @@ '*mode': 'NewImageMode'} } ## +# @blockdev-snapshot-internal-sync +# +# Generates a synchronous internal snapshot of a block device. +# +# @device: the name of the device to generate the snapshot from. +# +# @name: #optional the name of snapshot to be created. If not specified, a name +# would be generated according to host time. If an internal snapshot with +# name exist, it will be overwritten. +# +# Returns: nothing on success +# If @device is not a valid block device, DeviceNotFound +# +# Since 1.4 +## +{ 'command': 'blockdev-snapshot-internal-sync', + 'data': { 'device': 'str', '*name': 'str'} } + +## # @human-monitor-command: # # Execute a command on the human monitor and return the output. diff --git a/qmp-commands.hx b/qmp-commands.hx index 3c2f468..499e64e 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -946,6 +946,34 @@ Example: EQMP { + .name = "blockdev-snapshot-internal-sync", + .args_type = "device:B,name:s?", + .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_internal_sync, + }, + +SQMP +blockdev-snapshot-internal-sync +---------------------- + +Synchronous snapshot of a block device. name specifies the internal snapshot +name. If it is not specified, a name would be generated according to host time. +If a snapshot with that name already exist, it will be overwritten. + +Arguments: + +- "device": device name to snapshot (json-string) +- "name": name of internal snapshot (json-string, optional) + +Example: + +-> { "execute": "blockdev-snapshot-internal-sync", "arguments": { + "device": "ide-hd0", + "name": "snapshot1" } } +<- { "return": {} } + +EQMP + + { .name = "drive-mirror", .args_type = "sync:s,device:B,target:s,speed:i?,mode:s?,format:s?," "on-source-error:s?,on-target-error:s?", -- 1.7.1