From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui254-0001HQ-AZ for qemu-devel@nongnu.org; Thu, 30 May 2013 08:35:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ui24w-00064b-Pb for qemu-devel@nongnu.org; Thu, 30 May 2013 08:35:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ui24w-00064J-FL for qemu-devel@nongnu.org; Thu, 30 May 2013 08:35:38 -0400 From: Stefan Hajnoczi Date: Thu, 30 May 2013 14:34:56 +0200 Message-Id: <1369917299-5725-9-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 08/11] blockdev: allow BdrvActionOps->commit() to be NULL 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 Some QMP 'transaction' types don't need to do anything on .commit(). Make .commit() optional just like .abort(). The "drive-backup" action will take advantage of this, it only needs to cancel the block job on .abort(). Other block job actions will probably follow the same pattern, so allow .commit() to be NULL. Suggested-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- blockdev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 94ad829..0e649df 100644 --- a/blockdev.c +++ b/blockdev.c @@ -789,7 +789,7 @@ typedef struct BdrvActionOps { size_t instance_size; /* Prepare the work, must NOT be NULL. */ void (*prepare)(BlkTransactionState *common, Error **errp); - /* Commit the changes, must NOT be NULL. */ + /* Commit the changes, can be NULL. */ void (*commit)(BlkTransactionState *common); /* Abort the changes on fail, can be NULL. */ void (*abort)(BlkTransactionState *common); @@ -969,7 +969,9 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp) } QSIMPLEQ_FOREACH(state, &snap_bdrv_states, entry) { - state->ops->commit(state); + if (state->ops->commit) { + state->ops->commit(state); + } } /* success */ -- 1.8.1.4