From nobody Sat Nov 15 04:18:21 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593099912; cv=none; d=zohomail.com; s=zohoarc; b=Qq0lWvVVkmyqGSMda1ZRgVK5oYrXcogiAAi86UtYK54shXZLHE2LlA/1UeJtCCkrYZc1zOd2SlBpgKOB3MTtcvdI1YSIQ+wgeHZr5EQ5V0D/yBnngs44k2evb9Rt/0elUkjNj4C2S9xT0CKsXPrW93p3viiMhNugoO4efSWRqp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593099912; h=Content-Type: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; bh=f/8zhymTzIASkGBdt7o/w7A64dbu+ST4wSjovqOs2p0=; b=eBqyDxw89VToNiQLYDaMTbwIp48z4WNGS0HSp0PByVYOzajIx6sq92VtgXdezNjHH5GvwrCG2W6X4mlPI5wCwG0KAe0fN5KjxU11BpBoj1ZP9FWRsPLZ6HYUMw1QpnouzM72N+jDve7uN5dnwbhwQvd6R/vR0EF2XuBof5D7vtc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=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 1593099912109443.8780357662232; Thu, 25 Jun 2020 08:45:12 -0700 (PDT) Received: from localhost ([::1]:40858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joU3q-0004Ox-ML for importer@patchew.org; Thu, 25 Jun 2020 11:45:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joTia-00061s-SI for qemu-devel@nongnu.org; Thu, 25 Jun 2020 11:23:12 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:28353 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1joTiZ-00017M-7Y for qemu-devel@nongnu.org; Thu, 25 Jun 2020 11:23:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-169-iM2jqbcWMeykjgOw5lKfYQ-1; Thu, 25 Jun 2020 11:23:06 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6121D800C60; Thu, 25 Jun 2020 15:23:05 +0000 (UTC) Received: from localhost (ovpn-113-182.ams2.redhat.com [10.36.113.182]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 044325C296; Thu, 25 Jun 2020 15:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593098590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f/8zhymTzIASkGBdt7o/w7A64dbu+ST4wSjovqOs2p0=; b=eTOCY0iLwueBPqGuXCHcXuwyD5z2PpHTChQ+xPrVvqqB0kgrjElOBbzJQoHh7mGFpuOsz5 brcsd5DPfGZr44ulXBX7018hH82o9kJ29s2Qacv6krQoPtP0u6YHPfJPcSUo30vpectJ5g g+sWAZePkLxD4mKuaMQ58WlLwbjkKHM= X-MC-Unique: iM2jqbcWMeykjgOw5lKfYQ-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v7 21/47] block: Use CAFs in bdrv_refresh_filename() Date: Thu, 25 Jun 2020 17:21:49 +0200 Message-Id: <20200625152215.941773-22-mreitz@redhat.com> In-Reply-To: <20200625152215.941773-1-mreitz@redhat.com> References: <20200625152215.941773-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=207.211.31.81; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/25 02:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 8131d0b5eb..7c827fefa0 100644 --- a/block.c +++ b/block.c @@ -6797,6 +6797,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 @@ -6866,20 +6867,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: @@ -6888,11 +6899,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 @@ -6912,6 +6923,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); @@ -6922,8 +6934,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.26.2