提交 78b18b78 编写于 作者: S Stefan Hajnoczi 提交者: Kevin Wolf

blockdev: add Abort transaction

The Abort action can be used to test QMP 'transaction' failure.  Add it
as the last action to exercise the .abort() and .cleanup() code paths
for all previous actions.
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 3037f364
......@@ -963,6 +963,16 @@ static void drive_backup_abort(BlkTransactionState *common)
}
}
static void abort_prepare(BlkTransactionState *common, Error **errp)
{
error_setg(errp, "Transaction aborted using Abort action");
}
static void abort_commit(BlkTransactionState *common)
{
assert(false); /* this action never succeeds */
}
static const BdrvActionOps actions[] = {
[TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = {
.instance_size = sizeof(ExternalSnapshotState),
......@@ -975,6 +985,11 @@ static const BdrvActionOps actions[] = {
.prepare = drive_backup_prepare,
.abort = drive_backup_abort,
},
[TRANSACTION_ACTION_KIND_ABORT] = {
.instance_size = sizeof(BlkTransactionState),
.prepare = abort_prepare,
.commit = abort_commit,
},
};
/*
......
......@@ -1659,6 +1659,16 @@
'*on-source-error': 'BlockdevOnError',
'*on-target-error': 'BlockdevOnError' } }
##
# @Abort
#
# This action can be used to test transaction failure.
#
# Since: 1.6
###
{ 'type': 'Abort',
'data': { } }
##
# @TransactionAction
#
......@@ -1668,7 +1678,8 @@
{ 'union': 'TransactionAction',
'data': {
'blockdev-snapshot-sync': 'BlockdevSnapshot',
'drive-backup': 'DriveBackup'
'drive-backup': 'DriveBackup',
'abort': 'Abort'
} }
##
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册