提交 c8a83e85 编写于 作者: K Kevin Wolf 提交者: Stefan Hajnoczi

blockdev: Rename BlockdevAction -> TransactionAction

There's no reason to restrict transactions to operations related to
block devices, so rename the type now before schema introspection stops
us from doing so.

Also change the schema documentation of 'transaction' to not refer to
block devices or snapshots any more.
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 ba0c86a3
...@@ -750,8 +750,8 @@ void do_commit(Monitor *mon, const QDict *qdict) ...@@ -750,8 +750,8 @@ void do_commit(Monitor *mon, const QDict *qdict)
static void blockdev_do_action(int kind, void *data, Error **errp) static void blockdev_do_action(int kind, void *data, Error **errp)
{ {
BlockdevAction action; TransactionAction action;
BlockdevActionList list; TransactionActionList list;
action.kind = kind; action.kind = kind;
action.data = data; action.data = data;
...@@ -773,8 +773,8 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file, ...@@ -773,8 +773,8 @@ void qmp_blockdev_snapshot_sync(const char *device, const char *snapshot_file,
.has_mode = has_mode, .has_mode = has_mode,
.mode = mode, .mode = mode,
}; };
blockdev_do_action(BLOCKDEV_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC, &snapshot, blockdev_do_action(TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC,
errp); &snapshot, errp);
} }
...@@ -803,7 +803,7 @@ typedef struct BdrvActionOps { ...@@ -803,7 +803,7 @@ typedef struct BdrvActionOps {
* Later it will be used in free(). * Later it will be used in free().
*/ */
struct BlkTransactionStates { struct BlkTransactionStates {
BlockdevAction *action; TransactionAction *action;
const BdrvActionOps *ops; const BdrvActionOps *ops;
QSIMPLEQ_ENTRY(BlkTransactionStates) entry; QSIMPLEQ_ENTRY(BlkTransactionStates) entry;
}; };
...@@ -828,10 +828,10 @@ static void external_snapshot_prepare(BlkTransactionStates *common, ...@@ -828,10 +828,10 @@ static void external_snapshot_prepare(BlkTransactionStates *common,
enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS; enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
ExternalSnapshotStates *states = ExternalSnapshotStates *states =
DO_UPCAST(ExternalSnapshotStates, common, common); DO_UPCAST(ExternalSnapshotStates, common, common);
BlockdevAction *action = common->action; TransactionAction *action = common->action;
/* get parameters */ /* get parameters */
g_assert(action->kind == BLOCKDEV_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC); g_assert(action->kind == TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
device = action->blockdev_snapshot_sync->device; device = action->blockdev_snapshot_sync->device;
new_image_file = action->blockdev_snapshot_sync->snapshot_file; new_image_file = action->blockdev_snapshot_sync->snapshot_file;
...@@ -927,7 +927,7 @@ static void external_snapshot_abort(BlkTransactionStates *common) ...@@ -927,7 +927,7 @@ static void external_snapshot_abort(BlkTransactionStates *common)
} }
static const BdrvActionOps actions[] = { static const BdrvActionOps actions[] = {
[BLOCKDEV_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = { [TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = {
.instance_size = sizeof(ExternalSnapshotStates), .instance_size = sizeof(ExternalSnapshotStates),
.prepare = external_snapshot_prepare, .prepare = external_snapshot_prepare,
.commit = external_snapshot_commit, .commit = external_snapshot_commit,
...@@ -940,9 +940,9 @@ static const BdrvActionOps actions[] = { ...@@ -940,9 +940,9 @@ static const BdrvActionOps actions[] = {
* then we do not pivot any of the devices in the group, and abandon the * then we do not pivot any of the devices in the group, and abandon the
* snapshots * snapshots
*/ */
void qmp_transaction(BlockdevActionList *dev_list, Error **errp) void qmp_transaction(TransactionActionList *dev_list, Error **errp)
{ {
BlockdevActionList *dev_entry = dev_list; TransactionActionList *dev_entry = dev_list;
BlkTransactionStates *states, *next; BlkTransactionStates *states, *next;
Error *local_err = NULL; Error *local_err = NULL;
...@@ -954,7 +954,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp) ...@@ -954,7 +954,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
/* We don't do anything in this loop that commits us to the snapshot */ /* We don't do anything in this loop that commits us to the snapshot */
while (NULL != dev_entry) { while (NULL != dev_entry) {
BlockdevAction *dev_info = NULL; TransactionAction *dev_info = NULL;
const BdrvActionOps *ops; const BdrvActionOps *ops;
dev_info = dev_entry->value; dev_info = dev_entry->value;
......
...@@ -1609,12 +1609,12 @@ ...@@ -1609,12 +1609,12 @@
'*mode': 'NewImageMode' } } '*mode': 'NewImageMode' } }
## ##
# @BlockdevAction # @TransactionAction
# #
# A discriminated record of operations that can be performed with # A discriminated record of operations that can be performed with
# @transaction. # @transaction.
## ##
{ 'union': 'BlockdevAction', { 'union': 'TransactionAction',
'data': { 'data': {
'blockdev-snapshot-sync': 'BlockdevSnapshot' 'blockdev-snapshot-sync': 'BlockdevSnapshot'
} } } }
...@@ -1622,25 +1622,24 @@ ...@@ -1622,25 +1622,24 @@
## ##
# @transaction # @transaction
# #
# Atomically operate on a group of one or more block devices. If # Executes a number of transactionable QMP commands atomically. If any
# any operation fails, then the entire set of actions will be # operation fails, then the entire set of actions will be abandoned and the
# abandoned and the appropriate error returned. The only operation # appropriate error returned.
# supported is currently blockdev-snapshot-sync.
# #
# List of: # List of:
# @BlockdevAction: information needed for the device snapshot # @TransactionAction: information needed for the respective operation
# #
# Returns: nothing on success # Returns: nothing on success
# If @device is not a valid block device, DeviceNotFound # Errors depend on the operations of the transaction
# #
# Note: The transaction aborts on the first failure. Therefore, there will # Note: The transaction aborts on the first failure. Therefore, there will be
# be only one device or snapshot file returned in an error condition, and # information on only one failed operation returned in an error condition, and
# subsequent actions will not have been attempted. # subsequent actions will not have been attempted.
# #
# Since 1.1 # Since 1.1
## ##
{ 'command': 'transaction', { 'command': 'transaction',
'data': { 'actions': [ 'BlockdevAction' ] } } 'data': { 'actions': [ 'TransactionAction' ] } }
## ##
# @blockdev-snapshot-sync # @blockdev-snapshot-sync
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册