From: Stefan Hajnoczi Date: Mon, 24 Jun 2013 15:13:18 +0000 (+0200) Subject: blockdev: add Abort transaction X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~1656^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78b18b78aa89c28aecbd007ae1967c978d39bfd6;p=sdk%2Femulator%2Fqemu.git 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 Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- diff --git a/blockdev.c b/blockdev.c index 6200c0d..b3a57e0 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, + }, }; /* diff --git a/qapi-schema.json b/qapi-schema.json index 714108d..6590307 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1660,6 +1660,16 @@ '*on-target-error': 'BlockdevOnError' } } ## +# @Abort +# +# This action can be used to test transaction failure. +# +# Since: 1.6 +### +{ 'type': 'Abort', + 'data': { } } + +## # @TransactionAction # # A discriminated record of operations that can be performed with @@ -1668,7 +1678,8 @@ { 'union': 'TransactionAction', 'data': { 'blockdev-snapshot-sync': 'BlockdevSnapshot', - 'drive-backup': 'DriveBackup' + 'drive-backup': 'DriveBackup', + 'abort': 'Abort' } } ##