aboutsummaryrefslogtreecommitdiff
path: root/block/raw-format.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2020-05-13 13:05:37 +0200
committerKevin Wolf <kwolf@redhat.com>2020-05-18 19:05:25 +0200
commit58944401d661f22fef15af5a0270ef808a1f4791 (patch)
tree54fd40d68c18fad4f455c4ab42037da1c2610774 /block/raw-format.c
parentb3af2af43b2bf85191cf40fa84b33df1268a08fd (diff)
block: Use child_of_bds in remaining places
Replace child_file by child_of_bds in all remaining places (excluding tests). Signed-off-by: Max Reitz <mreitz@redhat.com> Message-Id: <20200513110544.176672-28-mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/raw-format.c')
-rw-r--r--block/raw-format.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/block/raw-format.c b/block/raw-format.c
index 824fe70686..bfb4d7ddb7 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -441,6 +441,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
BDRVRawState *s = bs->opaque;
bool has_size;
uint64_t offset, size;
+ BdrvChildRole file_role;
int ret;
ret = raw_read_options(options, &offset, &has_size, &size, errp);
@@ -448,8 +449,18 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
return ret;
}
- bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
- false, errp);
+ /*
+ * Without offset and a size limit, this driver behaves very much
+ * like a filter. With any such limit, it does not.
+ */
+ if (offset || has_size) {
+ file_role = BDRV_CHILD_DATA | BDRV_CHILD_PRIMARY;
+ } else {
+ file_role = BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY;
+ }
+
+ bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
+ file_role, false, errp);
if (!bs->file) {
return -EINVAL;
}