mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-30 21:42:06 -06:00
blockdev: add Abort transaction
The Abort action can be used to test QMP 'transaction' failure. Add it as the last action to exercise the .abort() and .cleanup() code paths for all previous actions. Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
3037f36446
commit
78b18b78aa
2 changed files with 27 additions and 1 deletions
15
blockdev.c
15
blockdev.c
|
@ -963,6 +963,16 @@ static void drive_backup_abort(BlkTransactionState *common)
|
|||
}
|
||||
}
|
||||
|
||||
static void abort_prepare(BlkTransactionState *common, Error **errp)
|
||||
{
|
||||
error_setg(errp, "Transaction aborted using Abort action");
|
||||
}
|
||||
|
||||
static void abort_commit(BlkTransactionState *common)
|
||||
{
|
||||
assert(false); /* this action never succeeds */
|
||||
}
|
||||
|
||||
static const BdrvActionOps actions[] = {
|
||||
[TRANSACTION_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC] = {
|
||||
.instance_size = sizeof(ExternalSnapshotState),
|
||||
|
@ -975,6 +985,11 @@ static const BdrvActionOps actions[] = {
|
|||
.prepare = drive_backup_prepare,
|
||||
.abort = drive_backup_abort,
|
||||
},
|
||||
[TRANSACTION_ACTION_KIND_ABORT] = {
|
||||
.instance_size = sizeof(BlkTransactionState),
|
||||
.prepare = abort_prepare,
|
||||
.commit = abort_commit,
|
||||
},
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue