[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 7/8] blockdev: add Abort transaction
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH v3 7/8] blockdev: add Abort transaction |
Date: |
Wed, 15 May 2013 16:34:35 +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.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
blockdev.c | 15 +++++++++++++++
qapi-schema.json | 11 ++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index c386bb6..fcce219 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -973,6 +973,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),
@@ -986,6 +996,11 @@ static const BdrvActionOps actions[] = {
.commit = drive_backup_commit,
.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 9ca9352..15221a5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1630,6 +1630,14 @@
'*mode': 'NewImageMode', '*speed': 'int' } }
##
+# @Abort
+#
+# This action can be used to test transaction failure.
+###
+{ 'type': 'Abort',
+ 'data': { } }
+
+##
# @TransactionAction
#
# A discriminated record of operations that can be performed with
@@ -1638,7 +1646,8 @@
{ 'union': 'TransactionAction',
'data': {
'blockdev-snapshot-sync': 'BlockdevSnapshot',
- 'drive-backup': 'DriveBackup'
+ 'drive-backup': 'DriveBackup',
+ 'abort': 'Abort'
} }
##
--
1.8.1.4
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, (continued)
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Stefan Hajnoczi, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Paolo Bonzini, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Dietmar Maurer, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Paolo Bonzini, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Dietmar Maurer, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Paolo Bonzini, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Dietmar Maurer, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Dietmar Maurer, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Paolo Bonzini, 2013/05/21
- Re: [Qemu-devel] [PATCH v3 2/8] block: add basic backup support to block driver, Stefan Hajnoczi, 2013/05/22
[Qemu-devel] [PATCH v3 7/8] blockdev: add Abort transaction,
Stefan Hajnoczi <=
Re: [Qemu-devel] [PATCH v3 0/8] block: drive-backup live backup command, Wenchao Xia, 2013/05/16
Re: [Qemu-devel] [PATCH v3 0/8] block: drive-backup live backup command, Paolo Bonzini, 2013/05/17