On 17.05.21 08:44, Vladimir Sementsov-Ogievskiy wrote:
We are going to publish copy-before-write filter, and there no public
backing-child-based filter in Qemu. No reason to create a precedent, so
let's refactor copy-before-write filter instead.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
---
block/copy-before-write.c | 40 ++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index af2bb97a30..2f06a524b8 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
[...]
@@ -201,22 +195,34 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState
*source,
state->target = bdrv_attach_child(top, target, "target", &child_of_bds,
BDRV_CHILD_DATA, errp);
if (!state->target) {
+ error_prepend(errp, "Cannot attach target child: ");
bdrv_unref(target);
bdrv_unref(top);
return NULL;
}
+ bdrv_ref(source);
+ top->file = bdrv_attach_child(top, source, "file", &child_of_bds,
+ BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY,
+ errp);
+ if (!top->file) {
+ error_prepend(errp, "Cannot attach file child: ");
+ bdrv_unref(source);
Already existing in the code above, but why is the reference to @source
dropped here? Shouldn’t bdrv_attach_child()’s error path have done that
already?
Max
+ bdrv_unref(top);
+ return NULL;
+ }