From nobody Tue Nov 11 20:53:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565367724; cv=none; d=zoho.com; s=zohoarc; b=Dt4ZeqnCqJAkjtf7FF/a7IYfQGwL25e/Unai/pDVChCk3IO0zv/aj64Rqv+MbsiEaY7xEfS2PpJUVmmteatrOt1htunNes3yl1aQMwfvVycuPqzz4tvitJFKykosB4PhM8lkVyFWyHUp7xvuI6zoA/IH4BQ1tMoJj+DZ00J/7jU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565367724; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gp8JW95MC8jebkzg7FsVdmj//E0mjDH1fx58wzs34Bo=; b=LY9pRe7qvnIMLge9NFh7/txDeAsK32nRu8PBS+o0pPVhgZQ8LJiyIiBhc6JhrhlIYBZRjX9/a9Op0vqAsu8wqBT2e9Bnfvob8OGBtvxoVh19a8EfznN1Ljwdqv+S20GUPmde+IrtcT/IgbpMu3YmA3du9U4Ct07nQPVwt1bgM+Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565367724776928.7177806211639; Fri, 9 Aug 2019 09:22:04 -0700 (PDT) Received: from localhost ([::1]:60934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw7eT-000197-8v for importer@patchew.org; Fri, 09 Aug 2019 12:22:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57219) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hw7Xa-0001uG-Rg for qemu-devel@nongnu.org; Fri, 09 Aug 2019 12:14:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hw7XZ-0004Ek-Om for qemu-devel@nongnu.org; Fri, 09 Aug 2019 12:14:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38048) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hw7XX-0004DN-97; Fri, 09 Aug 2019 12:14:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9820D88309; Fri, 9 Aug 2019 16:14:50 +0000 (UTC) Received: from localhost (unknown [10.40.205.179]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 352035C29A; Fri, 9 Aug 2019 16:14:50 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 9 Aug 2019 18:13:43 +0200 Message-Id: <20190809161407.11920-19-mreitz@redhat.com> In-Reply-To: <20190809161407.11920-1-mreitz@redhat.com> References: <20190809161407.11920-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 09 Aug 2019 16:14:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v6 18/42] block: Use CAFs in bdrv_refresh_filename() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Vladimir Sementsov-Ogievskiy --- block.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/block.c b/block.c index 064cc99857..a467b175c6 100644 --- a/block.c +++ b/block.c @@ -6432,6 +6432,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) { BlockDriver *drv =3D bs->drv; BdrvChild *child; + BlockDriverState *primary_child_bs; QDict *opts; bool backing_overridden; bool generate_json_filename; /* Whether our default implementation sho= uld @@ -6500,20 +6501,30 @@ void bdrv_refresh_filename(BlockDriverState *bs) qobject_unref(bs->full_open_options); bs->full_open_options =3D opts; =20 + primary_child_bs =3D bdrv_primary_bs(bs); + if (drv->bdrv_refresh_filename) { /* Obsolete information is of no use here, so drop the old file na= me * information before refreshing it */ bs->exact_filename[0] =3D '\0'; =20 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). + */ =20 bs->exact_filename[0] =3D '\0'; =20 /* * 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 c= reate * the BDS tree we have right now, that is: @@ -6522,11 +6533,11 @@ void bdrv_refresh_filename(BlockDriverState *bs) * - no non-file child of this BDS has been overridden by the us= er * Both of these conditions are represented by generate_json_fil= ename. */ - 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); } } =20 @@ -6543,6 +6554,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) char *bdrv_dirname(BlockDriverState *bs, Error **errp) { BlockDriver *drv =3D bs->drv; + BlockDriverState *child_bs; =20 if (!drv) { error_setg(errp, "Node '%s' is ejected", bs->node_name); @@ -6553,8 +6565,9 @@ char *bdrv_dirname(BlockDriverState *bs, Error **errp) return drv->bdrv_dirname(bs, errp); } =20 - if (bs->file) { - return bdrv_dirname(bs->file->bs, errp); + child_bs =3D bdrv_primary_bs(bs); + if (child_bs) { + return bdrv_dirname(child_bs, errp); } =20 bdrv_refresh_filename(bs); --=20 2.21.0