]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
commit: Replace commit_top_bs on failure after deleting the block job
authorAlberto Garcia <berto@igalia.com>
Fri, 15 Feb 2019 13:49:32 +0000 (15:49 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 25 Feb 2019 14:03:19 +0000 (15:03 +0100)
If there's an error in commit_start() then the block job must be
deleted before replacing commit_top_bs, otherwise it will fail because
of lack of permissions. This happens since the permission system was
introduced in 8dfba2797761d8a43744e4e6571c8175e448a478.

Fortunately this bug doesn't seem to be possible to reproduce at the
moment without changing the code.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/commit.c

index 53148e610bceeca0bc52c1edad961c6fc0da3177..5deb05925b4e5e3fa896ac59a0ce5f24c6fdc02a 100644 (file)
@@ -374,10 +374,12 @@ fail:
     if (s->top) {
         blk_unref(s->top);
     }
+    job_early_fail(&s->common.job);
+    /* commit_top_bs has to be replaced after deleting the block job,
+     * otherwise this would fail because of lack of permissions. */
     if (commit_top_bs) {
         bdrv_replace_node(commit_top_bs, top, &error_abort);
     }
-    job_early_fail(&s->common.job);
 }