From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnSOX-00075D-AU for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnSOW-0006Ao-7Y for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:42:17 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:47623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnSON-0005sD-KC for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:42:16 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Jun 2013 21:39:09 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 830FD3578050 for ; Fri, 14 Jun 2013 21:41:47 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5EBR2iD5767570 for ; Fri, 14 Jun 2013 21:27:02 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5EBfkMu026396 for ; Fri, 14 Jun 2013 21:41:46 +1000 From: Wenchao Xia Date: Fri, 14 Jun 2013 19:39:50 +0800 Message-Id: <1371209999-15579-4-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1371209999-15579-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1371209999-15579-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V2 03/12] 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: kwolf@redhat.com, phrdina@redhat.com, famz@redhat.com, Wenchao Xia , armbru@redhat.com, lcapitulino@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com 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 Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Wenchao Xia Signed-off-by: Wenchao Xia --- blockdev.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 46a43b0..4bd6cbc 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.7.1