[Qemu-devel] [PATCH] commit: Replace commit_top_bs on failure after deleting the block job

Alberto Garcia posted 1 patch 5 years, 1 month ago
Test asan passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu failed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190215134932.14492-1-berto@igalia.com
Maintainers: Jeff Cody <jcody@redhat.com>, Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>
block/commit.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH] commit: Replace commit_top_bs on failure after deleting the block job
Posted by Alberto Garcia 5 years, 1 month ago
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>
---
 block/commit.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/commit.c b/block/commit.c
index 53148e610b..5deb05925b 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -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);
 }
 
 
-- 
2.11.0


Re: [Qemu-devel] [PATCH] commit: Replace commit_top_bs on failure after deleting the block job
Posted by Kevin Wolf 5 years, 1 month ago
Am 15.02.2019 um 14:49 hat Alberto Garcia geschrieben:
> 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>

Thanks, applied to the block branch.

Kevin