[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 10/12] blockdev: add Abort transaction
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH v6 10/12] blockdev: add Abort transaction |
Date: |
Mon, 24 Jun 2013 17:13:18 +0200 |
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 <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
blockdev.c | 15 +++++++++++++++
qapi-schema.json | 13 ++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index 8caeac4..edca843 100644
--- a/blockdev.c
+++ b/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,
+ },
};
/*
diff --git a/qapi-schema.json b/qapi-schema.json
index f3f6ff6..d6479e1 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1652,6 +1652,16 @@
'*on-target-error': 'BlockdevOnError' } }
##
+# @Abort
+#
+# This action can be used to test transaction failure.
+#
+# Since: 1.6
+###
+{ 'type': 'Abort',
+ 'data': { } }
+
+##
# @TransactionAction
#
# A discriminated record of operations that can be performed with
@@ -1660,7 +1670,8 @@
{ 'union': 'TransactionAction',
'data': {
'blockdev-snapshot-sync': 'BlockdevSnapshot',
- 'drive-backup': 'DriveBackup'
+ 'drive-backup': 'DriveBackup',
+ 'abort': 'Abort'
} }
##
--
1.8.1.4
- [Qemu-devel] [PATCH v6 00/12] block: drive-backup live backup command, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 01/12] notify: add NotiferWithReturn so notifier list can abort, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 09/12] blockdev: add DriveBackup transaction, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 08/12] blockdev: allow BdrvActionOps->commit() to be NULL, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 03/12] block: add basic backup support to block driver, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 10/12] blockdev: add Abort transaction,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH v6 11/12] qemu-iotests: extract wait_until_completed() into iotests.py, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 05/12] blockdev: use bdrv_getlength() in qmp_drive_mirror(), Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 02/12] block: add bdrv_add_before_write_notifier(), Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 04/12] blockdev: drop redundant proto_drv check, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 06/12] block: add drive-backup QMP command, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 07/12] blockdev: rename BlkTransactionStates to singular, Stefan Hajnoczi, 2013/06/24
- [Qemu-devel] [PATCH v6 12/12] qemu-iotests: add 055 drive-backup test case, Stefan Hajnoczi, 2013/06/24
- Re: [Qemu-devel] [PATCH v6 00/12] block: drive-backup live backup command, Kevin Wolf, 2013/06/25