Skip to contentSkip to conversation

commit: Make base read-only if there is an early failure

PATCH Superseded Alberto Garcia 2 participants 3 messages Apr 10, 2019 – Apr 11, 2019 Block layer

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 commit: Make base read-only if there is an early failure

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.

---
 block/commit.c | 3 +++
 1 file changed, 3 insertions(+)
block/commit.c +3 -0
index ba60fef58a..698eda1dfe 100644
@@ -384,6 +384,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. */
Signature · 1 line
2.11.0
#1 lore raw
Quoted 4 lines · Alberto Garcia

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.

Is it worth iotest coverage?

Quoted 20 lines
---
 block/commit.c | 3 +++
 1 file changed, 3 insertions(+)
block/commit.c +3 -0
index ba60fef58a..698eda1dfe 100644
@@ -384,6 +384,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. */
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 6 lines · Eric Blake
Quoted 3 lines · Alberto Garcia

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.

Is it worth iotest coverage?

I couldn't think of any way to reproduce this that would trigger an error on an iotest, but I think I have one now, I'll try to write something.

Berto