[PULL,25/27] commit: Make base read-only if there is an early failure
diff mbox series

Message ID 20190430154244.30083-26-kwolf@redhat.com
State New
Headers show
Series
  • [PULL,01/27] tests/qemu-iotests: Fix output of qemu-io related tests
Related show

Commit Message

Kevin Wolf April 30, 2019, 3:42 p.m. UTC
From: Alberto Garcia <berto@igalia.com>

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 | 3 +++
 1 file changed, 3 insertions(+)

Patch
diff mbox series

diff --git a/block/commit.c b/block/commit.c
index 08204fa6f8..27537d995b 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -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. */