Received: from eggs.gnu.org ([2001:4830:134:3::10]:41119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsZcH-0005hq-9Y for qemu-devel@nongnu.org; Fri, 28 Jun 2013 10:25:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsZcB-0003rz-9t for qemu-devel@nongnu.org; Fri, 28 Jun 2013 10:25:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsZcB-0003rn-0t for qemu-devel@nongnu.org; Fri, 28 Jun 2013 10:25:31 -0400 From: Kevin Wolf Date: Fri, 28 Jun 2013 16:24:58 +0200 Message-Id: <1372429509-29642-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1372429509-29642-1-git-send-email-kwolf@redhat.com> References: <1372429509-29642-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 09/20] blockdev: allow BdrvActionOps->commit() to be NULL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Stefan Hajnoczi 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 Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- blockdev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 5312e60..0cf8081 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