From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui256-0001HT-E1 for qemu-devel@nongnu.org; Thu, 30 May 2013 08:36:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ui24x-00064z-CT for qemu-devel@nongnu.org; Thu, 30 May 2013 08:35:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui24x-00064j-2X for qemu-devel@nongnu.org; Thu, 30 May 2013 08:35:39 -0400 From: Stefan Hajnoczi Date: Thu, 30 May 2013 14:34:58 +0200 Message-Id: <1369917299-5725-11-git-send-email-stefanha@redhat.com> In-Reply-To: <1369917299-5725-1-git-send-email-stefanha@redhat.com> References: <1369917299-5725-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v5 10/11] blockdev: add Abort transaction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , xiawenc@linux.vnet.ibm.com, imain@redhat.com, Stefan Hajnoczi , Paolo Bonzini , dietmar@proxmox.com 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. Signed-off-by: Stefan Hajnoczi --- blockdev.c | 15 +++++++++++++++ qapi-schema.json | 13 ++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 18a2012..e3393d2 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 6bf96aa..0da1b98 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1646,6 +1646,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 @@ -1654,7 +1664,8 @@ { 'union': 'TransactionAction', 'data': { 'blockdev-snapshot-sync': 'BlockdevSnapshot', - 'drive-backup': 'DriveBackup' + 'drive-backup': 'DriveBackup', + 'abort': 'Abort' } } ## -- 1.8.1.4