[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-5.0 24/31] block: Use child_of_bds in remaining places
From: |
Max Reitz |
Subject: |
[PATCH for-5.0 24/31] block: Use child_of_bds in remaining places |
Date: |
Wed, 27 Nov 2019 14:16:17 +0100 |
Replace child_file by child_of_bds in all remaining places (excluding
tests).
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 3 ++-
block/backup-top.c | 4 ++--
block/blklogwrites.c | 3 ++-
block/blkreplay.c | 5 +++--
block/raw-format.c | 16 ++++++++++++++--
5 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/block.c b/block.c
index 0530c81c6d..e800ce862e 100644
--- a/block.c
+++ b/block.c
@@ -3182,7 +3182,8 @@ static BlockDriverState *bdrv_open_inherit(const char
*filename,
BlockDriverState *file_bs;
file_bs = bdrv_open_child_bs(filename, options, "file", bs,
- &child_file, 0, true, &local_err);
+ &child_of_bds, BDRV_CHILD_IMAGE,
+ true, &local_err);
if (local_err) {
goto fail;
}
diff --git a/block/backup-top.c b/block/backup-top.c
index ce97c0146a..eccd6bfae0 100644
--- a/block/backup-top.c
+++ b/block/backup-top.c
@@ -200,8 +200,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState
*source,
top->opaque = state = g_new0(BDRVBackupTopState, 1);
bdrv_ref(target);
- state->target = bdrv_attach_child(top, target, "target", &child_file, 0,
- errp);
+ state->target = bdrv_attach_child(top, target, "target", &child_of_bds,
+ BDRV_CHILD_DATA, errp);
if (!state->target) {
bdrv_unref(target);
bdrv_unref(top);
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 78b0c49460..3ee991b38e 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -167,7 +167,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict
*options, int flags,
}
/* Open the log file */
- s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, 0,
+ s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_of_bds,
+ BDRV_CHILD_METADATA | BDRV_CHILD_PROTOCOL,
false, &local_err);
if (local_err) {
ret = -EINVAL;
diff --git a/block/blkreplay.c b/block/blkreplay.c
index f97493f45a..71628f4d56 100644
--- a/block/blkreplay.c
+++ b/block/blkreplay.c
@@ -27,8 +27,9 @@ static int blkreplay_open(BlockDriverState *bs, QDict
*options, int flags,
int ret;
/* Open the image file */
- bs->file = bdrv_open_child(NULL, options, "image",
- bs, &child_file, 0, false, &local_err);
+ bs->file = bdrv_open_child(NULL, options, "image", bs, &child_of_bds,
+ BDRV_CHILD_DATA | BDRV_CHILD_PRIMARY,
+ false, &local_err);
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
diff --git a/block/raw-format.c b/block/raw-format.c
index 4d47e59b7a..6c46dee996 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -444,6 +444,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);
@@ -451,8 +452,19 @@ 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_PROTOCOL | BDRV_CHILD_PRIMARY;
+ } else {
+ file_role = BDRV_CHILD_FILTERED | BDRV_CHILD_PROTOCOL |
+ BDRV_CHILD_PRIMARY;
+ }
+
+ bs->file = bdrv_open_child(NULL, options, "file", bs, &child_of_bds,
+ file_role, false, errp);
if (!bs->file) {
return -EINVAL;
}
--
2.23.0
- [PATCH for-5.0 12/31] block: Distinguish paths in *_format_default_perms, (continued)
- [PATCH for-5.0 12/31] block: Distinguish paths in *_format_default_perms, Max Reitz, 2019/11/27
- [PATCH for-5.0 10/31] block: Unify bdrv_child_cb_detach(), Max Reitz, 2019/11/27
- [PATCH for-5.0 13/31] block: Pull out bdrv_default_perms_for_backing(), Max Reitz, 2019/11/27
- [PATCH for-5.0 17/31] raw-format: Split raw_read_options(), Max Reitz, 2019/11/27
- [PATCH for-5.0 16/31] block: Add bdrv_default_perms(), Max Reitz, 2019/11/27
- [PATCH for-5.0 20/31] block: Make backing files child_of_bds children, Max Reitz, 2019/11/27
- [PATCH for-5.0 19/31] block: Drop child_format, Max Reitz, 2019/11/27
- [PATCH for-5.0 21/31] block: Drop child_backing, Max Reitz, 2019/11/27
- [PATCH for-5.0 23/31] block: Make filter drivers use child_of_bds, Max Reitz, 2019/11/27
- [PATCH for-5.0 22/31] block: Make format drivers use child_of_bds, Max Reitz, 2019/11/27
- [PATCH for-5.0 24/31] block: Use child_of_bds in remaining places,
Max Reitz <=
- [PATCH for-5.0 25/31] tests: Use child_of_bds instead of child_file, Max Reitz, 2019/11/27
- [PATCH for-5.0 26/31] block: Use bdrv_default_perms(), Max Reitz, 2019/11/27
- [PATCH for-5.0 27/31] block: Make bdrv_filter_default_perms() static, Max Reitz, 2019/11/27
- [PATCH for-5.0 29/31] block: Drop child_file, Max Reitz, 2019/11/27
- [PATCH for-5.0 30/31] block: Pass BdrvChildRole in remaining cases, Max Reitz, 2019/11/27
- [PATCH for-5.0 28/31] block: Drop bdrv_format_default_perms(), Max Reitz, 2019/11/27
- [PATCH for-5.0 31/31] block: Drop @child_class from bdrv_child_perm(), Max Reitz, 2019/11/27
- [PATCH for-5.0 18/31] block: Switch child_format users to child_of_bds, Max Reitz, 2019/11/27