From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655384905; cv=none; d=zohomail.com; s=zohoarc; b=VLBzjw0Tr6zm4PQAab0Upj9cjfABuweG+uJRyeoZTZOiaNkXbWuROA0hSbD4HV+WYeBS3KZBTVEKj8R03RPGrsi0qw4R6cUNijIHGGy9Jwz6yDIQ0YXr67CnYJDAYAlN/wBZJp845F1+xAYuXLAoo9G0VSDb/b5GxzgRc6m2rDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655384905; 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=fy92f6kQJ5+uPC2RTOYG/PSXahPriSC+sovWZGw5Ewk=; b=MJr8R8b/IyAG6/1kOIFeWhpc+kC/H7veOaXbHxeaDmU47nschq0d7vFCO+r6BCOsgeaq3n/D15S7EuBEy2WDge2LRtBlPCSwrB6WzSoSupc8oj7xdrYX2z3pvTCsU03IBIjRpxhtEtkdNzBmu4RrDC3fL9/bHWvHy2xu2mk1seM= 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+importer=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 1655384905617910.7568182709277; Thu, 16 Jun 2022 06:08:25 -0700 (PDT) Received: from localhost ([::1]:45802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1pEW-0006T5-8W for importer@patchew.org; Thu, 16 Jun 2022 09:08:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooN-0001Cf-MI for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ont-0005FQ-VJ for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:20 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-eOuc_wz5N4OnmteMfPfewA-1; Thu, 16 Jun 2022 08:40:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F94B833976; Thu, 16 Jun 2022 12:40:44 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47B811415107; Thu, 16 Jun 2022 12:40:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383248; 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=fy92f6kQJ5+uPC2RTOYG/PSXahPriSC+sovWZGw5Ewk=; b=Za9gzlDW0MaUJ75Kn2oKlJHwZcJrhTWC181kC7kIMja23zuS8AhBAZC/cPhChXjLDDr4I5 kk+rIbznBybMPGkHNBKhMFYaL1yOc9wO9b1IPefCvgjquZAmKhMoaVxYrAHqcBfgkCZDAY eXrptQz9UEnv5yetWaDNFNdgNORSB8E= X-MC-Unique: eOuc_wz5N4OnmteMfPfewA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 1/9] monitor: make error_vprintf_unless_qmp() static Date: Thu, 16 Jun 2022 16:40:26 +0400 Message-Id: <20220616124034.3381391-2-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655384907702100001 From: Marc-Andr=C3=A9 Lureau Not needed outside monitor.c. Remove the needless stub. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/monitor/monitor.h | 1 - monitor/monitor.c | 3 ++- stubs/error-printf.c | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index a4b40e8391db..44653e195b45 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -56,7 +56,6 @@ void monitor_register_hmp(const char *name, bool info, void monitor_register_hmp_info_hrt(const char *name, HumanReadableText *(*handler)(Error **e= rrp)); =20 -int error_vprintf_unless_qmp(const char *fmt, va_list ap) G_GNUC_PRINTF(1,= 0); int error_printf_unless_qmp(const char *fmt, ...) G_GNUC_PRINTF(1, 2); =20 #endif /* MONITOR_H */ diff --git a/monitor/monitor.c b/monitor/monitor.c index 86949024f643..ba4c1716a48a 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -273,7 +273,8 @@ int error_vprintf(const char *fmt, va_list ap) return vfprintf(stderr, fmt, ap); } =20 -int error_vprintf_unless_qmp(const char *fmt, va_list ap) +G_GNUC_PRINTF(1, 0) +static int error_vprintf_unless_qmp(const char *fmt, va_list ap) { Monitor *cur_mon =3D monitor_cur(); =20 diff --git a/stubs/error-printf.c b/stubs/error-printf.c index 0e326d801059..1afa0f62ca26 100644 --- a/stubs/error-printf.c +++ b/stubs/error-printf.c @@ -16,8 +16,3 @@ int error_vprintf(const char *fmt, va_list ap) } return vfprintf(stderr, fmt, ap); } - -int error_vprintf_unless_qmp(const char *fmt, va_list ap) -{ - return error_vprintf(fmt, ap); -} --=20 2.37.0.rc0 From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655384362; cv=none; d=zohomail.com; s=zohoarc; b=kMaSgAN4B9DE75UZo5R+HPEG7SUzZRwioOkjCKiXFggi6xn9IxJzUPHN/L8bwjW2uIaS/RK7Ll4e+Y9VfLpfPMDsb4cdNnfuYMfJ8ffeKvKJtFWLqKrcIBuvlI8kLYAKHrChbemfRWobt54PGeVHJoRaYZrN7FxaY37FXd/qxPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655384362; 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=mhY9PsABRcMLJF+tV+NJTVZCNMbp0QjCFVmkIu3F/XI=; b=QZ8JQpgvFAwDyBjvfiCMhHFimVbnHBbZyL2yFCSwP3wXpwBHz6kN2TnP4UJAD0qdMjadHCLtvPBHNQ3pl2wixztOuBphq4aoUW+AepNcTG/hyQ0sdqvgpYTBMgtwboz3ZD2p3ge+aF3uOEJ8bTWijfF/HJhb0QyjvRtLgQd+D+o= 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+importer=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 1655384362043517.8585462903509; Thu, 16 Jun 2022 05:59:22 -0700 (PDT) Received: from localhost ([::1]:35028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1p5k-00072G-Bv for importer@patchew.org; Thu, 16 Jun 2022 08:59:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooN-0001Cj-NG for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30161) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1onu-0005Fd-JM for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:20 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-EvbRXGxEP7i5lJzk7SWXVg-1; Thu, 16 Jun 2022 08:40:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 91685185A7BA; Thu, 16 Jun 2022 12:40:48 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DE5C40C141F; Thu, 16 Jun 2022 12:40:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383252; 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=mhY9PsABRcMLJF+tV+NJTVZCNMbp0QjCFVmkIu3F/XI=; b=b+efhreUPkhbDs60MW3QWnGmTXtAhOS65BSSv5NPj1aqvyOsSXZwJav4YcaqlXwTyaQqVF TT2kaL7faQF4rALHQCwONaqI1prbSug2XiAqUxM4ZH7THZSe+RWCe7SnLP73bDZ6eIAVkm 98cldX8WwYm1WiJlCWCvdG3XRk+Aai4= X-MC-Unique: EvbRXGxEP7i5lJzk7SWXVg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 2/9] error-report: misc comment fix Date: Thu, 16 Jun 2022 16:40:27 +0400 Message-Id: <20220616124034.3381391-3-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655384364025100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- util/error-report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/error-report.c b/util/error-report.c index 5edb2e604061..98f242b75bbf 100644 --- a/util/error-report.c +++ b/util/error-report.c @@ -390,7 +390,7 @@ void error_init(const char *argv0) { const char *p =3D strrchr(argv0, '/'); =20 - /* Set the program name for error_print_loc(). */ + /* Set the program name for print_loc(). */ g_set_prgname(p ? p + 1 : argv0); =20 /* --=20 2.37.0.rc0 From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655384144; cv=none; d=zohomail.com; s=zohoarc; b=dbOf5DqHdeBK694XWvpwsSeBieO3/gJQmcQpvrooall0NhqsNBqgjb1dufbbxUbo/98yknPoX1QokrHTrVOjcK6qmQJYqSiC2ba2sdyWUQJwdiCpy+GvInKbwYaspt6Lcf4ekj67EwTfDdiEg/u8sKQmxpUePCzCiGoFqJmuxRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655384144; 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=rzIBgNsKYpHaLR13PS2PpWp9q632APSC+dXPHpCH13g=; b=Z3yAfWuNEmmGMfNsF9kZyd/RTvrdZrnyXuy61jiz3zLQcIsVHfwHc9Ew13GhtWomdHobToIokJBy1iFHHfoRZVkYeBrP+HcHC2H447OQ4049h5PioDC4VYisrKfFrsQkPvxF/HX/OQ36lLHAlk8ohvv6Q98ufOzbm8Zq0N3fpFc= 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+importer=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 16553841440823.636469356353132; Thu, 16 Jun 2022 05:55:44 -0700 (PDT) Received: from localhost ([::1]:55066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1p2D-0001OJ-VI for importer@patchew.org; Thu, 16 Jun 2022 08:55:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooL-0001CR-0g for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1oo7-0005Pb-Gn for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:19 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-0Sap0AJEMF-yI9fy4sosfA-1; Thu, 16 Jun 2022 08:40:54 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50F80802D1F; Thu, 16 Jun 2022 12:40:54 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1548A492CA5; Thu, 16 Jun 2022 12:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383265; 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=rzIBgNsKYpHaLR13PS2PpWp9q632APSC+dXPHpCH13g=; b=FzmpCtujp4CT/MZpfFSpRLtF3Vfi/mgztJ44f1gfSen7XILh6B6i5JihtNOiLZB/teI4p3 N9Fp0J5SXaa5i6glWk79n/4e985NVi3BqId+6qRV2zAVJ2KqPhmZrlN1vBqoSoNrXb1wnc Vl+N9f2qvxSVBSq5a7a9DDjudVzKisg= X-MC-Unique: 0Sap0AJEMF-yI9fy4sosfA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 3/9] error-report: introduce "detailed" variable Date: Thu, 16 Jun 2022 16:40:28 +0400 Message-Id: <20220616124034.3381391-4-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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=170.10.129.124; envelope-from=marcandre.lureau@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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655384145344100001 From: Marc-Andr=C3=A9 Lureau Let's use a more explicit variable "detailed" instead of calling monitor_cur() multiple times. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- util/error-report.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/error-report.c b/util/error-report.c index 98f242b75bbf..893da10f19bc 100644 --- a/util/error-report.c +++ b/util/error-report.c @@ -195,16 +195,17 @@ real_time_iso8601(void) */ static void vreport(report_type type, const char *fmt, va_list ap) { + bool detailed =3D !monitor_cur(); gchar *timestr; =20 - if (message_with_timestamp && !monitor_cur()) { + if (message_with_timestamp && detailed) { timestr =3D real_time_iso8601(); error_printf("%s ", timestr); g_free(timestr); } =20 /* Only prepend guest name if -msg guest-name and -name guest=3D... ar= e set */ - if (error_with_guestname && error_guest_name && !monitor_cur()) { + if (error_with_guestname && error_guest_name && detailed) { error_printf("%s ", error_guest_name); } =20 --=20 2.37.0.rc0 From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655384152; cv=none; d=zohomail.com; s=zohoarc; b=Gzi5p4qOHrnpo+07wKuBbD90WEHMjrsc783zfHxJ5GZAS8e9gOYJYqywddpSOrRjHzcOToLiKcDaW5kbP338kzC/5DedsQLq3b8q1czHIOr1NLOrVW0MYTRZ0U4GeR60xYaBcGND7UjykeNZpQj0WFJue/xzR/DmFL7ZijDlq30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655384152; 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=1o27EBUfNWT2QpBtPZu+Zc5UCpj4z+bwGHt6RXKOyfU=; b=cDZvs63GDqwr1dAr07it88EAK3UoVPQ9+0zsX4hSeBB4XdoLZpIFUzwV1WeuLBYtxRVJdXTEy9ZFcc26KzdDJHj/y6JXi/CV7l49pPqMJcup0Nbxei8uqSORBBi+zdYYzAk6/a3ULTACva60D0hobuDVIINwzOSgcYKXj/aj8SM= 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+importer=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 1655384152302525.1715563195622; Thu, 16 Jun 2022 05:55:52 -0700 (PDT) Received: from localhost ([::1]:55324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1p2M-0001Yn-7c for importer@patchew.org; Thu, 16 Jun 2022 08:55:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooO-0001Cq-E7 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1oo5-0005P7-N7 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:24 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-178-HahSN54VO6i1XBLDQsxNdQ-1; Thu, 16 Jun 2022 08:40:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CDA771C1C1A9; Thu, 16 Jun 2022 12:40:58 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2EB92166B26; Thu, 16 Jun 2022 12:40:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383263; 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=1o27EBUfNWT2QpBtPZu+Zc5UCpj4z+bwGHt6RXKOyfU=; b=BdWtmv09avGtKvJzZ7XECsu/Zi/SuNZshsMwURS4THsguWuHYsiZPvtvstB+ghEVnjuwuz 6yClNDYaWlvWv8ywQY/FGqDiNd8drQCV5xTNYN1qy518wwP5VPgfTZRZEeaZGbFXdRiZki hp3LB3IEjtpRo7GfvJWu4BWwrff/DHs= X-MC-Unique: HahSN54VO6i1XBLDQsxNdQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 4/9] error-report: simplify print_loc() Date: Thu, 16 Jun 2022 16:40:29 +0400 Message-Id: <20220616124034.3381391-5-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655384153316100001 From: Marc-Andr=C3=A9 Lureau Pass the program name as "prefix" argument to print_loc() if printing with "details". This allows to get rid of monitor_cur() call in print_loc(). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- util/error-report.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/error-report.c b/util/error-report.c index 893da10f19bc..c43227a975e2 100644 --- a/util/error-report.c +++ b/util/error-report.c @@ -138,14 +138,14 @@ void loc_set_file(const char *fname, int lno) /* * Print current location to current monitor if we have one, else to stder= r. */ -static void print_loc(void) +static void print_loc(const char *prefix) { const char *sep =3D ""; int i; const char *const *argp; =20 - if (!monitor_cur() && g_get_prgname()) { - error_printf("%s:", g_get_prgname()); + if (prefix) { + error_printf("%s:", prefix); sep =3D " "; } switch (cur_loc->kind) { @@ -209,7 +209,7 @@ static void vreport(report_type type, const char *fmt, = va_list ap) error_printf("%s ", error_guest_name); } =20 - print_loc(); + print_loc(detailed ? g_get_prgname() : NULL); =20 switch (type) { case REPORT_TYPE_ERROR: --=20 2.37.0.rc0 From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655385373; cv=none; d=zohomail.com; s=zohoarc; b=Ryrik5XWJXWukKUYwl8FG+EIIt/RnfKcj/V6mAmM1UcdIlC9jOE4/km9uvsZjJXpnxn8Fm7VZn40wJ3NpCwi8WmDStgLIaWD5CblCyq2Yc8+SXR0UmYwQ3rUyuf1c0p3z0lXlEEiZmaiQXrzisiJoSN/A55x4u5ji0R4uPU6LcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655385373; 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=LJXySoeq0t7JZM5RA/pyaMohMd2V1GfWM/4dE5+QpiU=; b=X/mdPJgWis7u6ev8znGPoA/xm3fr8ZZ20BZWeqc9h+UyJ0FErXh22dHPPvNO4KUj760JRDNi06O323upkLf+T+EUIXkI+oTBWvYRMEvJypwbotM1CiJJee+xTRxw/A1GuFXM64vO6ozUGlsagqnOdR2+wWAzwGx685AeknrJph8= 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+importer=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 1655385373394313.4164732451479; Thu, 16 Jun 2022 06:16:13 -0700 (PDT) Received: from localhost ([::1]:35982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1pM3-0002Ay-66 for importer@patchew.org; Thu, 16 Jun 2022 09:16:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooW-0001R0-By for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooM-0005Vw-Hp for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:32 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-440--GFDmYZlPrivwdr_DbXIcg-1; Thu, 16 Jun 2022 08:41:04 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3CCC29DD98A; Thu, 16 Jun 2022 12:41:03 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86B17492CA8; Thu, 16 Jun 2022 12:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383275; 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=LJXySoeq0t7JZM5RA/pyaMohMd2V1GfWM/4dE5+QpiU=; b=LmBqBOtXLfTkxsSJevkFoxCVDacIaRYYvLHKoyl/9dPP6q0RxWayY78MaTKdGYpbgLALQc 0VxfxvoNsrSmZXJ93UFswSVt5J5RpAnc2ucV/zOJ5gOG6K4MDP9EVvvN65fsrTM3cfq48h +pZX8YfVZAcgPR2VoHfGfC9rSu/8oUg= X-MC-Unique: -GFDmYZlPrivwdr_DbXIcg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 5/9] error-report: introduce ErrorReportDetailedFunc Date: Thu, 16 Jun 2022 16:40:30 +0400 Message-Id: <20220616124034.3381391-6-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655385374582100001 From: Marc-Andr=C3=A9 Lureau Remove monitor dependency from error printing code, by allowing programs to set a callback for when to use "detailed" reporting or not. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Warner Losh --- include/qemu/error-report.h | 4 +++- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- qemu-img.c | 2 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- scsi/qemu-pr-helper.c | 2 +- softmmu/vl.c | 7 ++++++- storage-daemon/qemu-storage-daemon.c | 7 ++++++- util/error-report.c | 8 +++++--- 10 files changed, 26 insertions(+), 12 deletions(-) diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index 3ae2357fda54..e2e630f207f0 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -13,6 +13,8 @@ #ifndef QEMU_ERROR_REPORT_H #define QEMU_ERROR_REPORT_H =20 +typedef bool (*ErrorReportDetailedFunc)(void); + typedef struct Location { /* all members are private to qemu-error.c */ enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; @@ -46,7 +48,7 @@ bool error_report_once_cond(bool *printed, const char *fm= t, ...) bool warn_report_once_cond(bool *printed, const char *fmt, ...) G_GNUC_PRINTF(2, 3); =20 -void error_init(const char *argv0); +void error_init(const char *argv0, ErrorReportDetailedFunc detailed_fn); =20 /* * Similar to error_report(), except it prints the message just once. diff --git a/bsd-user/main.c b/bsd-user/main.c index 6f09180d6541..d5f8fca863d7 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -292,7 +292,7 @@ int main(int argc, char **argv) =20 save_proc_pathname(argv[0]); =20 - error_init(argv[0]); + error_init(argv[0], NULL); module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); module_call_init(MODULE_INIT_QOM); diff --git a/linux-user/main.c b/linux-user/main.c index 651e32f5f248..84f380bd366d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -646,7 +646,7 @@ int main(int argc, char **argv, char **envp) unsigned long max_reserved_va; bool preserve_argv0; =20 - error_init(argv[0]); + error_init(argv[0], NULL); module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); module_call_init(MODULE_INIT_QOM); diff --git a/qemu-img.c b/qemu-img.c index 4cf4d2423df8..1f27a9fc70f6 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5396,7 +5396,7 @@ int main(int argc, char **argv) #endif =20 socket_init(); - error_init(argv[0]); + error_init(argv[0], NULL); module_call_init(MODULE_INIT_TRACE); qemu_init_exec_dir(argv[0]); =20 diff --git a/qemu-io.c b/qemu-io.c index 2bd7bfb65073..b5cdc7c922a7 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -539,7 +539,7 @@ int main(int argc, char **argv) #endif =20 socket_init(); - error_init(argv[0]); + error_init(argv[0], NULL); module_call_init(MODULE_INIT_TRACE); qemu_init_exec_dir(argv[0]); =20 diff --git a/qemu-nbd.c b/qemu-nbd.c index 0cd5aa6f02bc..6bc632c93611 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -587,7 +587,7 @@ int main(int argc, char **argv) #endif =20 socket_init(); - error_init(argv[0]); + error_init(argv[0], NULL); module_call_init(MODULE_INIT_TRACE); qcrypto_init(&error_fatal); =20 diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 196b78c00df5..8d80e58d4498 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -910,7 +910,7 @@ int main(int argc, char **argv) =20 signal(SIGPIPE, SIG_IGN); =20 - error_init(argv[0]); + error_init(argv[0], NULL); module_call_init(MODULE_INIT_TRACE); module_call_init(MODULE_INIT_QOM); qemu_add_opts(&qemu_trace_opts); diff --git a/softmmu/vl.c b/softmmu/vl.c index 54e920ada1a1..3b46fc9c1fc5 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2590,6 +2590,11 @@ void qmp_x_exit_preconfig(Error **errp) } } =20 +static bool error_is_detailed(void) +{ + return !monitor_cur(); +} + void qemu_init(int argc, char **argv, char **envp) { QemuOpts *opts; @@ -2634,7 +2639,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_add_opts(&qemu_action_opts); module_call_init(MODULE_INIT_OPTS); =20 - error_init(argv[0]); + error_init(argv[0], error_is_detailed); qemu_init_exec_dir(argv[0]); =20 qemu_init_arch_modules(); diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index c104817cdddc..7e4d5030a045 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -368,13 +368,18 @@ static void pid_file_init(void) atexit(pid_file_cleanup); } =20 +static bool error_is_detailed(void) +{ + return !monitor_cur(); +} + int main(int argc, char *argv[]) { #ifdef CONFIG_POSIX signal(SIGPIPE, SIG_IGN); #endif =20 - error_init(argv[0]); + error_init(argv[0], error_is_detailed); qemu_init_exec_dir(argv[0]); os_setup_signal_handling(); =20 diff --git a/util/error-report.c b/util/error-report.c index c43227a975e2..c2181f80a83d 100644 --- a/util/error-report.c +++ b/util/error-report.c @@ -11,7 +11,6 @@ */ =20 #include "qemu/osdep.h" -#include "monitor/monitor.h" #include "qemu/error-report.h" =20 /* @@ -28,6 +27,7 @@ typedef enum { bool message_with_timestamp; bool error_with_guestname; const char *error_guest_name; +ErrorReportDetailedFunc detailed_fn =3D NULL; =20 int error_printf(const char *fmt, ...) { @@ -195,7 +195,7 @@ real_time_iso8601(void) */ static void vreport(report_type type, const char *fmt, va_list ap) { - bool detailed =3D !monitor_cur(); + bool detailed =3D detailed_fn ? detailed_fn() : TRUE; gchar *timestr; =20 if (message_with_timestamp && detailed) { @@ -387,7 +387,7 @@ static void qemu_log_func(const gchar *log_domain, } } =20 -void error_init(const char *argv0) +void error_init(const char *argv0, ErrorReportDetailedFunc detailed) { const char *p =3D strrchr(argv0, '/'); =20 @@ -401,4 +401,6 @@ void error_init(const char *argv0) g_log_set_default_handler(qemu_log_func, NULL); g_warn_if_fail(qemu_glog_domains =3D=3D NULL); qemu_glog_domains =3D g_strdup(g_getenv("G_MESSAGES_DEBUG")); + + detailed_fn =3D detailed; } --=20 2.37.0.rc0 From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655385187; cv=none; d=zohomail.com; s=zohoarc; b=GnLIRnw4RX9b4kXS7sxBRTaAoTMNrTtjagCIx5ptsh54bSLD2T9g6Y5k1laNiSVVDqdZpd4muOF565fIOLKITELUOxBbdQRp4F6DEdIF7+Ye0G93L1EIdMlTNEli3xMlS9zaegYbWHbdaNHbOspNy4hSdQQpy7xx6aR8G9/eJZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655385187; 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=w4voxXrKbyhL/lOz9FRDmaZJ++LuTFoliK+/VyoayUo=; b=hbRa5wqF90ab4G9l3J5xY1jE+womfvS45z22Abn56gSYcHaOgC09eH9RIqXGp1u9JgGWUbg8Flybvpz1IJhRqIKRdpgVwf5cqj8NHDjtpVfGGqE2tfIdBKp+C5sQ/fl9Wgk42QrUer/9TyunGSv7WCnXuad+Zq8fF11vziYY6J0= 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+importer=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 1655385187499524.3853857815494; Thu, 16 Jun 2022 06:13:07 -0700 (PDT) Received: from localhost ([::1]:56736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1pJ3-0005XR-PW for importer@patchew.org; Thu, 16 Jun 2022 09:13:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooT-0001Kq-M5 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooK-0005Yp-6h for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:29 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-Xn-lT_swMpOT305bRNzjOw-1; Thu, 16 Jun 2022 08:41:11 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E1F1D833976; Thu, 16 Jun 2022 12:41:10 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2235D492CA5; Thu, 16 Jun 2022 12:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383277; 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=w4voxXrKbyhL/lOz9FRDmaZJ++LuTFoliK+/VyoayUo=; b=TK3+8MqopHrh8z27Kcmg4LuXJwim5N/4aHN2+4+sMCMaNSkdB+Xzu79/Tz7KawieuA2dJV +909asxmflm5i1GMC9DpFynXvFUwDDZ3ZibueEOXojK1rdC5Eonck9Dl+bRRolgW2ApRIj fbZf09QJc7YxWukecY822FYLk237xX0= X-MC-Unique: Xn-lT_swMpOT305bRNzjOw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 6/9] error-report: add a callback to overwrite error_vprintf Date: Thu, 16 Jun 2022 16:40:31 +0400 Message-Id: <20220616124034.3381391-7-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655385189240100001 From: Marc-Andr=C3=A9 Lureau error_vprintf() is implemented in monitor.c, which overrides the default implementation from stubs/, while avoiding a direct dependency to the monitor from error-report.c. However, the stub solution isn't working when moving error-report.c and stubs/error-printf.c in a common library. Linking with such library creates conflicts for the error_vprintf() implementations (and weak symbols aren't great either). Instead, use the "traditional" approach to provide overidable callbacks. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/monitor/monitor.h | 1 + include/qemu/error-report.h | 6 ++++-- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- monitor/monitor.c | 2 +- qemu-img.c | 2 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- scsi/qemu-pr-helper.c | 2 +- softmmu/vl.c | 2 +- storage-daemon/qemu-storage-daemon.c | 2 +- stubs/error-printf.c | 18 ------------------ util/error-report.c | 27 ++++++++++++++++++++++++--- stubs/meson.build | 1 - 14 files changed, 38 insertions(+), 33 deletions(-) delete mode 100644 stubs/error-printf.c diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 44653e195b45..e94ab2e74889 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -16,6 +16,7 @@ extern QemuOptsList qemu_mon_opts; Monitor *monitor_cur(void); Monitor *monitor_set_cur(Coroutine *co, Monitor *mon); bool monitor_cur_is_qmp(void); +int monitor_error_vprintf(const char *fmt, va_list ap); =20 void monitor_init_globals(void); void monitor_init_globals_core(void); diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index e2e630f207f0..a2bc030b4bfe 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -14,6 +14,7 @@ #define QEMU_ERROR_REPORT_H =20 typedef bool (*ErrorReportDetailedFunc)(void); +typedef int (*ErrorReportVPrintfFunc)(const char *fmt, va_list ap) G_GNUC_= PRINTF(1, 0); =20 typedef struct Location { /* all members are private to qemu-error.c */ @@ -32,7 +33,6 @@ void loc_set_none(void); void loc_set_cmdline(char **argv, int idx, int cnt); void loc_set_file(const char *fname, int lno); =20 -int error_vprintf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0); int error_printf(const char *fmt, ...) G_GNUC_PRINTF(1, 2); =20 void error_vreport(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0); @@ -48,7 +48,9 @@ bool error_report_once_cond(bool *printed, const char *fm= t, ...) bool warn_report_once_cond(bool *printed, const char *fmt, ...) G_GNUC_PRINTF(2, 3); =20 -void error_init(const char *argv0, ErrorReportDetailedFunc detailed_fn); +void error_init(const char *argv0, + ErrorReportDetailedFunc detailed_fn, + ErrorReportVPrintfFunc vprintf_fn); =20 /* * Similar to error_report(), except it prints the message just once. diff --git a/bsd-user/main.c b/bsd-user/main.c index d5f8fca863d7..1cc1ba9b2e6e 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -292,7 +292,7 @@ int main(int argc, char **argv) =20 save_proc_pathname(argv[0]); =20 - error_init(argv[0], NULL); + error_init(argv[0], NULL, NULL); module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); module_call_init(MODULE_INIT_QOM); diff --git a/linux-user/main.c b/linux-user/main.c index 84f380bd366d..75f72099739d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -646,7 +646,7 @@ int main(int argc, char **argv, char **envp) unsigned long max_reserved_va; bool preserve_argv0; =20 - error_init(argv[0], NULL); + error_init(argv[0], NULL, NULL); module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); module_call_init(MODULE_INIT_QOM); diff --git a/monitor/monitor.c b/monitor/monitor.c index ba4c1716a48a..490e7babd895 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -263,7 +263,7 @@ int monitor_printf(Monitor *mon, const char *fmt, ...) /* * Print to current monitor if we have one, else to stderr. */ -int error_vprintf(const char *fmt, va_list ap) +int monitor_error_vprintf(const char *fmt, va_list ap) { Monitor *cur_mon =3D monitor_cur(); =20 diff --git a/qemu-img.c b/qemu-img.c index 1f27a9fc70f6..00383f48f7bc 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5396,7 +5396,7 @@ int main(int argc, char **argv) #endif =20 socket_init(); - error_init(argv[0], NULL); + error_init(argv[0], NULL, NULL); module_call_init(MODULE_INIT_TRACE); qemu_init_exec_dir(argv[0]); =20 diff --git a/qemu-io.c b/qemu-io.c index b5cdc7c922a7..09794cd781be 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -539,7 +539,7 @@ int main(int argc, char **argv) #endif =20 socket_init(); - error_init(argv[0], NULL); + error_init(argv[0], NULL, NULL); module_call_init(MODULE_INIT_TRACE); qemu_init_exec_dir(argv[0]); =20 diff --git a/qemu-nbd.c b/qemu-nbd.c index 6bc632c93611..112303674cfb 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -587,7 +587,7 @@ int main(int argc, char **argv) #endif =20 socket_init(); - error_init(argv[0], NULL); + error_init(argv[0], NULL, NULL); module_call_init(MODULE_INIT_TRACE); qcrypto_init(&error_fatal); =20 diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 8d80e58d4498..d265d11b6261 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -910,7 +910,7 @@ int main(int argc, char **argv) =20 signal(SIGPIPE, SIG_IGN); =20 - error_init(argv[0], NULL); + error_init(argv[0], NULL, NULL); module_call_init(MODULE_INIT_TRACE); module_call_init(MODULE_INIT_QOM); qemu_add_opts(&qemu_trace_opts); diff --git a/softmmu/vl.c b/softmmu/vl.c index 3b46fc9c1fc5..ef54af0efd6f 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2639,7 +2639,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_add_opts(&qemu_action_opts); module_call_init(MODULE_INIT_OPTS); =20 - error_init(argv[0], error_is_detailed); + error_init(argv[0], error_is_detailed, monitor_error_vprintf); qemu_init_exec_dir(argv[0]); =20 qemu_init_arch_modules(); diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-sto= rage-daemon.c index 7e4d5030a045..0e0893695628 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -379,7 +379,7 @@ int main(int argc, char *argv[]) signal(SIGPIPE, SIG_IGN); #endif =20 - error_init(argv[0], error_is_detailed); + error_init(argv[0], error_is_detailed, monitor_error_vprintf); qemu_init_exec_dir(argv[0]); os_setup_signal_handling(); =20 diff --git a/stubs/error-printf.c b/stubs/error-printf.c deleted file mode 100644 index 1afa0f62ca26..000000000000 --- a/stubs/error-printf.c +++ /dev/null @@ -1,18 +0,0 @@ -#include "qemu/osdep.h" -#include "qemu/error-report.h" -#include "monitor/monitor.h" - -int error_vprintf(const char *fmt, va_list ap) -{ - int ret; - - if (g_test_initialized() && !g_test_subprocess() && - getenv("QTEST_SILENT_ERRORS")) { - char *msg =3D g_strdup_vprintf(fmt, ap); - g_test_message("%s", msg); - ret =3D strlen(msg); - g_free(msg); - return ret; - } - return vfprintf(stderr, fmt, ap); -} diff --git a/util/error-report.c b/util/error-report.c index c2181f80a83d..1452047cd2e8 100644 --- a/util/error-report.c +++ b/util/error-report.c @@ -23,11 +23,14 @@ typedef enum { REPORT_TYPE_INFO, } report_type; =20 +static int error_vprintf(const char *fmt, va_list ap); + /* Prepend timestamp to messages */ bool message_with_timestamp; bool error_with_guestname; const char *error_guest_name; ErrorReportDetailedFunc detailed_fn =3D NULL; +ErrorReportVPrintfFunc vprintf_fn =3D error_vprintf; =20 int error_printf(const char *fmt, ...) { @@ -35,7 +38,7 @@ int error_printf(const char *fmt, ...) int ret; =20 va_start(ap, fmt); - ret =3D error_vprintf(fmt, ap); + ret =3D vprintf_fn(fmt, ap); va_end(ap); return ret; } @@ -222,7 +225,7 @@ static void vreport(report_type type, const char *fmt, = va_list ap) break; } =20 - error_vprintf(fmt, ap); + vprintf_fn(fmt, ap); error_printf("\n"); } =20 @@ -387,7 +390,24 @@ static void qemu_log_func(const gchar *log_domain, } } =20 -void error_init(const char *argv0, ErrorReportDetailedFunc detailed) +static int error_vprintf(const char *fmt, va_list ap) +{ + int ret; + + if (g_test_initialized() && !g_test_subprocess() && + getenv("QTEST_SILENT_ERRORS")) { + char *msg =3D g_strdup_vprintf(fmt, ap); + g_test_message("%s", msg); + ret =3D strlen(msg); + g_free(msg); + return ret; + } + return vfprintf(stderr, fmt, ap); +} + +void error_init(const char *argv0, + ErrorReportDetailedFunc detailed, + ErrorReportVPrintfFunc vprintf) { const char *p =3D strrchr(argv0, '/'); =20 @@ -403,4 +423,5 @@ void error_init(const char *argv0, ErrorReportDetailedF= unc detailed) qemu_glog_domains =3D g_strdup(g_getenv("G_MESSAGES_DEBUG")); =20 detailed_fn =3D detailed; + vprintf_fn =3D vprintf ?: error_vprintf; } diff --git a/stubs/meson.build b/stubs/meson.build index d8f3fd5c44f2..498b6ee0466e 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -9,7 +9,6 @@ stub_ss.add(files('cpus-get-virtual-clock.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('icount.c')) stub_ss.add(files('dump.c')) -stub_ss.add(files('error-printf.c')) stub_ss.add(files('fdset.c')) stub_ss.add(files('gdbstub.c')) stub_ss.add(files('get-vm-name.c')) --=20 2.37.0.rc0 From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655384812; cv=none; d=zohomail.com; s=zohoarc; b=DblZ2HFMTLZjV2pZJGlMW0VEHeNO71LvILtZ8YVddHDqT8llkvP+l/bXhQxI1GKCQznAVKkv6QCM+1MN4nceRL3B6DebDPfzKqRFIC1gPGXyR919f60Q1oiuhLfFCXS2VqjlwBB2IDLOAGijNDnyhA0eoQgTpydGEp1nYxKMe00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655384812; 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=4JCwGVreW5Z5NC5FZ9pjBxLt89NA5vi3SysqTGNE1zk=; b=BtfgkPVwqeVrrwUs9Wz9uz8ebaLQt8H9c1RcJqU3EjaraQn4SkEQ3MqNqI/gaSl6TjrWoQzusjWN+LsPsHGPHVuoWrqlOWMZuKyuDIgHYC2Am6664jG3GglRdiOhD5Qia6UFG8jBNZDx15iLGqxgLZa7msdSj0SAGtn9BpI3xb8= 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+importer=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 1655384812808775.3208820064345; Thu, 16 Jun 2022 06:06:52 -0700 (PDT) Received: from localhost ([::1]:41846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1pD1-0003jd-IW for importer@patchew.org; Thu, 16 Jun 2022 09:06:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooW-0001SC-SQ for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23674) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooN-0005ZD-N5 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:32 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-283-8YAX20ZCMKOsEfH_co3-qQ-1; Thu, 16 Jun 2022 08:41:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CC57D802D1C; Thu, 16 Jun 2022 12:41:15 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90D061121314; Thu, 16 Jun 2022 12:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383279; 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=4JCwGVreW5Z5NC5FZ9pjBxLt89NA5vi3SysqTGNE1zk=; b=Nl84ir6tgIpQYDEnFgo1zm5CjcM0IDE9Mh01co9O5BOAAoIOHXscSgfX4UeELSAiLJuOTu GnkvM+WNXUNjQtFU+8sbUDIbLJaLqZB+F0Z+5t1x+aYg2DlA2reXWXpVS/crqKoyW2qpqT H4ApD/Wl2FeXu3TLzJfsy6GWjz1M3/E= X-MC-Unique: 8YAX20ZCMKOsEfH_co3-qQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 7/9] qapi: move QEMU-specific dispatch code in monitor Date: Thu, 16 Jun 2022 16:40:32 +0400 Message-Id: <20220616124034.3381391-8-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655384815170100001 From: Marc-Andr=C3=A9 Lureau Make QMP-dispatch code free from QEMU-specific OOB dispatch/async coroutine handling. This will allow to move the base code to qemu-common, and clear other users from potential mis-ususe (QGA doesn't have OOB or coroutine). To do that, introduce an optional callback QmpDispatchRun called when a QMP command should be run, to allow QEMU to override the default behaviour. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/qmp/dispatch.h | 7 ++-- monitor/qmp.c | 68 ++++++++++++++++++++++++++++++++++++- qapi/qmp-dispatch.c | 64 +++------------------------------- qga/main.c | 2 +- tests/unit/test-qmp-cmds.c | 6 ++-- 5 files changed, 81 insertions(+), 66 deletions(-) diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 1e4240fd0dbc..b659da613f2e 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -14,7 +14,6 @@ #ifndef QAPI_QMP_DISPATCH_H #define QAPI_QMP_DISPATCH_H =20 -#include "monitor/monitor.h" #include "qemu/queue.h" =20 typedef void (QmpCommandFunc)(QDict *, QObject **, Error **); @@ -41,6 +40,10 @@ typedef struct QmpCommand =20 typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList; =20 +typedef void (QmpDispatchRun)(bool oob, const QmpCommand *cmd, + QDict *args, QObject **ret, Error **errp, + void *run_data); + void qmp_register_command(QmpCommandList *cmds, const char *name, QmpCommandFunc *fn, QmpCommandOptions options, unsigned special_features); @@ -56,7 +59,7 @@ const char *qmp_command_name(const QmpCommand *cmd); bool qmp_has_success_response(const QmpCommand *cmd); QDict *qmp_error_response(Error *err); QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, - bool allow_oob, Monitor *cur_mon); + bool allow_oob, QmpDispatchRun run_cb, void *run_data); bool qmp_is_oob(const QDict *dict); =20 typedef void (*qmp_cmd_callback_fn)(const QmpCommand *cmd, void *opaque); diff --git a/monitor/qmp.c b/monitor/qmp.c index 092c527b6fc9..f8dec97c96bb 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -132,6 +132,72 @@ static void monitor_qmp_respond(MonitorQMP *mon, QDict= *rsp) } } =20 +typedef struct QmpDispatchBH { + const QmpCommand *cmd; + Monitor *cur_mon; + QDict *args; + QObject **ret; + Error **errp; + Coroutine *co; +} QmpDispatchBH; + +static void do_qmp_dispatch_bh(void *opaque) +{ + QmpDispatchBH *data =3D opaque; + + assert(monitor_cur() =3D=3D NULL); + monitor_set_cur(qemu_coroutine_self(), data->cur_mon); + data->cmd->fn(data->args, data->ret, data->errp); + monitor_set_cur(qemu_coroutine_self(), NULL); + aio_co_wake(data->co); +} + +/* + * Runs outside of coroutine context for OOB commands, but in coroutine + * context for everything else. + */ +static void qmp_dispatch_run(bool oob, const QmpCommand *cmd, + QDict *args, QObject **ret, Error **errp, + void *run_data) +{ + Monitor *cur_mon =3D run_data; + + assert(!(oob && qemu_in_coroutine())); + assert(monitor_cur() =3D=3D NULL); + + if (!!(cmd->options & QCO_COROUTINE) =3D=3D qemu_in_coroutine()) { + monitor_set_cur(qemu_coroutine_self(), cur_mon); + cmd->fn(args, ret, errp); + monitor_set_cur(qemu_coroutine_self(), NULL); + } else { + /* + * Actual context doesn't match the one the command needs. + * + * Case 1: we are in coroutine context, but command does not + * have QCO_COROUTINE. We need to drop out of coroutine + * context for executing it. + * + * Case 2: we are outside coroutine context, but command has + * QCO_COROUTINE. Can't actually happen, because we get here + * outside coroutine context only when executing a command + * out of band, and OOB commands never have QCO_COROUTINE. + */ + assert(!oob && qemu_in_coroutine() && !(cmd->options & QCO_COROUTI= NE)); + + QmpDispatchBH data =3D { + .cur_mon =3D cur_mon, + .cmd =3D cmd, + .args =3D args, + .ret =3D ret, + .errp =3D errp, + .co =3D qemu_coroutine_self(), + }; + aio_bh_schedule_oneshot(qemu_get_aio_context(), do_qmp_dispatch_bh, + &data); + qemu_coroutine_yield(); + } +} + /* * Runs outside of coroutine context for OOB commands, but in * coroutine context for everything else. @@ -142,7 +208,7 @@ static void monitor_qmp_dispatch(MonitorQMP *mon, QObje= ct *req) QDict *error; =20 rsp =3D qmp_dispatch(mon->commands, req, qmp_oob_enabled(mon), - &mon->common); + qmp_dispatch_run, &mon->common); =20 if (mon->commands =3D=3D &qmp_cap_negotiation_commands) { error =3D qdict_get_qdict(rsp, "error"); diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 0990873ec8ec..342b13d7ebbd 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -13,7 +13,6 @@ =20 #include "qemu/osdep.h" =20 -#include "block/aio.h" #include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/dispatch.h" @@ -22,8 +21,6 @@ #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" #include "qapi/qmp/qbool.h" -#include "qemu/coroutine.h" -#include "qemu/main-loop.h" =20 Visitor *qobject_input_visitor_new_qmp(QObject *obj) { @@ -110,32 +107,8 @@ bool qmp_is_oob(const QDict *dict) && !qdict_haskey(dict, "execute"); } =20 -typedef struct QmpDispatchBH { - const QmpCommand *cmd; - Monitor *cur_mon; - QDict *args; - QObject **ret; - Error **errp; - Coroutine *co; -} QmpDispatchBH; - -static void do_qmp_dispatch_bh(void *opaque) -{ - QmpDispatchBH *data =3D opaque; - - assert(monitor_cur() =3D=3D NULL); - monitor_set_cur(qemu_coroutine_self(), data->cur_mon); - data->cmd->fn(data->args, data->ret, data->errp); - monitor_set_cur(qemu_coroutine_self(), NULL); - aio_co_wake(data->co); -} - -/* - * Runs outside of coroutine context for OOB commands, but in coroutine - * context for everything else. - */ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, - bool allow_oob, Monitor *cur_mon) + bool allow_oob, QmpDispatchRun run_cb, void *run_data) { Error *err =3D NULL; bool oob; @@ -203,39 +176,12 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObje= ct *request, qobject_ref(args); } =20 - assert(!(oob && qemu_in_coroutine())); - assert(monitor_cur() =3D=3D NULL); - if (!!(cmd->options & QCO_COROUTINE) =3D=3D qemu_in_coroutine()) { - monitor_set_cur(qemu_coroutine_self(), cur_mon); - cmd->fn(args, &ret, &err); - monitor_set_cur(qemu_coroutine_self(), NULL); + if (run_cb) { + run_cb(oob, cmd, args, &ret, &err, run_data); } else { - /* - * Actual context doesn't match the one the command needs. - * - * Case 1: we are in coroutine context, but command does not - * have QCO_COROUTINE. We need to drop out of coroutine - * context for executing it. - * - * Case 2: we are outside coroutine context, but command has - * QCO_COROUTINE. Can't actually happen, because we get here - * outside coroutine context only when executing a command - * out of band, and OOB commands never have QCO_COROUTINE. - */ - assert(!oob && qemu_in_coroutine() && !(cmd->options & QCO_COROUTI= NE)); - - QmpDispatchBH data =3D { - .cur_mon =3D cur_mon, - .cmd =3D cmd, - .args =3D args, - .ret =3D &ret, - .errp =3D &err, - .co =3D qemu_coroutine_self(), - }; - aio_bh_schedule_oneshot(qemu_get_aio_context(), do_qmp_dispatch_bh, - &data); - qemu_coroutine_yield(); + cmd->fn(args, &ret, &err); } + qobject_unref(args); if (err) { /* or assert(!ret) after reviewing all handlers: */ diff --git a/qga/main.c b/qga/main.c index c373fec3ee69..fb7d673bea9f 100644 --- a/qga/main.c +++ b/qga/main.c @@ -569,7 +569,7 @@ static void process_event(void *opaque, QObject *obj, E= rror *err) } =20 g_debug("processing command"); - rsp =3D qmp_dispatch(&ga_commands, obj, false, NULL); + rsp =3D qmp_dispatch(&ga_commands, obj, false, NULL, NULL); =20 end: ret =3D send_response(s, rsp); diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c index 6085c099950b..abe67a9bd880 100644 --- a/tests/unit/test-qmp-cmds.c +++ b/tests/unit/test-qmp-cmds.c @@ -150,7 +150,7 @@ static QObject *do_qmp_dispatch(bool allow_oob, const c= har *template, ...) req =3D qdict_from_vjsonf_nofail(template, ap); va_end(ap); =20 - resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob, NULL); + resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob, NULL, NU= LL); g_assert(resp); ret =3D qdict_get(resp, "return"); g_assert(ret); @@ -173,7 +173,7 @@ static void do_qmp_dispatch_error(bool allow_oob, Error= Class cls, req =3D qdict_from_vjsonf_nofail(template, ap); va_end(ap); =20 - resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob, NULL); + resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob, NULL, NU= LL); g_assert(resp); error =3D qdict_get_qdict(resp, "error"); g_assert(error); @@ -229,7 +229,7 @@ static void test_dispatch_cmd_success_response(void) QDict *resp; =20 qdict_put_str(req, "execute", "cmd-success-response"); - resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), false, NULL); + resp =3D qmp_dispatch(&qmp_commands, QOBJECT(req), false, NULL, NULL); g_assert_null(resp); qobject_unref(req); } --=20 2.37.0.rc0 From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655385135; cv=none; d=zohomail.com; s=zohoarc; b=UxzB9Hl9kYo9uOl0GR9z0o7j+SijP/zvr+0hFXO6xEvT9gKBI+vHVBdBFHXtJvsj53BQME3E42Eqx+EZiRxoiGq7QEkLvvoFwTo86DCAUuuYPF+dHTSycUB/L3GIM5gpmmx29bbgDPg19QGfRz/3B+EoV0MO2mj9rwiiNmJyjGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655385135; 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=qY6ywvOwDLELLr7tGfvyNuCLoI0xFYiPWuPvnh0yL98=; b=guFZeeGkAwU2mzyhwn5hzb1WSEI3+3ksdJAnqNhV0qRfD+9h9lVkcdnmChHWeptJITPlaYrqfYQx3uOXrDgUNWTtZXF0N127uUEEgX8MNQItgnpTnDSl0OhN5Mk7Yek71oUuQ6F6YfLNC+osNyEgeWxTRDfno63/SkMPdjK835Y= 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+importer=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 1655385135144787.4799591997801; Thu, 16 Jun 2022 06:12:15 -0700 (PDT) Received: from localhost ([::1]:54118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1pID-0003nE-9J for importer@patchew.org; Thu, 16 Jun 2022 09:12:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooZ-0001UI-Fy for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooV-0005r8-Gy for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:35 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-323-xpvjDBBwO1u7XapfK7ptsg-1; Thu, 16 Jun 2022 08:41:26 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7E9F3833285; Thu, 16 Jun 2022 12:41:25 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF067492CA5; Thu, 16 Jun 2022 12:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383290; 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=qY6ywvOwDLELLr7tGfvyNuCLoI0xFYiPWuPvnh0yL98=; b=UQx59USx+6KovYHUaYLKBUyPYokeJsMnbRgnyutw3xgGiLi0vXlHO7t7CrHZF+KImu73jV YrsP8iEPNoboDeMAu+MI8ZMPgBLKW4EjDvWApp5EfsJ5i85emRjO+Dg2OfWTkoXWKfrhWn j3w6RguqkzrNil8nRKe17g7jAjgDxME= X-MC-Unique: xpvjDBBwO1u7XapfK7ptsg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 8/9] scripts/qapi-gen: add -i option Date: Thu, 16 Jun 2022 16:40:33 +0400 Message-Id: <20220616124034.3381391-9-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655385136913100001 From: Marc-Andr=C3=A9 Lureau Replace hard-coded "qemu/osdep.h" include with a qapi-gen option to specify the headers to include. This will allow to substitute QEMU osdep.h with glib.h for example, for projects with different global headers. For historical reasons, we can keep the default as "qemu/osdep.h". Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/commands.py | 15 ++++++++++----- scripts/qapi/events.py | 17 +++++++++++------ scripts/qapi/gen.py | 17 +++++++++++++++++ scripts/qapi/introspect.py | 11 +++++++---- scripts/qapi/main.py | 17 +++++++++++------ scripts/qapi/types.py | 17 +++++++++++------ scripts/qapi/visit.py | 17 +++++++++++------ 7 files changed, 78 insertions(+), 33 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 38ca38a7b9dd..781491b6390d 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -294,9 +294,9 @@ def gen_register_command(name: str, =20 =20 class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): - def __init__(self, prefix: str, gen_tracing: bool): + def __init__(self, prefix: str, include: List[str], gen_tracing: bool): super().__init__( - prefix, 'qapi-commands', + prefix, include, 'qapi-commands', ' * Schema-defined QAPI/QMP commands', None, __doc__, gen_tracing=3Dgen_tracing) self._visited_ret_types: Dict[QAPIGenC, Set[QAPISchemaType]] =3D {} @@ -308,7 +308,8 @@ def _begin_user_module(self, name: str) -> None: types =3D self._module_basename('qapi-types', name) visit =3D self._module_basename('qapi-visit', name) self._genc.add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "qapi/compat-policy.h" #include "qapi/visitor.h" #include "qapi/qmp/qdict.h" @@ -318,6 +319,7 @@ def _begin_user_module(self, name: str) -> None: #include "%(commands)s.h" =20 ''', + include=3Dself.genc_include(), commands=3Dcommands, visit=3Dvisit)) =20 if self._gen_tracing and commands !=3D 'qapi-commands': @@ -344,7 +346,8 @@ def visit_begin(self, schema: QAPISchema) -> None: ''', c_prefix=3Dc_name(self._prefix, protect=3DFal= se))) self._genc.add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "%(prefix)sqapi-commands.h" #include "%(prefix)sqapi-init-commands.h" =20 @@ -353,6 +356,7 @@ def visit_begin(self, schema: QAPISchema) -> None: QTAILQ_INIT(cmds); =20 ''', + include=3Dself.genc_include(), prefix=3Dself._prefix, c_prefix=3Dc_name(self._prefix, protect=3DFal= se))) =20 @@ -404,7 +408,8 @@ def visit_command(self, def gen_commands(schema: QAPISchema, output_dir: str, prefix: str, + include: List[str], gen_tracing: bool) -> None: - vis =3D QAPISchemaGenCommandVisitor(prefix, gen_tracing) + vis =3D QAPISchemaGenCommandVisitor(prefix, include, gen_tracing) schema.visit(vis) vis.write(output_dir) diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 27b44c49f5e9..6e677d11d2e0 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -175,9 +175,9 @@ def gen_event_send(name: str, =20 class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): =20 - def __init__(self, prefix: str): + def __init__(self, prefix: str, include: List[str]): super().__init__( - prefix, 'qapi-events', + prefix, include, 'qapi-events', ' * Schema-defined QAPI/QMP events', None, __doc__) self._event_enum_name =3D c_name(prefix + 'QAPIEvent', protect=3DF= alse) self._event_enum_members: List[QAPISchemaEnumMember] =3D [] @@ -188,7 +188,8 @@ def _begin_user_module(self, name: str) -> None: types =3D self._module_basename('qapi-types', name) visit =3D self._module_basename('qapi-visit', name) self._genc.add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "%(prefix)sqapi-emit-events.h" #include "%(events)s.h" #include "%(visit)s.h" @@ -198,6 +199,7 @@ def _begin_user_module(self, name: str) -> None: #include "qapi/qmp-event.h" =20 ''', + include=3Dself.genc_include(), events=3Devents, visit=3Dvisit, prefix=3Dself._prefix)) self._genh.add(mcgen(''' @@ -209,9 +211,11 @@ def _begin_user_module(self, name: str) -> None: def visit_end(self) -> None: self._add_module('./emit', ' * QAPI Events emission') self._genc.preamble_add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "%(prefix)sqapi-emit-events.h" ''', + include=3Dself.genc_include(), prefix=3Dself._prefix)) self._genh.preamble_add(mcgen(''' #include "qapi/util.h" @@ -246,7 +250,8 @@ def visit_event(self, =20 def gen_events(schema: QAPISchema, output_dir: str, - prefix: str) -> None: - vis =3D QAPISchemaGenEventVisitor(prefix) + prefix: str, + include: List[str]) -> None: + vis =3D QAPISchemaGenEventVisitor(prefix, include) schema.visit(vis) vis.write(output_dir) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 113b49134de4..54a70a5ff516 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -17,6 +17,7 @@ from typing import ( Dict, Iterator, + List, Optional, Sequence, Tuple, @@ -45,6 +46,12 @@ def gen_special_features(features: Sequence[QAPISchemaFe= ature]) -> str: return ' | '.join(special_features) or '0' =20 =20 +def genc_include(include: List[str]) -> str: + return '\n'.join(['#include ' + + (f'"{inc}"' if inc[0] not in ('<', '"') else inc) + for inc in include]) + + class QAPIGen: def __init__(self, fname: str): self.fname =3D fname @@ -228,16 +235,21 @@ def ifcontext(ifcond: QAPISchemaIfCond, *args: QAPIGe= nCCode) -> Iterator[None]: class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor): def __init__(self, prefix: str, + include: List[str], what: str, blurb: str, pydoc: str): self._prefix =3D prefix + self._include =3D include self._what =3D what self._genc =3D QAPIGenC(self._prefix + self._what + '.c', blurb, pydoc) self._genh =3D QAPIGenH(self._prefix + self._what + '.h', blurb, pydoc) =20 + def genc_include(self) -> str: + return genc_include(self._include) + def write(self, output_dir: str) -> None: self._genc.write(output_dir) self._genh.write(output_dir) @@ -246,12 +258,14 @@ def write(self, output_dir: str) -> None: class QAPISchemaModularCVisitor(QAPISchemaVisitor): def __init__(self, prefix: str, + include: List[str], what: str, user_blurb: str, builtin_blurb: Optional[str], pydoc: str, gen_tracing: bool =3D False): self._prefix =3D prefix + self._include =3D include self._what =3D what self._user_blurb =3D user_blurb self._builtin_blurb =3D builtin_blurb @@ -262,6 +276,9 @@ def __init__(self, self._main_module: Optional[str] =3D None self._gen_tracing =3D gen_tracing =20 + def genc_include(self) -> str: + return genc_include(self._include) + @property def _genc(self) -> QAPIGenC: assert self._current_module is not None diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 67c7d89aae00..d965d1769447 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -170,9 +170,9 @@ def to_c_string(string: str) -> str: =20 class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithicCVisitor): =20 - def __init__(self, prefix: str, unmask: bool): + def __init__(self, prefix: str, include: List[str], unmask: bool): super().__init__( - prefix, 'qapi-introspect', + prefix, include, 'qapi-introspect', ' * QAPI/QMP schema introspection', __doc__) self._unmask =3D unmask self._schema: Optional[QAPISchema] =3D None @@ -180,10 +180,12 @@ def __init__(self, prefix: str, unmask: bool): self._used_types: List[QAPISchemaType] =3D [] self._name_map: Dict[str, str] =3D {} self._genc.add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "%(prefix)sqapi-introspect.h" =20 ''', + include=3Dself.genc_include(), prefix=3Dprefix)) =20 def visit_begin(self, schema: QAPISchema) -> None: @@ -384,7 +386,8 @@ def visit_event(self, name: str, info: Optional[QAPISou= rceInfo], =20 =20 def gen_introspect(schema: QAPISchema, output_dir: str, prefix: str, + include: List[str], opt_unmask: bool) -> None: - vis =3D QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) + vis =3D QAPISchemaGenIntrospectVisitor(prefix, include, opt_unmask) schema.visit(vis) vis.write(output_dir) diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py index fc216a53d32a..eba98cb9ace2 100644 --- a/scripts/qapi/main.py +++ b/scripts/qapi/main.py @@ -9,7 +9,7 @@ =20 import argparse import sys -from typing import Optional +from typing import List, Optional =20 from .commands import gen_commands from .common import must_match @@ -31,6 +31,7 @@ def invalid_prefix_char(prefix: str) -> Optional[str]: def generate(schema_file: str, output_dir: str, prefix: str, + include: List[str], unmask: bool =3D False, builtins: bool =3D False, gen_tracing: bool =3D False) -> None: @@ -48,11 +49,11 @@ def generate(schema_file: str, assert invalid_prefix_char(prefix) is None =20 schema =3D QAPISchema(schema_file) - gen_types(schema, output_dir, prefix, builtins) - gen_visit(schema, output_dir, prefix, builtins) - gen_commands(schema, output_dir, prefix, gen_tracing) - gen_events(schema, output_dir, prefix) - gen_introspect(schema, output_dir, prefix, unmask) + gen_types(schema, output_dir, prefix, include, builtins) + gen_visit(schema, output_dir, prefix, include, builtins) + gen_commands(schema, output_dir, prefix, include, gen_tracing) + gen_events(schema, output_dir, prefix, include) + gen_introspect(schema, output_dir, prefix, include, unmask) =20 =20 def main() -> int: @@ -75,6 +76,9 @@ def main() -> int: parser.add_argument('-u', '--unmask-non-abi-names', action=3D'store_tr= ue', dest=3D'unmask', help=3D"expose non-ABI names in introspection") + parser.add_argument('-i', '--include', nargs=3D'*', + default=3D['qemu/osdep.h'], + help=3D"top-level include headers") =20 # Option --suppress-tracing exists so we can avoid solving build system # problems. TODO Drop it when we no longer need it. @@ -94,6 +98,7 @@ def main() -> int: generate(args.schema, output_dir=3Dargs.output_dir, prefix=3Dargs.prefix, + include=3Dargs.include, unmask=3Dargs.unmask, builtins=3Dargs.builtins, gen_tracing=3Dnot args.suppress_tracing) diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 477d02700137..9617b7d4edfa 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -282,18 +282,20 @@ def gen_type_cleanup(name: str) -> str: =20 class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor): =20 - def __init__(self, prefix: str): + def __init__(self, prefix: str, include: List[str]): super().__init__( - prefix, 'qapi-types', ' * Schema-defined QAPI types', + prefix, include, 'qapi-types', ' * Schema-defined QAPI types', ' * Built-in QAPI types', __doc__) =20 def _begin_builtin_module(self) -> None: self._genc.preamble_add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "qapi/dealloc-visitor.h" #include "qapi/qapi-builtin-types.h" #include "qapi/qapi-builtin-visit.h" -''')) +''', + include=3Dself.genc_include())) self._genh.preamble_add(mcgen(''' #include "qapi/util.h" ''')) @@ -302,11 +304,13 @@ def _begin_user_module(self, name: str) -> None: types =3D self._module_basename('qapi-types', name) visit =3D self._module_basename('qapi-visit', name) self._genc.preamble_add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "qapi/dealloc-visitor.h" #include "%(types)s.h" #include "%(visit)s.h" ''', + include=3Dself.genc_include(), types=3Dtypes, visit=3Dvisit)) self._genh.preamble_add(mcgen(''' #include "qapi/qapi-builtin-types.h" @@ -381,7 +385,8 @@ def visit_alternate_type(self, def gen_types(schema: QAPISchema, output_dir: str, prefix: str, + include: List[str], opt_builtins: bool) -> None: - vis =3D QAPISchemaGenTypeVisitor(prefix) + vis =3D QAPISchemaGenTypeVisitor(prefix, include) schema.visit(vis) vis.write(output_dir, opt_builtins) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 380fa197f589..1ff464c0360f 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -318,17 +318,19 @@ def gen_visit_object(name: str) -> str: =20 class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor): =20 - def __init__(self, prefix: str): + def __init__(self, prefix: str, include: List[str]): super().__init__( - prefix, 'qapi-visit', ' * Schema-defined QAPI visitors', + prefix, include, 'qapi-visit', ' * Schema-defined QAPI visitor= s', ' * Built-in QAPI visitors', __doc__) =20 def _begin_builtin_module(self) -> None: self._genc.preamble_add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "qapi/error.h" #include "qapi/qapi-builtin-visit.h" -''')) +''', + include=3Dself.genc_include())) self._genh.preamble_add(mcgen(''' #include "qapi/visitor.h" #include "qapi/qapi-builtin-types.h" @@ -339,11 +341,13 @@ def _begin_user_module(self, name: str) -> None: types =3D self._module_basename('qapi-types', name) visit =3D self._module_basename('qapi-visit', name) self._genc.preamble_add(mcgen(''' -#include "qemu/osdep.h" +%(include)s + #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "%(visit)s.h" ''', + include=3Dself.genc_include(), visit=3Dvisit)) self._genh.preamble_add(mcgen(''' #include "qapi/qapi-builtin-visit.h" @@ -408,7 +412,8 @@ def visit_alternate_type(self, def gen_visit(schema: QAPISchema, output_dir: str, prefix: str, + include: List[str], opt_builtins: bool) -> None: - vis =3D QAPISchemaGenVisitVisitor(prefix) + vis =3D QAPISchemaGenVisitVisitor(prefix, include) schema.visit(vis) vis.write(output_dir, opt_builtins) --=20 2.37.0.rc0 From nobody Mon Feb 9 19:11:42 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1655385664; cv=none; d=zohomail.com; s=zohoarc; b=hjAKZ9ckKK8lZGt1BWsNLw6eLvMlzy/YMiwiPwlfp7PwKDfV0j3XIEUfPeWLhJReienpcYWVCzFWGMr6/Lx8a5gO0kmYqugLdvXAsYatRkkL1sThQlwKOeksUAilU1caBp1ORBY0p1Q5RL42aGLJLO3nsqUgge76K5xBtHfzrKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655385664; 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=Et7o+gm789s34jZqe/LwIE8WIv+NIHpOHYPmrL3ytP8=; b=bUBUFr1qf1imgFpStFGgv5ASt2Sc4Jas2p2cnHgRXeBfHRSoqzD0AeIPhXopr8qp69vFcwDQTUC5wKbwzeE3690Ga2H6QvsWL5NOzsQouJgg2nEgeOBwGldfjnMAb3QTyR+2QHl+mVeAofoArJ2ns2QchzmQ+phKQhcDp4nVHaQ= 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+importer=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 1655385664262585.7337920121578; Thu, 16 Jun 2022 06:21:04 -0700 (PDT) Received: from localhost ([::1]:43260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1pQl-0007TX-52 for importer@patchew.org; Thu, 16 Jun 2022 09:21:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ooe-0001X3-N5 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1ood-0005sN-4b for qemu-devel@nongnu.org; Thu, 16 Jun 2022 08:41:40 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-mf8Vj5tQNSCy7A57D0VbIw-1; Thu, 16 Jun 2022 08:41:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 301D5101E986; Thu, 16 Jun 2022 12:41:31 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D71D111F5; Thu, 16 Jun 2022 12:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655383295; 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=Et7o+gm789s34jZqe/LwIE8WIv+NIHpOHYPmrL3ytP8=; b=bbG1g7pZ8MUlOY2W7dp6upgt4+ynMwHO6P4ArcrqlRS3mZnRDYGrrCGrRQnNqc4XnAF+17 1ZTcO5ODTG4oU2Oy2IrLhcyBUx/I7N6KtPZ6nMbDgcwz2k8wOyd1riddTo3UUkQdNUQrt3 JsQlmAXOq4QwYDaBcGfUMD56ZPKNMT8= X-MC-Unique: mf8Vj5tQNSCy7A57D0VbIw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Kevin Wolf , Laurent Vivier , Warner Losh , Kyle Evans , Hanna Reitz , Vladimir Sementsov-Ogievskiy , Fam Zheng , Eric Blake , "Dr. David Alan Gilbert" , Paolo Bonzini , qemu-block@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 9/9] scripts/qapi: add required system includes to visitor Date: Thu, 16 Jun 2022 16:40:34 +0400 Message-Id: <20220616124034.3381391-10-marcandre.lureau@redhat.com> In-Reply-To: <20220616124034.3381391-1-marcandre.lureau@redhat.com> References: <20220616124034.3381391-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1655385666545100001 From: Marc-Andr=C3=A9 Lureau The generated visitor code includes abort() & assert(), we shouldn't rely on the global "-i" headers to include the necessary system headers. Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi/visit.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 1ff464c0360f..d686df17f4b6 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -326,6 +326,8 @@ def __init__(self, prefix: str, include: List[str]): def _begin_builtin_module(self) -> None: self._genc.preamble_add(mcgen(''' %(include)s +#include +#include =20 #include "qapi/error.h" #include "qapi/qapi-builtin-visit.h" @@ -342,6 +344,8 @@ def _begin_user_module(self, name: str) -> None: visit =3D self._module_basename('qapi-visit', name) self._genc.preamble_add(mcgen(''' %(include)s +#include +#include =20 #include "qapi/error.h" #include "qapi/qmp/qerror.h" --=20 2.37.0.rc0