From nobody Mon Feb 9 12:43:04 2026 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=1560379322; cv=none; d=zoho.com; s=zohoarc; b=PfxAIatWVc6kchPObyuBcbdj1Hh84C4jTkDjVVdA6Ac7v2Ij6N8OSViPJOHtgI7Jh2fIwNiHUMVHovSGnpD6RHcrGOvbrh1kAifq2y7ogFBA2kGk4ksYbXmoTD5rkt5eoJRrp00UZnC4+5ZDJxHBT8xYNZ3cKohrM1RrrO2RXn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560379322; 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=yTZ1SmFuqFYOR/bF2NLSjbYfmHdObQileSDLPb5tvrs=; b=OXHsdlOhbYu0L0GmttY4PTLkJ9p5/hLdDRxa44xaNvP3BLHECet78c56OIk0KUApWmmc/AbTP/5zPBHiDTKAM5UyEcpPJnZUKE1yDzs7CdVSuq8gV/J0zCItF6SVZVS3Z8LFSmXLruOTJKKzs2uernfSmhPHD+VcctPJY0mLvNI= 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 1560379322571577.978098016006; Wed, 12 Jun 2019 15:42:02 -0700 (PDT) Received: from localhost ([::1]:35612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbBwM-0002no-DW for importer@patchew.org; Wed, 12 Jun 2019 18:41:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45808) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbBSR-0007zC-EF for qemu-devel@nongnu.org; Wed, 12 Jun 2019 18:11:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbBSP-0007sr-9z for qemu-devel@nongnu.org; Wed, 12 Jun 2019 18:11:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbBSJ-0007oe-Cd; Wed, 12 Jun 2019 18:10:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C79BA96F1; Wed, 12 Jun 2019 22:10:53 +0000 (UTC) Received: from localhost (unknown [10.40.205.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 918E660FD6; Wed, 12 Jun 2019 22:10:52 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 13 Jun 2019 00:09:40 +0200 Message-Id: <20190612221004.2317-19-mreitz@redhat.com> In-Reply-To: <20190612221004.2317-1-mreitz@redhat.com> References: <20190612221004.2317-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Jun 2019 22:10:53 +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 v5 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 --- block.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/block.c b/block.c index db2759c10d..797bec0326 100644 --- a/block.c +++ b/block.c @@ -6280,6 +6280,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 @@ -6348,20 +6349,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: @@ -6370,11 +6381,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 @@ -6391,6 +6402,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); @@ -6401,8 +6413,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