commit: Make base read-only if there is an early failure
authorAlberto Garcia <berto@igalia.com>
Mon, 29 Apr 2019 13:51:08 +0000 (15:51 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 30 Apr 2019 13:29:00 +0000 (15:29 +0200)
You can reproduce this by passing an invalid filter-node-name (like
"1234") to block-commit. In this case the base image is put in
read-write mode but is never reset back to read-only.

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

index 08204fa6f88c25b9f3407f8fbace5dbee32bb1eb..27537d995b6050ebb2992e6833c2af77fbf331a7 100644 (file)
@@ -383,6 +383,9 @@ fail:
     if (s->top) {
         blk_unref(s->top);
     }
+    if (s->base_read_only) {
+        bdrv_reopen_set_read_only(base, true, NULL);
+    }
     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. */