From nobody Fri Apr 4 21:12:23 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1739902963; cv=none; d=zohomail.com; s=zohoarc; b=drImOzGVIdGpC0h98tVAadjHsKpb3Vy1kNiKZjdRnf3nN2Dj0FjkYDhAiPO+HPOun6UsQb8J9vfAOibarId0naR+XkAACqHPpKgvebuwhH53hrVZLzkJ+KfVFxC5MKjtOCvCXKNNwwvxRS5irQNYlhJmdZAmRoxdW1hV2F+R5fI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739902963; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZL6MhAWrd4tLPqhBzrw0oeGzfhv+jDg7uLxyhTF7330=; b=Xe8zW8xYCGqhKrpCwLC4zesbrpVjzD8XNzvwC03fEM2qRsa84jcAKUXELP4xtg/DTpYeZaVcYXIc0ht3WLw/c5YQ3Pb0VLy4VGqbqkkwg39+sttna9cQiDpE1C8GDFZjB95BxDF7/jjraeR1GCDMIoQ8mdhLphCjOWz6NslS88E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739902963184862.6143364103382; Tue, 18 Feb 2025 10:22:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tkSDs-0006Dn-8I; Tue, 18 Feb 2025 13:21:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkSDJ-0005z7-CO for qemu-devel@nongnu.org; Tue, 18 Feb 2025 13:21:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkSDH-0007b7-NY for qemu-devel@nongnu.org; Tue, 18 Feb 2025 13:20:57 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-6O4hdOprNFaAE-NCmWYf-Q-1; Tue, 18 Feb 2025 13:20:51 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 063021801A24; Tue, 18 Feb 2025 18:20:50 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.45.226.66]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7BADD180034D; Tue, 18 Feb 2025 18:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739902854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZL6MhAWrd4tLPqhBzrw0oeGzfhv+jDg7uLxyhTF7330=; b=DJQAKWVBsscJML9PETeBnFMxY1qes+f+T6U7wFI+/Hcypux1iX78maNbUlqdUniToNW8uT jJVasFvFhKvuNE9L+OOptBWm2qyDAEnagtrcm3WjhYArsZRxdnGZVnIkD/kesCywSh1jQa LKknDa8Iogxd4eUqmPYA+lkWaM+1+G4= X-MC-Unique: 6O4hdOprNFaAE-NCmWYf-Q-1 X-Mimecast-MFC-AGG-ID: 6O4hdOprNFaAE-NCmWYf-Q_1739902850 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, hreitz@redhat.com, pbonzini@redhat.com, manos.pitsidianakis@linaro.org, philmd@linaro.org, qemu-devel@nongnu.org, qemu-rust@nongnu.org Subject: [PATCH v2 07/11] block: Add bdrv_open_blockdev_ref_file() Date: Tue, 18 Feb 2025 19:20:15 +0100 Message-ID: <20250218182019.111467-8-kwolf@redhat.com> In-Reply-To: <20250218182019.111467-1-kwolf@redhat.com> References: <20250218182019.111467-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.423, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1739902964204019000 Content-Type: text/plain; charset="utf-8" This is the equivalent of bdrv_open_file_child() to be used in cases where the caller is QAPI based and has a BlockdevRef rather than a filename and an options QDict. Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 4 ++++ block.c | 31 +++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index 9be34b3c99..861e19cfe6 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -100,6 +100,10 @@ bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); BlockDriverState * coroutine_fn no_co_wrapper bdrv_co_open_blockdev_ref(BlockdevRef *ref, Error **errp); =20 +BlockDriverState * no_coroutine_fn +bdrv_open_blockdev_ref_file(BlockdevRef *ref, BlockDriverState *parent, + Error **errp); + int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, Error **errp); int GRAPH_WRLOCK diff --git a/block.c b/block.c index 0ece805e41..cd53c84f84 100644 --- a/block.c +++ b/block.c @@ -3847,7 +3847,11 @@ int bdrv_open_file_child(const char *filename, * TODO Future callers may need to specify parent/child_class in order for * option inheritance to work. Existing callers use it for the root node. */ -BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp) +static BlockDriverState * no_coroutine_fn +bdrv_open_blockdev_ref_common(BlockdevRef *ref, BlockDriverState *parent, + const BdrvChildClass *child_class, + BdrvChildRole child_role, bool parse_filenam= e, + Error **errp) { BlockDriverState *bs =3D NULL; QObject *obj =3D NULL; @@ -3880,14 +3884,35 @@ BlockDriverState *bdrv_open_blockdev_ref(BlockdevRe= f *ref, Error **errp) =20 } =20 - bs =3D bdrv_open_inherit(NULL, reference, qdict, 0, NULL, NULL, 0, fal= se, - errp); + bs =3D bdrv_open_inherit(NULL, reference, qdict, 0, parent, child_clas= s, + child_role, parse_filename, errp); obj =3D NULL; qobject_unref(obj); visit_free(v); return bs; } =20 +BlockDriverState *bdrv_open_blockdev_ref_file(BlockdevRef *ref, + BlockDriverState *parent, + Error **errp) +{ + BdrvChildRole role; + + /* commit_top and mirror_top don't use this function */ + assert(!parent->drv->filtered_child_is_backing); + role =3D parent->drv->is_filter + ? (BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY) + : BDRV_CHILD_IMAGE; + + return bdrv_open_blockdev_ref_common(ref, parent, &child_of_bds, role, + true, errp); +} + +BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp) +{ + return bdrv_open_blockdev_ref_common(ref, NULL, NULL, 0, false, errp); +} + static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, QDict *snapshot_options, --=20 2.48.1