From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTXAp-0002sJ-AP for qemu-devel@nongnu.org; Mon, 15 Sep 2014 10:22:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTXAd-00025I-0Z for qemu-devel@nongnu.org; Mon, 15 Sep 2014 10:22:35 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:50250 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTXAc-00023u-Nr for qemu-devel@nongnu.org; Mon, 15 Sep 2014 10:22:22 -0400 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Mon, 15 Sep 2014 16:21:20 +0200 Message-Id: <1410790880-21861-3-git-send-email-benoit.canet@nodalink.com> In-Reply-To: <1410790880-21861-1-git-send-email-benoit.canet@nodalink.com> References: <1410790880-21861-1-git-send-email-benoit.canet@nodalink.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 2/2] block: commit and stream return an error when a subtree is found List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com In bdrv_find_backing_image when looking for the base BDS of a backing cha= in and a BDS having a multiple children block driver is found return NULL and se= t an error message. This will hopefully remove any unwanted interference between stream, comm= it and drivers like quorum. CC: Jeff Cody Signed-off-by: Beno=C3=AEt Canet --- block.c | 17 +++++++++++++++-- blockdev.c | 18 ++++++++++++------ include/block/block.h | 3 ++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index d06dd51..ea86252 100644 --- a/block.c +++ b/block.c @@ -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->filen= ame * from a BDS as backing_file should not be done, as that may be relativ= e 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 pat= h 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 =3D NULL; char *backing_file_full =3D NULL; @@ -4362,6 +4366,15 @@ BlockDriverState *bdrv_find_backing_image(BlockDri= verState *bs, =20 for (curr_bs =3D bs; curr_bs->backing_hd; curr_bs =3D curr_bs->backi= ng_hd) { =20 + /* If a BDS having a multiple children block driver is found the= n 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)) { diff --git a/blockdev.c b/blockdev.c index e919566..4c5c28e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1894,9 +1894,11 @@ void qmp_block_stream(const char *device, } =20 if (has_base) { - base_bs =3D bdrv_find_backing_image(bs, base); + base_bs =3D bdrv_find_backing_image(bs, base, errp); if (base_bs =3D=3D NULL) { - error_set(errp, QERR_BASE_NOT_FOUND, base); + if (!*errp) { + error_set(errp, QERR_BASE_NOT_FOUND, base); + } return; } base_name =3D base; @@ -1965,23 +1967,27 @@ void qmp_block_commit(const char *device, =20 if (has_top && top) { if (strcmp(bs->filename, top) !=3D 0) { - top_bs =3D bdrv_find_backing_image(bs, top); + top_bs =3D bdrv_find_backing_image(bs, top, errp); } } =20 if (top_bs =3D=3D NULL) { - error_setg(errp, "Top image file %s not found", top ? top : "NUL= L"); + if (!*errp) { + error_setg(errp, "Top image file %s not found", top ? top : = "NULL"); + } return; } =20 if (has_base && base) { - base_bs =3D bdrv_find_backing_image(top_bs, base); + base_bs =3D bdrv_find_backing_image(top_bs, base, errp); } else { base_bs =3D bdrv_find_base(top_bs); } =20 if (base_bs =3D=3D NULL) { - error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL"); + if (!*errp) { + error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL"); + } return; } =20 diff --git a/include/block/block.h b/include/block/block.h index 8f4ad16..65cde65 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -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 sect= or_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); --=20 2.1.0