From nobody Wed Dec 17 05:36:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487963575846385.4124740981266; Fri, 24 Feb 2017 11:12:55 -0800 (PST) Received: from localhost ([::1]:39521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chLIU-0006u8-MM for importer@patchew.org; Fri, 24 Feb 2017 14:12:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chKR0-0006gt-JO for qemu-devel@nongnu.org; Fri, 24 Feb 2017 13:17:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chKQz-0002v9-Gu for qemu-devel@nongnu.org; Fri, 24 Feb 2017 13:17:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1chKQv-0002qT-8D; Fri, 24 Feb 2017 13:17:33 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D8FDC04D29E; Fri, 24 Feb 2017 18:17:33 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-128.ams2.redhat.com [10.36.117.128]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1OIHDCN015460; Fri, 24 Feb 2017 13:17:32 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 24 Feb 2017 19:17:05 +0100 Message-Id: <1487960230-18054-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1487960230-18054-1-git-send-email-kwolf@redhat.com> References: <1487960230-18054-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 24 Feb 2017 18:17:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 14/19] block: Factor out bdrv_open_child_bs() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is the part of bdrv_open_child() that opens a BDS with option inheritance, but doesn't attach it as a child to the parent yet. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- block.c | 61 +++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/block.c b/block.c index 40c4dee..6987400 100644 --- a/block.c +++ b/block.c @@ -1546,28 +1546,12 @@ free_exit: return ret; } =20 -/* - * Opens a disk image whose options are given as BlockdevRef in another bl= ock - * device's options. - * - * If allow_none is true, no image will be opened if filename is false and= no - * BlockdevRef is given. NULL will be returned, but errp remains unset. - * - * bdrev_key specifies the key for the image's BlockdevRef in the options = QDict. - * That QDict has to be flattened; therefore, if the BlockdevRef is a QDict - * itself, all options starting with "${bdref_key}." are considered part o= f the - * BlockdevRef. - * - * The BlockdevRef will be removed from the options QDict. - */ -BdrvChild *bdrv_open_child(const char *filename, - QDict *options, const char *bdref_key, - BlockDriverState* parent, - const BdrvChildRole *child_role, - bool allow_none, Error **errp) +static BlockDriverState * +bdrv_open_child_bs(const char *filename, QDict *options, const char *bdref= _key, + BlockDriverState *parent, const BdrvChildRole *child_ro= le, + bool allow_none, Error **errp) { - BdrvChild *c =3D NULL; - BlockDriverState *bs; + BlockDriverState *bs =3D NULL; QDict *image_options; char *bdref_key_dot; const char *reference; @@ -1594,11 +1578,40 @@ BdrvChild *bdrv_open_child(const char *filename, goto done; } =20 - c =3D bdrv_attach_child(parent, bs, bdref_key, child_role); - done: qdict_del(options, bdref_key); - return c; + return bs; +} + +/* + * Opens a disk image whose options are given as BlockdevRef in another bl= ock + * device's options. + * + * If allow_none is true, no image will be opened if filename is false and= no + * BlockdevRef is given. NULL will be returned, but errp remains unset. + * + * bdrev_key specifies the key for the image's BlockdevRef in the options = QDict. + * That QDict has to be flattened; therefore, if the BlockdevRef is a QDict + * itself, all options starting with "${bdref_key}." are considered part o= f the + * BlockdevRef. + * + * The BlockdevRef will be removed from the options QDict. + */ +BdrvChild *bdrv_open_child(const char *filename, + QDict *options, const char *bdref_key, + BlockDriverState *parent, + const BdrvChildRole *child_role, + bool allow_none, Error **errp) +{ + BlockDriverState *bs; + + bs =3D bdrv_open_child_bs(filename, options, bdref_key, parent, child_= role, + allow_none, errp); + if (bs =3D=3D NULL) { + return NULL; + } + + return bdrv_attach_child(parent, bs, bdref_key, child_role); } =20 static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, --=20 1.8.3.1