From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B07ECFC51D for ; Sat, 22 Nov 2025 08:45:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vMjAx-0002L3-I4; Sat, 22 Nov 2025 03:41:00 -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 1vMiBk-0005EU-1P for qemu-devel@nongnu.org; Sat, 22 Nov 2025 02:37:48 -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 1vMiBF-0000Nr-Kv for qemu-devel@nongnu.org; Sat, 22 Nov 2025 02:37:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763797016; 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: in-reply-to:in-reply-to:references:references; bh=9zaKUM6NERkcDDV6tGqy74CB52tnWy2WHUiDFb7Jfp8=; b=Njoorb8B24NKoThbfuSpKVtnoVvfJ6lGPvyAYNTIf2igp6WcTimgvWGroBPvGewVs1Lobx I/2UM1zkTMHLa93ZZ1+nCicPIdtR3X0pUFCwis/H8bH5/yiIXSeThOFAWWMVpWikpXiBWE ReKpfMLQwGiztObXUaPSL32YccCjqPU= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-403-_NSKGyWnNIq26wjDIyzvQA-1; Sat, 22 Nov 2025 02:36:51 -0500 X-MC-Unique: _NSKGyWnNIq26wjDIyzvQA-1 X-Mimecast-MFC-AGG-ID: _NSKGyWnNIq26wjDIyzvQA_1763797008 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8F13A195608F; Sat, 22 Nov 2025 07:36:45 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.45.242.3]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 930D118004D8; Sat, 22 Nov 2025 07:36:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1260B21E6A27; Sat, 22 Nov 2025 08:36:40 +0100 (CET) From: Markus Armbruster To: "Dr. David Alan Gilbert" Cc: qemu-devel@nongnu.org, arei.gonglei@huawei.com, pizhenwei@bytedance.com, alistair.francis@wdc.com, stefanb@linux.vnet.ibm.com, kwolf@redhat.com, hreitz@redhat.com, sw@weilnetz.de, qemu_oss@crudebyte.com, groug@kaod.org, mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, kraxel@redhat.com, shentey@gmail.com, npiggin@gmail.com, harshpb@linux.ibm.com, sstabellini@kernel.org, anthony@xenproject.org, paul@xen.org, edgar.iglesias@gmail.com, elena.ufimtseva@oracle.com, jag.raman@oracle.com, sgarzare@redhat.com, pbonzini@redhat.com, fam@euphon.net, philmd@linaro.org, alex@shazbot.org, clg@redhat.com, peterx@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, jasowang@redhat.com, samuel.thibault@ens-lyon.org, michael.roth@amd.com, kkostiuk@redhat.com, zhao1.liu@intel.com, mtosatti@redhat.com, rathc@linux.ibm.com, palmer@dabbelt.com, liwei1518@gmail.com, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com, marcandre.lureau@redhat.com, qemu-block@nongnu.org, qemu-ppc@nongnu.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, qemu-riscv@nongnu.org Subject: Re: [PATCH 09/14] error: Use error_setg_file_open() for simplicity and consistency In-Reply-To: (David Alan Gilbert's message of "Fri, 21 Nov 2025 17:45:52 +0000") References: <20251120191339.756429-1-armbru@redhat.com> <20251120191339.756429-10-armbru@redhat.com> <87see8q6qm.fsf@pond.sub.org> Date: Sat, 22 Nov 2025 08:36:40 +0100 Message-ID: <87ecpqtt6f.fsf@pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org "Dr. David Alan Gilbert" writes: > * Markus Armbruster (armbru@redhat.com) wrote: >> "Dr. David Alan Gilbert" writes: >> >> > * Markus Armbruster (armbru@redhat.com) wrote: >> >> Replace >> >> >> >> error_setg_errno(errp, errno, MSG, FNAME); >> >> >> >> by >> >> >> >> error_setg_file_open(errp, errno, FNAME); >> >> >> >> where MSG is "Could not open '%s'" or similar. >> >> >> >> Also replace equivalent uses of error_setg(). >> >> >> >> A few messages lose prefixes ("net dump: ", "SEV: ", __func__ ": "). >> >> We could put them back with error_prepend(). Not worth the bother. >> > >> > Yeh, I guess you could just do it with another macro using >> > the same internal function just with string concatenation. >> >> I'm no fan of such prefixes. A sign of developers not caring enough to >> craft a good error message for *users*. *Especially* in the case of >> __func__. >> >> The error messages changes in question are: >> >> net dump: can't open DUMP-FILE: REASON >> Could not open 'DUMP-FILE': REASON >> >> SEV: Failed to open SEV-DEVICE: REASON >> Could not open 'SEV-DEVICE': REASON >> >> sev_common_kvm_init: Failed to open SEV_DEVICE 'REASON' >> Could not open 'SEV-DEVICE': REASON >> >> I think these are all improvements, and the loss of the prefix is fine. > > Yeh, although I find the error messages aren't just for users; > they're often for the first dev to see it to guess which other > dev to pass the problem to, so a hint about where it's coming > from can be useful. I agree! But I think an error message must be make sense to users *first* and help developers second, and once they make sense to users, they're often good enough for developers. The common failures I see happen when developers remain caught in the developer's perspective, and write something that makes sense to *them*. Strawman form: prefix: failed op[: reason] where "prefix" is a subsystem tag, or even __func__, and "reason" is strerror() or similar. To users, this tends to read as gobbledygook: techbabble[: reason] When we care to replace "failed op" (developer's perspective) by something that actually makes sense to users, "prefix" often becomes redundant. The error messages shown above aren't bad to begin with. "failed to open FILE", where FILE is something the user specified, should make sense to the user. It should also be good enough for developers even without a prefix: connecting trouble with the DUMP-FILE to dump / trouble with the SEV-DEVICE to SEV should be straightforward. [...]