[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 35/64] block: Use CAFs in bdrv_refresh_filename()
From: |
Kevin Wolf |
Subject: |
[PULL 35/64] block: Use CAFs in bdrv_refresh_filename() |
Date: |
Mon, 7 Sep 2020 13:09:07 +0200 |
From: Max Reitz <mreitz@redhat.com>
bdrv_refresh_filename() and the kind of related bdrv_dirname() should
look to the primary child when they wish to copy the underlying file's
filename.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/block.c b/block.c
index 660386795a..ed29d1edb4 100644
--- a/block.c
+++ b/block.c
@@ -6822,6 +6822,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
BdrvChild *child;
+ BlockDriverState *primary_child_bs;
QDict *opts;
bool backing_overridden;
bool generate_json_filename; /* Whether our default implementation should
@@ -6891,20 +6892,30 @@ void bdrv_refresh_filename(BlockDriverState *bs)
qobject_unref(bs->full_open_options);
bs->full_open_options = opts;
+ primary_child_bs = bdrv_primary_bs(bs);
+
if (drv->bdrv_refresh_filename) {
/* Obsolete information is of no use here, so drop the old file name
* information before refreshing it */
bs->exact_filename[0] = '\0';
drv->bdrv_refresh_filename(bs);
- } else if (bs->file) {
- /* Try to reconstruct valid information from the underlying file */
+ } else if (primary_child_bs) {
+ /*
+ * Try to reconstruct valid information from the underlying
+ * file -- this only works for format nodes (filter nodes
+ * cannot be probed and as such must be selected by the user
+ * either through an options dict, or through a special
+ * filename which the filter driver must construct in its
+ * .bdrv_refresh_filename() implementation).
+ */
bs->exact_filename[0] = '\0';
/*
* We can use the underlying file's filename if:
* - it has a filename,
+ * - the current BDS is not a filter,
* - the file is a protocol BDS, and
* - opening that file (as this BDS's format) will automatically create
* the BDS tree we have right now, that is:
@@ -6913,11 +6924,11 @@ void bdrv_refresh_filename(BlockDriverState *bs)
* - no non-file child of this BDS has been overridden by the user
* Both of these conditions are represented by
generate_json_filename.
*/
- if (bs->file->bs->exact_filename[0] &&
- bs->file->bs->drv->bdrv_file_open &&
- !generate_json_filename)
+ if (primary_child_bs->exact_filename[0] &&
+ primary_child_bs->drv->bdrv_file_open &&
+ !drv->is_filter && !generate_json_filename)
{
- strcpy(bs->exact_filename, bs->file->bs->exact_filename);
+ strcpy(bs->exact_filename, primary_child_bs->exact_filename);
}
}
@@ -6937,6 +6948,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)
char *bdrv_dirname(BlockDriverState *bs, Error **errp)
{
BlockDriver *drv = bs->drv;
+ BlockDriverState *child_bs;
if (!drv) {
error_setg(errp, "Node '%s' is ejected", bs->node_name);
@@ -6947,8 +6959,9 @@ char *bdrv_dirname(BlockDriverState *bs, Error **errp)
return drv->bdrv_dirname(bs, errp);
}
- if (bs->file) {
- return bdrv_dirname(bs->file->bs, errp);
+ child_bs = bdrv_primary_bs(bs);
+ if (child_bs) {
+ return bdrv_dirname(child_bs, errp);
}
bdrv_refresh_filename(bs);
--
2.25.4
- [PULL 25/64] copy-on-read: Support compressed writes, (continued)
- [PULL 25/64] copy-on-read: Support compressed writes, Kevin Wolf, 2020/09/07
- [PULL 28/64] stream: Deal with filters, Kevin Wolf, 2020/09/07
- [PULL 30/64] block: Use bdrv_cow_child() in bdrv_co_truncate(), Kevin Wolf, 2020/09/07
- [PULL 31/64] block: Re-evaluate backing file handling in reopen, Kevin Wolf, 2020/09/07
- [PULL 29/64] block: Use CAFs when working with backing chains, Kevin Wolf, 2020/09/07
- [PULL 38/64] block: Use CAFs for debug breakpoints, Kevin Wolf, 2020/09/07
- [PULL 32/64] block: Flush all children in generic code, Kevin Wolf, 2020/09/07
- [PULL 39/64] block: Improve get_allocated_file_size's default, Kevin Wolf, 2020/09/07
- [PULL 40/64] block/null: Implement bdrv_get_allocated_file_size, Kevin Wolf, 2020/09/07
- [PULL 34/64] block: Iterate over children in refresh_limits, Kevin Wolf, 2020/09/07
- [PULL 35/64] block: Use CAFs in bdrv_refresh_filename(),
Kevin Wolf <=
- [PULL 41/64] blockdev: Use CAF in external_snapshot_prepare(), Kevin Wolf, 2020/09/07
- [PULL 36/64] block: Use CAF in bdrv_co_rw_vmstate(), Kevin Wolf, 2020/09/07
- [PULL 43/64] block: Use child access functions for QAPI queries, Kevin Wolf, 2020/09/07
- [PULL 33/64] vmdk: Drop vmdk_co_flush(), Kevin Wolf, 2020/09/07
- [PULL 45/64] mirror: Deal with filters, Kevin Wolf, 2020/09/07
- [PULL 48/64] nbd: Use CAF when looking for dirty bitmap, Kevin Wolf, 2020/09/07
- [PULL 46/64] backup: Deal with filters, Kevin Wolf, 2020/09/07
- [PULL 51/64] blockdev: Fix active commit choice, Kevin Wolf, 2020/09/07
- [PULL 47/64] commit: Deal with filters, Kevin Wolf, 2020/09/07
- [PULL 49/64] qemu-img: Use child access functions, Kevin Wolf, 2020/09/07