From patchwork Thu May 16 08:36:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 244246 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 913122C009D for ; Thu, 16 May 2013 18:39:20 +1000 (EST) Received: from localhost ([::1]:45108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UctiX-0004dV-4y for incoming@patchwork.ozlabs.org; Thu, 16 May 2013 04:39:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UctiD-0004cU-Ls for qemu-devel@nongnu.org; Thu, 16 May 2013 04:39:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uctg8-00014R-6Z for qemu-devel@nongnu.org; Thu, 16 May 2013 04:37:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uctg7-00014I-QX for qemu-devel@nongnu.org; Thu, 16 May 2013 04:36:48 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4G8ajS4021997 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 16 May 2013 04:36:45 -0400 Received: from localhost (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4G8aiKJ013351; Thu, 16 May 2013 04:36:44 -0400 From: Stefan Hajnoczi To: Date: Thu, 16 May 2013 10:36:18 +0200 Message-Id: <1368693379-8434-8-git-send-email-stefanha@redhat.com> In-Reply-To: <1368693379-8434-1-git-send-email-stefanha@redhat.com> References: <1368693379-8434-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , dietmar@proxmox.com, imain@redhat.com, Stefan Hajnoczi , Paolo Bonzini , xiawenc@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v4 7/8] blockdev: add Abort transaction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Eric Blake --- blockdev.c | 15 +++++++++++++++ qapi-schema.json | 13 ++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index c386bb6..fcce219 100644 --- a/blockdev.c +++ b/blockdev.c @@ -973,6 +973,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), @@ -986,6 +996,11 @@ static const BdrvActionOps actions[] = { .commit = drive_backup_commit, .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 114ae50..ac7bb0b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1632,6 +1632,16 @@ '*mode': 'NewImageMode', '*speed': 'int' } } ## +# @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 @@ -1640,7 +1650,8 @@ { 'union': 'TransactionAction', 'data': { 'blockdev-snapshot-sync': 'BlockdevSnapshot', - 'drive-backup': 'DriveBackup' + 'drive-backup': 'DriveBackup', + 'abort': 'Abort' } } ##