From nobody Sat Jul 5 16:02:10 2025 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678351879; cv=none; d=zohomail.com; s=zohoarc; b=hUW4XNAS0jJKXXFGdtZfKx4lxO7/U+E5ido82aFlsZRysl4eFGM0s66e5Hyzd1nfYj1boc202EtgH1VtT1bpAxecY+TPlELK0XYTJU6/0Y3kib2/oVDRRZdTfSGuqNl5pgCN1ILOGcCUqIUAHSiP4Hoe3mze1tMpd04YUPAJGxo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678351879; 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=M03WwdG34wPjeEEg0rnhkt9BMsbe0esm2loujONRDeM=; b=RAb3l29qKhoS87ZHT0kJ6Gm8wXsacRRtMLpfJOYv0XqLUrFOaI7miz5qqH4uzkH4U9MogjowmeIf9Z9V7DqsQWQigWHlCLk9FXEwQapFoIMyUycedJYgvC3tbhjipjys7S3Hx8SROq6HzymBX4uZzDLQwKks0NSxnyYZ2oCJaCo= 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+importer2=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 1678351879939950.5932822751581; Thu, 9 Mar 2023 00:51:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paBzT-0007mg-Cn; Thu, 09 Mar 2023 03:51:11 -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 1paBzJ-0007k5-5L for qemu-devel@nongnu.org; Thu, 09 Mar 2023 03:51:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1paBzH-00021Z-Fb for qemu-devel@nongnu.org; Thu, 09 Mar 2023 03:51:00 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-435-sro_wGHoMuWragfHCdFEMQ-1; Thu, 09 Mar 2023 03:50:57 -0500 Received: by mail-ed1-f71.google.com with SMTP id g2-20020a056402320200b004e98d45ee7dso1985404eda.0 for ; Thu, 09 Mar 2023 00:50:57 -0800 (PST) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id h23-20020a170906719700b008c673cd9ba2sm8484640ejk.126.2023.03.09.00.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 00:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678351858; 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=M03WwdG34wPjeEEg0rnhkt9BMsbe0esm2loujONRDeM=; b=fL9ghfGFwhBdccmrjeFJywdk6F17ztbSXfYu8RqNmrWWaDwO/QLiw8hfe+RfoOYUQXMV0m vJJnDQsellBzDcoiwQhFccOFely7E4mTLADCACZ24z7pmdyJNEz8SS3JpQgpyTBnINETK9 wze6K8NGvxtcboLx9ZTEh3c5BXJkI6Y= X-MC-Unique: sro_wGHoMuWragfHCdFEMQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678351855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M03WwdG34wPjeEEg0rnhkt9BMsbe0esm2loujONRDeM=; b=h819uqFY+r5cHyWWgkCmH3/YOt+OsL2zm927URVxT2MV2YVZwHLTsj4dVbQA+iiGCL /VChn5U2NZeXS4KLMmUZRG4RGq8HDYKTOOODYunHDrD6S0Gs+roC6beE7ZgqAoY2FmSd kG0FxCfmA9CkVQ6F2WahvvjQ4k4v8cCJrzh8sqGI7fyaHezKeWxj4RelUnJSW9rl2W81 qV9f8H49RkhGR74qvPZ1Qxf5mLOSRs/hz5uGHOKBbjixQAMKzIrZ5amrpILYA1hxM44K 3k9jzWwpI17dUr5f7pMwfTieK31rzP/5Ye8/4djMkn8tkpqIob8QZrk+kXcMUDa3/FnU AS6w== X-Gm-Message-State: AO0yUKWga2SPf8bOrCADtLHi1igcmsoc7vD/8Oc1gs2Hgg5/skcbdwz2 XfEiH39f4p9v3dXzdFusYcybBPO8P2Vh33D2ozhelj/9QsX9OgFCwGNJ7TYLuH7FZ8XCwDyqSL+ qlCUFTgGYOnT/iPJDkQGEqZbML4MDOWijulvK5hCyO3uq6qS1Vkrcr8q6qMb0MqHq2gE3WF3wzd A= X-Received: by 2002:a17:906:ee82:b0:8b1:304e:589e with SMTP id wt2-20020a170906ee8200b008b1304e589emr26895181ejb.53.1678351855612; Thu, 09 Mar 2023 00:50:55 -0800 (PST) X-Google-Smtp-Source: AK7set+KVdd4iT9KYtwQng5DgQINYhW0LF+4oiBf2FrBOTolWU+wi5lCG7IepPcc2VsI5qS792cDBw== X-Received: by 2002:a17:906:ee82:b0:8b1:304e:589e with SMTP id wt2-20020a170906ee8200b008b1304e589emr26895164ejb.53.1678351855267; Thu, 09 Mar 2023 00:50:55 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org Subject: [PATCH 2/3] block: do not check bdrv_file_open Date: Thu, 9 Mar 2023 09:50:50 +0100 Message-Id: <20230309085051.308664-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309085051.308664-1-pbonzini@redhat.com> References: <20230309085051.308664-1-pbonzini@redhat.com> MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678351881767100003 Content-Type: text/plain; charset="utf-8" The set of BlockDrivers that have .bdrv_file_open coincides with those that have .protocol_name and guess what---checking drv->bdrv_file_open is done to see if the driver is a protocol. So check drv->protocol_name instead. Signed-off-by: Paolo Bonzini --- block.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index 075da6517b7f..71f0ea24870e 100644 --- a/block.c +++ b/block.c @@ -914,7 +914,6 @@ BlockDriver *bdrv_find_protocol(const char *filename, int i; =20 GLOBAL_STATE_CODE(); - /* TODO Drivers without bdrv_file_open must be specified explicitly */ =20 /* * XXX(hch): we really should not let host device detection @@ -1628,7 +1627,7 @@ static int bdrv_open_driver(BlockDriverState *bs, Blo= ckDriver *drv, bs->opaque =3D g_malloc0(drv->instance_size); =20 assert(!drv->bdrv_needs_filename || bs->filename[0]); - if (drv->bdrv_file_open) { + if (drv->bdrv_open) { ret =3D drv->bdrv_file_open(bs, options, open_flags, &local_err); } else if (drv->bdrv_open) { ret =3D drv->bdrv_open(bs, options, open_flags, &local_err); @@ -1940,7 +1939,7 @@ static int bdrv_open_common(BlockDriverState *bs, Blo= ckBackend *file, open_flags =3D bdrv_open_flags(bs, bs->open_flags); node_name =3D qemu_opt_get(opts, "node-name"); =20 - assert(!drv->bdrv_file_open || file =3D=3D NULL); + assert(!drv->protocol_name || file =3D=3D NULL); ret =3D bdrv_open_driver(bs, drv, node_name, options, open_flags, errp= ); if (ret < 0) { goto fail_opts; @@ -2040,7 +2039,7 @@ static int bdrv_fill_options(QDict **options, const c= har *filename, } /* If the user has explicitly specified the driver, this choice sh= ould * override the BDRV_O_PROTOCOL flag */ - protocol =3D drv->bdrv_file_open; + protocol =3D drv->protocol_name; } =20 if (protocol) { @@ -4000,7 +3999,7 @@ bdrv_open_inherit(const char *filename, const char *r= eference, QDict *options, } =20 /* BDRV_O_PROTOCOL must be set iff a protocol BDS is about to be creat= ed */ - assert(!!(flags & BDRV_O_PROTOCOL) =3D=3D !!drv->bdrv_file_open); + assert(!!(flags & BDRV_O_PROTOCOL) =3D=3D !!drv->protocol_name); /* file must be NULL if a protocol BDS is about to be created * (the inverse results in an error message from bdrv_open_common()) */ assert(!(flags & BDRV_O_PROTOCOL) || !file); @@ -5785,7 +5784,7 @@ int64_t coroutine_fn bdrv_co_get_allocated_file_size(= BlockDriverState *bs) return drv->bdrv_co_get_allocated_file_size(bs); } =20 - if (drv->bdrv_file_open) { + if (drv->protocol_name) { /* * Protocol drivers default to -ENOTSUP (most of their data is * not stored in any of their children (if they even have any), @@ -7888,7 +7887,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) * Both of these conditions are represented by generate_json_fil= ename. */ if (primary_child_bs->exact_filename[0] && - primary_child_bs->drv->bdrv_file_open && + primary_child_bs->drv->protocol_name && !drv->is_filter && !generate_json_filename) { strcpy(bs->exact_filename, primary_child_bs->exact_filename); --=20 2.39.2