From nobody Sun Sep 28 16:34:17 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1757953756126403.1089057254799; Mon, 15 Sep 2025 09:29:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uyC3R-0002fi-75; Mon, 15 Sep 2025 12:27:49 -0400 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 1uyC3K-0002f0-7p for qemu-devel@nongnu.org; Mon, 15 Sep 2025 12:27:42 -0400 Received: from m204-227.eu.mailgun.net ([161.38.204.227]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uyC2j-0006Ey-AH for qemu-devel@nongnu.org; Mon, 15 Sep 2025 12:27:41 -0400 Received: from fedora (pub082136115007.dh-hfc.datazug.ch [82.136.115.7]) by 1359f3db7b55b86d05c746cc51c576b61417a5d3a5bbf366fd442f5a78e413fd with SMTP id 68c83e4b3d62d88b99c294fd; Mon, 15 Sep 2025 16:26:51 GMT DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=0x65c.net; q=dns/txt; s=email; t=1757953611; x=1757960811; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-ID: Date: Subject: Subject: Cc: To: To: From: From: Sender: Sender; bh=GfB7TJ/R+SmBPiIs7bTkD5S39munCenXb9QGVz606qk=; b=YzNjw7qUeONneE9UOTGnICSJA/VpJDQWQI1NApjkl3RtDOo3Ooe145tP35/7ZHLtXQaZ/a7nIua4UjmKxb1jIFr1PFy6vqH8LsoGCAjoudCruUjN55etVGl9yxHadDQ1Y8RGAo8YgXpqQIIxOHTHetrWknRZLylncTE86vo/Ye7osUkF4tk3o4+z0onH+aTrA76AbbzExvSd5l1RBnsUKWP3qD/HUNjvlg4tDYTaAUcQDEzsA7BbmvKVKCyDOnHc7n58jXHazPj89kMcq3vLXc7eqr+QjZWg6buZlccT/1eJnm+2b9PXyOb+49nzpkwxoe2ehPUTZsU3+GIuRKE3fw== X-Mailgun-Sid: WyJiNjdhNCIsInFlbXUtZGV2ZWxAbm9uZ251Lm9yZyIsIjU0ZWY0Il0= X-Mailgun-Sending-Ip: 161.38.204.227 From: Alessandro Ratti To: alex.bennee@linaro.org Cc: alessandro.ratti@gmail.com, alessandro@0x65c.net, philmd@linaro.org, qemu-devel@nongnu.org Subject: [PATCH v2] virtio: Add function name to error messages Date: Mon, 15 Sep 2025 18:19:38 +0200 Message-ID: <20250915162643.44716-2-alessandro@0x65c.net> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250915162643.44716-1-alessandro@0x65c.net> References: <87a52wqa03.fsf@draig.linaro.org> <20250915162643.44716-1-alessandro@0x65c.net> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=161.38.204.227; envelope-from=bounce+db73df.54ef4-qemu-devel=nongnu.org@0x65c.net; helo=m204-227.eu.mailgun.net 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, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757953758362116600 Content-Type: text/plain; charset="utf-8" Replace virtio_error() with a macro that automatically prepends the calling function name to error messages. This provides better context for debugging virtio issues by showing exactly which function encountered the error. Before: "Invalid queue size: 1024" After: "virtio_queue_set_num: Invalid queue size: 1024" The implementation uses a macro to insert __func__ at compile time, avoiding any runtime overhead while providing more specific error context than a generic "virtio:" prefix. Also remove manual __func__ usage in virtio-balloon to avoid duplicate function names in error messages. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/230 Buglink: https://bugs.launchpad.net/qemu/+bug/1919021 Signed-off-by: Alessandro Ratti --- hw/virtio/virtio-balloon.c | 2 +- hw/virtio/virtio.c | 2 +- include/hw/virtio/virtio.h | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index db787d00b3..e443f71c01 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -697,7 +697,7 @@ virtio_balloon_free_page_hint_notify(NotifierWithReturn= *n, void *data, case PRECOPY_NOTIFY_COMPLETE: break; default: - virtio_error(vdev, "%s: %d reason unknown", __func__, pnd->reason); + virtio_error(vdev, "%d reason unknown", pnd->reason); } =20 return 0; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 9a81ad912e..44528d7f2b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3931,7 +3931,7 @@ void virtio_device_set_child_bus_name(VirtIODevice *v= dev, char *bus_name) vdev->bus_name =3D g_strdup(bus_name); } =20 -void G_GNUC_PRINTF(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt,= ...) +void G_GNUC_PRINTF(2, 3) virtio_error_impl(VirtIODevice *vdev, const char = *fmt, ...) { va_list ap; =20 diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c594764f23..961d021497 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -249,7 +249,9 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id= , size_t config_size); =20 void virtio_cleanup(VirtIODevice *vdev); =20 -void virtio_error(VirtIODevice *vdev, const char *fmt, ...) G_GNUC_PRINTF(= 2, 3); +#define virtio_error(vdev, fmt, ...) \ + virtio_error_impl(vdev, "%s: " fmt, __func__, ##__VA_ARGS__) +void virtio_error_impl(VirtIODevice *vdev, const char *fmt, ...) G_GNUC_PR= INTF(2, 3); =20 /* Set the child bus name. */ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name); --=20 2.39.5