From: Stefan Hajnoczi Date: Mon, 24 Jun 2013 15:13:16 +0000 (+0200) Subject: blockdev: allow BdrvActionOps->commit() to be NULL X-Git-Tag: v1.6.0-rc0~174^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9ea81e82519f44071b3dd617de98f0d6d6cca0a;p=thirdparty%2Fqemu.git blockdev: allow BdrvActionOps->commit() to be NULL 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 --- diff --git a/blockdev.c b/blockdev.c index 5312e6065f8..0cf80810f5c 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 */