diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2013-06-24 17:13:18 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-06-28 09:20:27 +0200 |
commit | 78b18b78aa89c28aecbd007ae1967c978d39bfd6 (patch) | |
tree | 52587c44800847e92f66553cab88bddeec7ccd40 /blockdev.c | |
parent | 3037f36446eb3556c14757ac468463c3902f331b (diff) |
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: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c index 6200c0dc0a..b3a57e0c1d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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, + }, }; /* |