[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 05/10] block: Fix blockdev-snapshot error handling
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH 05/10] block: Fix blockdev-snapshot error handling |
Date: |
Mon, 6 Mar 2017 17:21:57 +0100 |
For blockdev-snapshot, external_snapshot_prepare() accepts an arbitrary
node reference at first and only checks later whether it already has a
backing file. Between those places, other errors can occur.
Therefore checking in external_snapshot_abort() whether state->new_bs
has a backing file is not sufficient to tell whether bdrv_append() was
already completed or not. Trying to undo the bdrv_append() when it
wasn't even executed is wrong.
Introduce a new boolean flag in the state to fix this.
Signed-off-by: Kevin Wolf <address@hidden>
---
blockdev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index 8eb4e84..af67ce4 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1614,6 +1614,7 @@ typedef struct ExternalSnapshotState {
BlockDriverState *old_bs;
BlockDriverState *new_bs;
AioContext *aio_context;
+ bool overlay_appended;
} ExternalSnapshotState;
static void external_snapshot_prepare(BlkActionState *common,
@@ -1780,6 +1781,7 @@ static void external_snapshot_prepare(BlkActionState
*common,
error_propagate(errp, local_err);
return;
}
+ state->overlay_appended = true;
}
static void external_snapshot_commit(BlkActionState *common)
@@ -1803,7 +1805,7 @@ static void external_snapshot_abort(BlkActionState
*common)
ExternalSnapshotState *state =
DO_UPCAST(ExternalSnapshotState, common, common);
if (state->new_bs) {
- if (state->new_bs->backing) {
+ if (state->overlay_appended) {
bdrv_replace_in_backing_chain(state->new_bs, state->old_bs);
}
}
--
1.8.3.1
- [Qemu-block] [PATCH 00/10] block: Op blocker fixes, Kevin Wolf, 2017/03/06
- [Qemu-block] [PATCH 01/10] commit: Fix error handling, Kevin Wolf, 2017/03/06
- [Qemu-block] [PATCH 02/10] mirror: Fix permission problem with 'replaces', Kevin Wolf, 2017/03/06
- [Qemu-block] [PATCH 03/10] mirror: Fix permissions for removing mirror_top_bs, Kevin Wolf, 2017/03/06
- [Qemu-block] [PATCH 04/10] mirror: Fix error path for dirty bitmap creation, Kevin Wolf, 2017/03/06
- [Qemu-block] [PATCH 05/10] block: Fix blockdev-snapshot error handling,
Kevin Wolf <=
- [Qemu-block] [PATCH 06/10] block: Factor out should_update_child(), Kevin Wolf, 2017/03/06
- [Qemu-block] [PATCH 07/10] block: Factor out bdrv_replace_child_noperm(), Kevin Wolf, 2017/03/06
- [Qemu-block] [PATCH 08/10] block: Ignore multiple children in bdrv_check_update_perm(), Kevin Wolf, 2017/03/06
- [Qemu-block] [PATCH 09/10] block: Handle permission errors in change_parent_backing_link(), Kevin Wolf, 2017/03/06