From patchwork Sat Jun 8 06:57:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 249925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 055562C02CF for ; Sat, 8 Jun 2013 17:03:01 +1000 (EST) Received: from localhost ([::1]:46160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlDAx-00060d-33 for incoming@patchwork.ozlabs.org; Sat, 08 Jun 2013 03:02:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlD9C-0003dS-Hf for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UlD9B-0000Wd-L6 for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:10 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:49030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlD9B-0000WO-22 for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:09 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 9 Jun 2013 03:57:53 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 9 Jun 2013 03:57:52 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 26E062CE804D for ; Sat, 8 Jun 2013 17:01:03 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5870sLU27787294 for ; Sat, 8 Jun 2013 17:00:54 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r587124h026177 for ; Sat, 8 Jun 2013 17:01:02 +1000 Received: from RH63Wenchao.localdomain ([9.125.31.72]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r586w9Iv018747; Sat, 8 Jun 2013 17:01:00 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Sat, 8 Jun 2013 14:57:59 +0800 Message-Id: <1370674687-13849-4-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1370674687-13849-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1370674687-13849-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13060817-3568-0000-0000-000003BD3874 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.142 Cc: kwolf@redhat.com, phrdina@redhat.com, armbru@redhat.com, lcapitulino@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com Subject: [Qemu-devel] [PATCH 03/11] blockdev: allow BdrvActionOps->commit() to be NULL 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 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 --- 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 */