@@ -4339,9 +4339,13 @@ int bdrv_is_snapshot(BlockDriverState *bs)
/* backing_file can either be relative, or absolute, or a protocol. If it is
* relative, it must be relative to the chain. So, passing in bs->filename
* from a BDS as backing_file should not be done, as that may be relative to
- * the CWD rather than the chain. */
+ * the CWD rather than the chain.
+ * If a multiple children BDS driver is found down the backing chain path then
+ * return NULL and set an error message.
+ */
BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
- const char *backing_file)
+ const char *backing_file,
+ Error **errp)
{
char *filename_full = NULL;
char *backing_file_full = NULL;
@@ -4362,6 +4366,15 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
for (curr_bs = bs; curr_bs->backing_hd; curr_bs = curr_bs->backing_hd) {
+ /* If a BDS having a multiple children block driver is found then the
+ * function should fail.
+ */
+ if (curr_bs->drv && curr_bs->drv->supports_multiple_children) {
+ error_setg(errp, "multiple children block driver found down the "
+ "backing chain");
+ break;
+ }
+
/* If either of the filename paths is actually a protocol, then
* compare unmodified paths; otherwise make paths relative */
if (is_protocol || path_has_protocol(curr_bs->backing_file)) {
@@ -1894,9 +1894,11 @@ void qmp_block_stream(const char *device,
}
if (has_base) {
- base_bs = bdrv_find_backing_image(bs, base);
+ base_bs = bdrv_find_backing_image(bs, base, errp);
if (base_bs == NULL) {
- error_set(errp, QERR_BASE_NOT_FOUND, base);
+ if (!*errp) {
+ error_set(errp, QERR_BASE_NOT_FOUND, base);
+ }
return;
}
base_name = base;
@@ -1965,23 +1967,27 @@ void qmp_block_commit(const char *device,
if (has_top && top) {
if (strcmp(bs->filename, top) != 0) {
- top_bs = bdrv_find_backing_image(bs, top);
+ top_bs = bdrv_find_backing_image(bs, top, errp);
}
}
if (top_bs == NULL) {
- error_setg(errp, "Top image file %s not found", top ? top : "NULL");
+ if (!*errp) {
+ error_setg(errp, "Top image file %s not found", top ? top : "NULL");
+ }
return;
}
if (has_base && base) {
- base_bs = bdrv_find_backing_image(top_bs, base);
+ base_bs = bdrv_find_backing_image(top_bs, base, errp);
} else {
base_bs = bdrv_find_base(top_bs);
}
if (base_bs == NULL) {
- error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
+ if (!*errp) {
+ error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL");
+ }
return;
}
@@ -272,7 +272,8 @@ int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, BdrvRequestFlags flags);
BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
- const char *backing_file);
+ const char *backing_file,
+ Error **errp);
int bdrv_get_backing_file_depth(BlockDriverState *bs);
void bdrv_refresh_filename(BlockDriverState *bs);
int bdrv_truncate(BlockDriverState *bs, int64_t offset);
In bdrv_find_backing_image when looking for the base BDS of a backing chain and a BDS having a multiple children block driver is found return NULL and set an error message. This will hopefully remove any unwanted interference between stream, commit and drivers like quorum. CC: Jeff Cody <jcody@redhat.com> Signed-off-by: Benoît Canet <benoit.canet@nodalink.com> --- block.c | 17 +++++++++++++++-- blockdev.c | 18 ++++++++++++------ include/block/block.h | 3 ++- 3 files changed, 29 insertions(+), 9 deletions(-)