From nobody Mon Feb 9 13:25:08 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=1657619029; cv=none; d=zohomail.com; s=zohoarc; b=inPqm26sCSglCEM3mWxgP/sNGOVTCS6x0w/8NmYpSwjxaPizpTWVpz6WnTg0lIBMiMbUjwwK67A7rPHeeHvv9rKk5B7AdCr7xL5cY590NUg0LTd9DPukN3PJ/ZMd1tT/vwp6fHsVhcuSCNuvpnI5JDJL+03R8KnVZkY+Y8yDbtw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619029; 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=fuUMfnKM4RKA8OiTM4aAaBM6S7QmPOnfp6bFoWwhm54=; b=ngL6xNrIdfwGDdsEdc1NljeYqAv2V9GAhAvpGx15m7V6GBbGsd4TCoCMR+UD7vJeIaUo+N2E8lHsVr44rXs7Y3+ogsfu0W6z4hPcXaEcW6qyvG43HE+p1vi+up8AkfmL3dRjLYDYRZMMQ/wZy86Pf8arUTY6XlXt8YaoeAhNVDY= 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 1657619029128366.29650844253035; Tue, 12 Jul 2022 02:43:49 -0700 (PDT) Received: from localhost ([::1]:35722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCQl-0004XI-03 for importer@patchew.org; Tue, 12 Jul 2022 05:43:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJ7-0005Bo-W2 for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:35:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJ5-0006Sb-Ez for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:35:52 -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-350-NANvpr9ROKK2F-b4prIhFg-1; Tue, 12 Jul 2022 05:35:41 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0CB30811E7A; Tue, 12 Jul 2022 09:35:41 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18B96C15D40; Tue, 12 Jul 2022 09:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618550; 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=fuUMfnKM4RKA8OiTM4aAaBM6S7QmPOnfp6bFoWwhm54=; b=KZSkELt7vZZ47Cn2WyDYOknMXDP6eAlkDBUKfJbg4PL6i6FpmxPU4HqWgmYW3wRHCkyAo0 2DCidt+E1t+2v3jQJTnxRgPNd4e6+t0661iyvy1xpbxK3juQI76o28YhTpc3a+2sk13xXC Wi3JOVKHtxgPRb9+K0cVrnD5gywY0nE= X-MC-Unique: NANvpr9ROKK2F-b4prIhFg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 01/15] error-report: misc comment fix Date: Tue, 12 Jul 2022 13:35:14 +0400 Message-Id: <20220712093528.4144184-2-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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.8 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: 1657619029786100001 From: Marc-Andr=C3=A9 Lureau Missed in commit beeb175c0d "util/qemu-error: Rename error_print_loc() to be more generic". 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 13:25:08 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=1657619045; cv=none; d=zohomail.com; s=zohoarc; b=djxMDDuNvKcJmkZDu1nsKRa0oc6RQ8MUpM4Yj5zI/Xr5s+2Two5TUMDOfFPvNlWV5GX8RuFIPQCGHYS2t6ldlNuIadN3ULWokMI08xdyOZ5XNPegIx/T4zz1zFOSgsja1k9lcqCjV5APGxmhttAY9awauHTXhnAb+t6xLhoCFq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619045; 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=RzBc0nl4yI9EOA558uood9/BjlvTEJkzBDosBBKzsnk=; b=Ub458onCjiKR+LPvG/B2qpPb70X5pqMp4+OSfDeT8z0R/Jvl+GLW6oU2W8F8KlueRUw3G3l1MFLpGKqSqbe+LdD9VxSr9GuYpyuHe7zy7TyzVkS4m2MRHw+yz734C8UTmHrPoMGS2ag2ZMoosV0Lhl417rJKNBtbLJNXDjxzplY= 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 1657619045366380.0575937277557; Tue, 12 Jul 2022 02:44:05 -0700 (PDT) Received: from localhost ([::1]:36598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCR1-0005BM-Df for importer@patchew.org; Tue, 12 Jul 2022 05:44:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJ9-0005I1-Et for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:35:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJ7-0006Vj-HP for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:35:55 -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-427-FKTduMrANg2r4WvaBzKfVg-1; Tue, 12 Jul 2022 05:35:49 -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 1FF3F811E7A; Tue, 12 Jul 2022 09:35:49 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13AD9492C3B; Tue, 12 Jul 2022 09:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618552; 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=RzBc0nl4yI9EOA558uood9/BjlvTEJkzBDosBBKzsnk=; b=PoRUXeDMpGgaOZng/G+1WT3RucGbf//0w/Vbrtuxd4/wkDUKLGfQuooJZHTgVMmlPFHS5J Cgh0OJi64N4VdE9MYLUuAYNB4y/cNBuFlemnv/L01FWV7QjmYtQ2gN2Z0zMZsE/1+yV2X1 NXD9V30WGrXLoskgJ6xgrdH3lAJO4fE= X-MC-Unique: FKTduMrANg2r4WvaBzKfVg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 02/15] error-report: introduce "detailed" variable Date: Tue, 12 Jul 2022 13:35:15 +0400 Message-Id: <20220712093528.4144184-3-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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: -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: 1657619047545100001 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 13:25:08 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=1657618864; cv=none; d=zohomail.com; s=zohoarc; b=X7FJnSFVFDP0xwoerIv08OZfuWyxRjT3jVZLr850pwa0NqFHwPpovdrM4SLm1ekMmq4fN6m7hVsQzhFdsc1rJv52SSbNEnvUa4dQ9MNJVXy0IwLPL0jjzUPqwRE+MLBND9Krqak3Sc6nFJfS+0Ffj6h79wsYi7ZYEE2caiRuYwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657618864; 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=K/MaKWOw9mwRiSAv5OIby/ogCfM8Tj/+vc4r0Ph5fLA=; b=hxNOyWXVRBjfcx7koARDXuJmBHlj3S4QMUS7K4pC55bilHFss+lDHyoRBU6EUrqxU6Y9gOAOqs7sLFCj0c1MIB30ZEGnXbLjJpJMHN7NhvkYIv6PM88+gLh6ONFBwfx5XOoFOZg2ADJ3uFm295g4lxEXMxKqJi1xu3hHVuGfwvc= 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 1657618864340408.7968399194717; Tue, 12 Jul 2022 02:41:04 -0700 (PDT) Received: from localhost ([::1]:58346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCO6-0000by-Sf for importer@patchew.org; Tue, 12 Jul 2022 05:41:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJL-0005Yn-Rd for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJJ-0007JG-VM for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:07 -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-664-IRRLzPbUP_GD-ZNhdW3HEQ-1; Tue, 12 Jul 2022 05:35:55 -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 C80BF185A7A4; Tue, 12 Jul 2022 09:35:54 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2C1A40D2827; Tue, 12 Jul 2022 09:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618565; 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=K/MaKWOw9mwRiSAv5OIby/ogCfM8Tj/+vc4r0Ph5fLA=; b=BiAra7xBWzKC+Te+1nVTTz0YRMzaonxvnlEHJdqLRbCRiFE8taXJKcMc+F6NoRbk9Uap6p I/dAwBpEM1Xg+hAuVO5rIvejdXNgSUdaGVS2y2AgQFUY3OMmH62Gu8yQyKfNbpy7xC+yIP aoRfBg26sx6Zyc0qG6jDU2iK5ezf6zc= X-MC-Unique: IRRLzPbUP_GD-ZNhdW3HEQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 03/15] error-report: simplify print_loc() Date: Tue, 12 Jul 2022 13:35:16 +0400 Message-Id: <20220712093528.4144184-4-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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, 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: 1657618866151100001 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 13:25:08 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=1657618861; cv=none; d=zohomail.com; s=zohoarc; b=dELn0KnPVEOxaJx0199FRiIWSKV/iq1h5uCE6iSJVfd5l9KgewUbZFNjVblzTa3zx9ktsW67le4MaoknNyjBk1rk77B2w4fap6+uvg6wdgYRUXteS5Gm8sCk3jibLoyFzVQhnyo3dLPM2gCk5muwB4pi+m91JDAvAm60sSlbqvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657618861; 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=xLG7pzYYdIpBU8lBmZPOqdZcw4LD0xxWf/VdLqmbweo=; b=ivmP2qLIgRb+nrlz3BNaxfCaGCnxS8Ie4IZVyE9iW90Temb2Kxb7KRuyiq8edH1RJ/nHgVLdJ1/CpfG1ASK7Owgc7prIwAqTL58Tt4+eJvUBIi2AvnPEYkKQ5kPrjfuuHfbWcHwoTgZGpkDHNjXzRtqeEo/G9t5B4pKiYpcjvtQ= 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 1657618861142173.9482326106545; Tue, 12 Jul 2022 02:41:01 -0700 (PDT) Received: from localhost ([::1]:58358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCO2-0000cE-7t for importer@patchew.org; Tue, 12 Jul 2022 05:40:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36164) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJM-0005ZP-7i for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJK-0007Gp-6S for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:07 -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-407-vc7OhPtGMguSnYLY7tCPjQ-1; Tue, 12 Jul 2022 05:36:00 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DAB5E3801F58; Tue, 12 Jul 2022 09:35:59 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id B75B5C15D40; Tue, 12 Jul 2022 09:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618564; 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=xLG7pzYYdIpBU8lBmZPOqdZcw4LD0xxWf/VdLqmbweo=; b=ifCJOq7WVr0g6BKmglwaSyFA039pjRWmmAnc0VkkkODe3jTXilPQq5ixtCqlaaWLXFX6Bu I4V7V6VHQfPUpldgnyhG8EN1nwNTxICxflMoYD0fsGuZSpnGdcap/wqJMIHgOlrUjUUt5Q kda0Ablhbk/aQ5HZ4RuHAfEGG2LVny4= X-MC-Unique: vc7OhPtGMguSnYLY7tCPjQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 04/15] error-report: introduce overridable error_is_detailed() Date: Tue, 12 Jul 2022 13:35:17 +0400 Message-Id: <20220712093528.4144184-5-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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.8 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: -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: 1657618862774100001 From: Marc-Andr=C3=A9 Lureau Remove the direct dependency from error-report to monitor code. This will allow to move error-report to a subproject. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster Reviewed-by: Warner Losh --- include/qemu/error-report.h | 2 ++ softmmu/vl.c | 5 +++++ stubs/error-is-detailed.c | 7 +++++++ util/error-report.c | 3 +-- stubs/meson.build | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 stubs/error-is-detailed.c diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index 3ae2357fda54..6ab25d458350 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -30,6 +30,8 @@ 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 +bool error_is_detailed(void); + 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 diff --git a/softmmu/vl.c b/softmmu/vl.c index 3f264d4b0930..f94efc56e9d6 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2589,6 +2589,11 @@ void qmp_x_exit_preconfig(Error **errp) } } =20 +bool error_is_detailed(void) +{ + return !monitor_cur(); +} + void qemu_init(int argc, char **argv, char **envp) { QemuOpts *opts; diff --git a/stubs/error-is-detailed.c b/stubs/error-is-detailed.c new file mode 100644 index 000000000000..c47cd236932f --- /dev/null +++ b/stubs/error-is-detailed.c @@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "qemu/error-report.h" + +bool error_is_detailed(void) +{ + return TRUE; +} diff --git a/util/error-report.c b/util/error-report.c index c43227a975e2..4d1d66fc0650 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 /* @@ -195,7 +194,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 error_is_detailed(); gchar *timestr; =20 if (message_with_timestamp && detailed) { diff --git a/stubs/meson.build b/stubs/meson.build index d8f3fd5c44f2..0f3a782824f9 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -9,6 +9,7 @@ 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-is-detailed.c')) stub_ss.add(files('error-printf.c')) stub_ss.add(files('fdset.c')) stub_ss.add(files('gdbstub.c')) --=20 2.37.0.rc0 From nobody Mon Feb 9 13:25:08 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=1657619369; cv=none; d=zohomail.com; s=zohoarc; b=SwGNVUZxSSyku+xQ+FXJZhRBeVdCDkJ1Pzna6pmuV4cDW33fWBEt3FxOncnarzxB1wJ5aKSErlZ+CZQvXPJ7WAMmIR1YDxGkmC5tNSrNbSIgjI3zDFJRZZvmCJu69w54L9rhvZRhlCQeGkva3YH3PpVXDaxOY5Kn7Yh5YbJba5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619369; 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=3OqpB+v/S1ya+tHPrgwpEKnb0oJgbtfZmhbkdweK5/A=; b=GrUCVsJNJYnIsouWFOuNTpGbVjy6+vk1oF+OGhnrzUfVPNE24vCzW7TRQoM2LL917F/aI1zTs59xQxnLHXpwZan3DOGQZOkGDQ2GBT3s5xNq0urZr2/e6hXOL9HAppXkl9d+xfUA9ypPgZwlw47W3yDrHU4VYheJY0JXn1RbT+k= 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 1657619369548543.5700933721781; Tue, 12 Jul 2022 02:49:29 -0700 (PDT) Received: from localhost ([::1]:44828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCWG-0002fu-AW for importer@patchew.org; Tue, 12 Jul 2022 05:49:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJV-0005at-Nj for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJP-0007aD-Lj for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:12 -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-32-wLlgI-eXP_uE48nl__WOtA-1; Tue, 12 Jul 2022 05:36:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E355280F2A2; Tue, 12 Jul 2022 09:36:06 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AF0E40E7F28; Tue, 12 Jul 2022 09:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618571; 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=3OqpB+v/S1ya+tHPrgwpEKnb0oJgbtfZmhbkdweK5/A=; b=fY4jFr+ESEDkh6TlUHgPlP3PiT0DFzR0DmJkxtDGLlQKSZX+MkF9ilL0OXsdPXPmwFCDJv oFe0Zg+F8qVjWivWWwib0nUmr+IjLLlT3h6+zmXdb6odbhQaK6eL/n5JJbg/pPwAKhlPf0 lL9SCztEqGZc8J4HxtF1yBaAKH1KgIo= X-MC-Unique: wLlgI-eXP_uE48nl__WOtA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 05/15] stubs: remove needless error_vprintf_unless_qmp() Date: Tue, 12 Jul 2022 13:35:18 +0400 Message-Id: <20220712093528.4144184-6-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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.1 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: 1657619371561100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- stubs/error-printf.c | 5 ----- 1 file changed, 5 deletions(-) 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 13:25:08 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=1657619138; cv=none; d=zohomail.com; s=zohoarc; b=m8IltVhV4wNDLJQIY1j2BWhBySY9tf1qeYnjjohkOp4EvruyLvjRcMYj1x7PrGGEgV63iPWY0vPcHCb/1SiwyNnsiF4cg2mqsf0ASMBizjPBHMoCI7xwzQY5CVi4Y0hBGWQT9Tg6m9KSxeniut4Vm9YHw6Aad9TR8XDD1c18cIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619138; 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=W0ofeHGfb8ObgK3VMiiywKY65IZLGUvJjR2WnOo4/weSPF7/rULPiORXsXFuO9ZH99puWzvl/tP5eKCywsQaXXGH219ZW7Jtz2j3r+dRhYrrnh6P/whwMLlU43roPwykho0HOe0fDXPdAsQiCrkHkuTNd+BvlPrS1+rpkFp8YDw= 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 1657619138163901.5506871728134; Tue, 12 Jul 2022 02:45:38 -0700 (PDT) Received: from localhost ([::1]:38582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCSV-0006Xf-Ud for importer@patchew.org; Tue, 12 Jul 2022 05:45:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJb-0005ei-31 for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJZ-0007qH-1M for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:22 -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-583-EObqTvJiP0GNMHhloBoQ6w-1; Tue, 12 Jul 2022 05:36:16 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BCE99811E80; Tue, 12 Jul 2022 09:36:15 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id D854E4B8D64; Tue, 12 Jul 2022 09:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618579; 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=VDfdM7PPbnNqdKnOAmN7p/CWW2NuD2GMMBGtH8kbh2B+EbROMLkOUlLjfo4hAXrpNjQxoc WP/uXrkXq4rof5/Y0ATVGrNrJ/r3Ihck6/4E7wi3WvmQPKcjr3pEzz3rrgPucinXlMITmM BDGXVt9lTMz/sbraslQM23uoArG9nQE= X-MC-Unique: EObqTvJiP0GNMHhloBoQ6w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 06/15] qapi: move QEMU-specific dispatch code in monitor Date: Tue, 12 Jul 2022 13:35:19 +0400 Message-Id: <20220712093528.4144184-7-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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.10 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: -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=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: 1657619140250100001 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 13:25:08 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=1657619382; cv=none; d=zohomail.com; s=zohoarc; b=cL6Tswm21f2kWekehluMdNb77ftEYyNJ7LWRgtPe+aRL5c96OoQr0rCk9RVztY1fr/hLPmxqS98tO9aqJJPKRuFZVcCtvrBWyuwr1pIJv+pf7emLsn8jVD5yTVlmRukwZZRCaODwxGsJ0ca1ExdkpcAoxo0aoSxyggWy27vaiKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619382; 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=ZPEslMeNzNYLD2A1/dmkKgPZLyiqsHpjbeK/+xrOEc5qqPfUmxeVqvtE6Qx5rJ2I+zwwW28HVB0E1ozXFePyeSLoKQBM4hEQz8dAfBX4J+ne97i0/GJ/wfKtzZjTDfDfEXzFiyUvo4GWnf62vKtafrBUnZDVTrqHFDtQR+6t0GM= 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 1657619382154261.13019040987933; Tue, 12 Jul 2022 02:49:42 -0700 (PDT) Received: from localhost ([::1]:45702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCWS-0003HZ-RD for importer@patchew.org; Tue, 12 Jul 2022 05:49:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJm-0005sa-EL for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJk-0000Ba-1W for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:34 -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-452-qTF_3fwbPDGklX6BzFOVYA-1; Tue, 12 Jul 2022 05:36:25 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94126380114F; Tue, 12 Jul 2022 09:36:24 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F166492C3B; Tue, 12 Jul 2022 09:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618591; 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=WgGRe8c1apQqzC4SGfQbkOyM+bVSU5zjBVOBtA1/YH5YRL1jD5hTDZROI//r1DEHGo1Qy3 kNzgyobhpc886c1rl2gtU00H7tJoxXVg+mD+yObIwTyhvOn7i+7WBHA5/Oo0JKI+Tl3T5t AMWKAb3ivy2aASRzXyR36qJ8c63VVew= X-MC-Unique: qTF_3fwbPDGklX6BzFOVYA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 07/15] scripts/qapi-gen: add -i option Date: Tue, 12 Jul 2022 13:35:20 +0400 Message-Id: <20220712093528.4144184-8-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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.10 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: 1657619383705100005 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 13:25:08 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=1657619686; cv=none; d=zohomail.com; s=zohoarc; b=mWc3qnsHdjDJR0T0F1KYdo0qo9YuWivyKTn37jTR/l7lIXdptD1e4qstE/7Ie/byOADmMomMQ2sz4+7Wjgs5drs3Fjk8/TzAniPMhA5PTr/+dQjJLdw4qVdb4/5lFFxSFKflBASasKWOxoRCEc8PbL2PgcArlwfGarA9L0BhhJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619686; 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=K+FOgYZaF/zj4Wy2R8jojVCvIkTSwtlg9ufBkecZgB4=; b=fcp45SxkmUGIOkORnVh6Oh2W6O/ARq1a8tJCgyrjWC9nsPG1j5G/1vS7M1g0Wpdo1UTsFCweW6JmHJgLqPP0MYAowm6/7kqQzV2w5IDCXEF4WvNSi8iVWJf0hh94vGRq1Iskg2pc0iCAyUR49gG09QBdh3SVpVuLZJYKdXRjWoU= 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 1657619686445116.44800177159902; Tue, 12 Jul 2022 02:54:46 -0700 (PDT) Received: from localhost ([::1]:53092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCbM-0008TB-Ur for importer@patchew.org; Tue, 12 Jul 2022 05:54:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJr-00061Q-N6 for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43463) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJp-0000Ni-Qv for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:39 -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-467-zflTnTGuPKqMBWnMOAotAw-1; Tue, 12 Jul 2022 05:36:32 -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 15EF8280D22A; Tue, 12 Jul 2022 09:36:32 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC9D41121314; Tue, 12 Jul 2022 09:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618597; 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=K+FOgYZaF/zj4Wy2R8jojVCvIkTSwtlg9ufBkecZgB4=; b=KepWFMgUnfiRKIjga8b5VDAPpC88EE42Pp0jGPTWgWtYGzWWfiJoysgb0zZoj+iWGHigFB aYTmnNj2CxBxaWHOhDSR2Hd4yzMb19LBbw1ORkOrBX92FWkpCWwChEooGOLMTN5oikpXMH a5zANMQEYZmgWMeEkpb++F4/C6dR7gc= X-MC-Unique: zflTnTGuPKqMBWnMOAotAw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 08/15] scripts/qapi: add required system includes to visitor Date: Tue, 12 Jul 2022 13:35:21 +0400 Message-Id: <20220712093528.4144184-9-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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: -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: 1657619688203100001 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 Reviewed-by: Warner Losh --- scripts/qapi/visit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 1ff464c0360f..4aba5ddd8af4 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -342,6 +342,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 From nobody Mon Feb 9 13:25:08 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=1657619403; cv=none; d=zohomail.com; s=zohoarc; b=bOq+6T3vOs8wLRljGNHp0JuOiwgYy86ieHSQNSDxv5HzINFxeeOk8NGhq6Id6VkoMExCkKIr6a8I1SkenUG/x5fMuEos0akc0d0Lqqj3DIVQPzECcH2KfCfNZYA17X6SJrv9DC5DMtqr1KZrhjdMDHhctjOlON+g5Bc3c6UHGy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619403; 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=Z8s7BnlQQLyedYCxq8eB0w4/jEtYMX51BNhdeSiILOA=; b=SXjvdljglPn9kbuiG9ByC1PWKScfSApylkYO3dj9bDWr54Bqme+npyKYRU/KTkIkgfjbrMI75R48Px9imEo2j2CaAwtEWquHbmo8DhXeRqtobG9ZYqwMoAWJIvWeB7SA4LPZHRHr0gYtGPuBEez3ExAg3UXJN1BtOlA4LChwgXI= 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 165761940349725.18722199967442; Tue, 12 Jul 2022 02:50:03 -0700 (PDT) Received: from localhost ([::1]:47084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCWo-0004F2-Dh for importer@patchew.org; Tue, 12 Jul 2022 05:50:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCK2-00063f-Bm for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCJz-0000dG-Ve for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:50 -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-459-g3-sj1W0PGKImnLZj1Zp9A-1; Tue, 12 Jul 2022 05:36:39 -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 9386B8117B0; Tue, 12 Jul 2022 09:36:38 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id B63131121314; Tue, 12 Jul 2022 09:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618607; 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=Z8s7BnlQQLyedYCxq8eB0w4/jEtYMX51BNhdeSiILOA=; b=U+DQ22ZIE8byOqVesvYDnaAsDGDqJ0fXWCgY9b14gNLCgkODQ5sRD8Lmm8dML9wlX3Facj vqG/PNgqoOrsUSj+Kz8YyDR1dEsmEbof+zyYMrd5IZjJaSQBNDw+bePe1LKKaxtdknRLEq Yu4UrHcuNOUmiVDw04Vl5f+5AGaqxfA= X-MC-Unique: g3-sj1W0PGKImnLZj1Zp9A-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 09/15] util: move 256-by-128 division helpers to int128 Date: Tue, 12 Jul 2022 13:35:22 +0400 Message-Id: <20220712093528.4144184-10-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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: -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: 1657619403943100001 From: Marc-Andr=C3=A9 Lureau Break a cyclic dependency between int128 and host-utils. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Lucas Mateus Castro --- include/qemu/host-utils.h | 3 - include/qemu/int128.h | 3 + util/host-utils.c | 180 -------------------------------------- util/int128.c | 180 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 183 insertions(+), 183 deletions(-) diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h index 29f3a9987880..fa228a4a86e2 100644 --- a/include/qemu/host-utils.h +++ b/include/qemu/host-utils.h @@ -32,7 +32,6 @@ =20 #include "qemu/compiler.h" #include "qemu/bswap.h" -#include "qemu/int128.h" =20 #ifdef CONFIG_INT128 static inline void mulu64(uint64_t *plow, uint64_t *phigh, @@ -785,6 +784,4 @@ static inline uint64_t udiv_qrnnd(uint64_t *r, uint64_t= n1, #endif } =20 -Int128 divu256(Int128 *plow, Int128 *phigh, Int128 divisor); -Int128 divs256(Int128 *plow, Int128 *phigh, Int128 divisor); #endif diff --git a/include/qemu/int128.h b/include/qemu/int128.h index d2b76ca6acdc..823c61edb0fd 100644 --- a/include/qemu/int128.h +++ b/include/qemu/int128.h @@ -472,4 +472,7 @@ static inline void bswap128s(Int128 *s) #define INT128_MAX int128_make128(UINT64_MAX, INT64_MAX) #define INT128_MIN int128_make128(0, INT64_MIN) =20 +Int128 divu256(Int128 *plow, Int128 *phigh, Int128 divisor); +Int128 divs256(Int128 *plow, Int128 *phigh, Int128 divisor); + #endif /* INT128_H */ diff --git a/util/host-utils.c b/util/host-utils.c index fb91bcba823d..96d5dc0bed25 100644 --- a/util/host-utils.c +++ b/util/host-utils.c @@ -266,183 +266,3 @@ void ulshift(uint64_t *plow, uint64_t *phigh, int32_t= shift, bool *overflow) *plow =3D *plow << shift; } } - -/* - * Unsigned 256-by-128 division. - * Returns the remainder via r. - * Returns lower 128 bit of quotient. - * Needs a normalized divisor (most significant bit set to 1). - * - * Adapted from include/qemu/host-utils.h udiv_qrnnd, - * from the GNU Multi Precision Library - longlong.h __udiv_qrnnd - * (https://gmplib.org/repo/gmp/file/tip/longlong.h) - * - * Licensed under the GPLv2/LGPLv3 - */ -static Int128 udiv256_qrnnd(Int128 *r, Int128 n1, Int128 n0, Int128 d) -{ - Int128 d0, d1, q0, q1, r1, r0, m; - uint64_t mp0, mp1; - - d0 =3D int128_make64(int128_getlo(d)); - d1 =3D int128_make64(int128_gethi(d)); - - r1 =3D int128_remu(n1, d1); - q1 =3D int128_divu(n1, d1); - mp0 =3D int128_getlo(q1); - mp1 =3D int128_gethi(q1); - mulu128(&mp0, &mp1, int128_getlo(d0)); - m =3D int128_make128(mp0, mp1); - r1 =3D int128_make128(int128_gethi(n0), int128_getlo(r1)); - if (int128_ult(r1, m)) { - q1 =3D int128_sub(q1, int128_one()); - r1 =3D int128_add(r1, d); - if (int128_uge(r1, d)) { - if (int128_ult(r1, m)) { - q1 =3D int128_sub(q1, int128_one()); - r1 =3D int128_add(r1, d); - } - } - } - r1 =3D int128_sub(r1, m); - - r0 =3D int128_remu(r1, d1); - q0 =3D int128_divu(r1, d1); - mp0 =3D int128_getlo(q0); - mp1 =3D int128_gethi(q0); - mulu128(&mp0, &mp1, int128_getlo(d0)); - m =3D int128_make128(mp0, mp1); - r0 =3D int128_make128(int128_getlo(n0), int128_getlo(r0)); - if (int128_ult(r0, m)) { - q0 =3D int128_sub(q0, int128_one()); - r0 =3D int128_add(r0, d); - if (int128_uge(r0, d)) { - if (int128_ult(r0, m)) { - q0 =3D int128_sub(q0, int128_one()); - r0 =3D int128_add(r0, d); - } - } - } - r0 =3D int128_sub(r0, m); - - *r =3D r0; - return int128_or(int128_lshift(q1, 64), q0); -} - -/* - * Unsigned 256-by-128 division. - * Returns the remainder. - * Returns quotient via plow and phigh. - * Also returns the remainder via the function return value. - */ -Int128 divu256(Int128 *plow, Int128 *phigh, Int128 divisor) -{ - Int128 dhi =3D *phigh; - Int128 dlo =3D *plow; - Int128 rem, dhighest; - int sh; - - if (!int128_nz(divisor) || !int128_nz(dhi)) { - *plow =3D int128_divu(dlo, divisor); - *phigh =3D int128_zero(); - return int128_remu(dlo, divisor); - } else { - sh =3D clz128(divisor); - - if (int128_ult(dhi, divisor)) { - if (sh !=3D 0) { - /* normalize the divisor, shifting the dividend accordingl= y */ - divisor =3D int128_lshift(divisor, sh); - dhi =3D int128_or(int128_lshift(dhi, sh), - int128_urshift(dlo, (128 - sh))); - dlo =3D int128_lshift(dlo, sh); - } - - *phigh =3D int128_zero(); - *plow =3D udiv256_qrnnd(&rem, dhi, dlo, divisor); - } else { - if (sh !=3D 0) { - /* normalize the divisor, shifting the dividend accordingl= y */ - divisor =3D int128_lshift(divisor, sh); - dhighest =3D int128_rshift(dhi, (128 - sh)); - dhi =3D int128_or(int128_lshift(dhi, sh), - int128_urshift(dlo, (128 - sh))); - dlo =3D int128_lshift(dlo, sh); - - *phigh =3D udiv256_qrnnd(&dhi, dhighest, dhi, divisor); - } else { - /* - * dhi >=3D divisor - * Since the MSB of divisor is set (sh =3D=3D 0), - * (dhi - divisor) < divisor - * - * Thus, the high part of the quotient is 1, and we can - * calculate the low part with a single call to udiv_qrnnd - * after subtracting divisor from dhi - */ - dhi =3D int128_sub(dhi, divisor); - *phigh =3D int128_one(); - } - - *plow =3D udiv256_qrnnd(&rem, dhi, dlo, divisor); - } - - /* - * since the dividend/divisor might have been normalized, - * the remainder might also have to be shifted back - */ - rem =3D int128_urshift(rem, sh); - return rem; - } -} - -/* - * Signed 256-by-128 division. - * Returns quotient via plow and phigh. - * Also returns the remainder via the function return value. - */ -Int128 divs256(Int128 *plow, Int128 *phigh, Int128 divisor) -{ - bool neg_quotient =3D false, neg_remainder =3D false; - Int128 unsig_hi =3D *phigh, unsig_lo =3D *plow; - Int128 rem; - - if (!int128_nonneg(*phigh)) { - neg_quotient =3D !neg_quotient; - neg_remainder =3D !neg_remainder; - - if (!int128_nz(unsig_lo)) { - unsig_hi =3D int128_neg(unsig_hi); - } else { - unsig_hi =3D int128_not(unsig_hi); - unsig_lo =3D int128_neg(unsig_lo); - } - } - - if (!int128_nonneg(divisor)) { - neg_quotient =3D !neg_quotient; - - divisor =3D int128_neg(divisor); - } - - rem =3D divu256(&unsig_lo, &unsig_hi, divisor); - - if (neg_quotient) { - if (!int128_nz(unsig_lo)) { - *phigh =3D int128_neg(unsig_hi); - *plow =3D int128_zero(); - } else { - *phigh =3D int128_not(unsig_hi); - *plow =3D int128_neg(unsig_lo); - } - } else { - *phigh =3D unsig_hi; - *plow =3D unsig_lo; - } - - if (neg_remainder) { - return int128_neg(rem); - } else { - return rem; - } -} diff --git a/util/int128.c b/util/int128.c index ed8f25fef161..482c63b6551e 100644 --- a/util/int128.c +++ b/util/int128.c @@ -145,3 +145,183 @@ Int128 int128_rems(Int128 a, Int128 b) } =20 #endif + +/* + * Unsigned 256-by-128 division. + * Returns the remainder via r. + * Returns lower 128 bit of quotient. + * Needs a normalized divisor (most significant bit set to 1). + * + * Adapted from include/qemu/host-utils.h udiv_qrnnd, + * from the GNU Multi Precision Library - longlong.h __udiv_qrnnd + * (https://gmplib.org/repo/gmp/file/tip/longlong.h) + * + * Licensed under the GPLv2/LGPLv3 + */ +static Int128 udiv256_qrnnd(Int128 *r, Int128 n1, Int128 n0, Int128 d) +{ + Int128 d0, d1, q0, q1, r1, r0, m; + uint64_t mp0, mp1; + + d0 =3D int128_make64(int128_getlo(d)); + d1 =3D int128_make64(int128_gethi(d)); + + r1 =3D int128_remu(n1, d1); + q1 =3D int128_divu(n1, d1); + mp0 =3D int128_getlo(q1); + mp1 =3D int128_gethi(q1); + mulu128(&mp0, &mp1, int128_getlo(d0)); + m =3D int128_make128(mp0, mp1); + r1 =3D int128_make128(int128_gethi(n0), int128_getlo(r1)); + if (int128_ult(r1, m)) { + q1 =3D int128_sub(q1, int128_one()); + r1 =3D int128_add(r1, d); + if (int128_uge(r1, d)) { + if (int128_ult(r1, m)) { + q1 =3D int128_sub(q1, int128_one()); + r1 =3D int128_add(r1, d); + } + } + } + r1 =3D int128_sub(r1, m); + + r0 =3D int128_remu(r1, d1); + q0 =3D int128_divu(r1, d1); + mp0 =3D int128_getlo(q0); + mp1 =3D int128_gethi(q0); + mulu128(&mp0, &mp1, int128_getlo(d0)); + m =3D int128_make128(mp0, mp1); + r0 =3D int128_make128(int128_getlo(n0), int128_getlo(r0)); + if (int128_ult(r0, m)) { + q0 =3D int128_sub(q0, int128_one()); + r0 =3D int128_add(r0, d); + if (int128_uge(r0, d)) { + if (int128_ult(r0, m)) { + q0 =3D int128_sub(q0, int128_one()); + r0 =3D int128_add(r0, d); + } + } + } + r0 =3D int128_sub(r0, m); + + *r =3D r0; + return int128_or(int128_lshift(q1, 64), q0); +} + +/* + * Unsigned 256-by-128 division. + * Returns the remainder. + * Returns quotient via plow and phigh. + * Also returns the remainder via the function return value. + */ +Int128 divu256(Int128 *plow, Int128 *phigh, Int128 divisor) +{ + Int128 dhi =3D *phigh; + Int128 dlo =3D *plow; + Int128 rem, dhighest; + int sh; + + if (!int128_nz(divisor) || !int128_nz(dhi)) { + *plow =3D int128_divu(dlo, divisor); + *phigh =3D int128_zero(); + return int128_remu(dlo, divisor); + } else { + sh =3D clz128(divisor); + + if (int128_ult(dhi, divisor)) { + if (sh !=3D 0) { + /* normalize the divisor, shifting the dividend accordingl= y */ + divisor =3D int128_lshift(divisor, sh); + dhi =3D int128_or(int128_lshift(dhi, sh), + int128_urshift(dlo, (128 - sh))); + dlo =3D int128_lshift(dlo, sh); + } + + *phigh =3D int128_zero(); + *plow =3D udiv256_qrnnd(&rem, dhi, dlo, divisor); + } else { + if (sh !=3D 0) { + /* normalize the divisor, shifting the dividend accordingl= y */ + divisor =3D int128_lshift(divisor, sh); + dhighest =3D int128_rshift(dhi, (128 - sh)); + dhi =3D int128_or(int128_lshift(dhi, sh), + int128_urshift(dlo, (128 - sh))); + dlo =3D int128_lshift(dlo, sh); + + *phigh =3D udiv256_qrnnd(&dhi, dhighest, dhi, divisor); + } else { + /* + * dhi >=3D divisor + * Since the MSB of divisor is set (sh =3D=3D 0), + * (dhi - divisor) < divisor + * + * Thus, the high part of the quotient is 1, and we can + * calculate the low part with a single call to udiv_qrnnd + * after subtracting divisor from dhi + */ + dhi =3D int128_sub(dhi, divisor); + *phigh =3D int128_one(); + } + + *plow =3D udiv256_qrnnd(&rem, dhi, dlo, divisor); + } + + /* + * since the dividend/divisor might have been normalized, + * the remainder might also have to be shifted back + */ + rem =3D int128_urshift(rem, sh); + return rem; + } +} + +/* + * Signed 256-by-128 division. + * Returns quotient via plow and phigh. + * Also returns the remainder via the function return value. + */ +Int128 divs256(Int128 *plow, Int128 *phigh, Int128 divisor) +{ + bool neg_quotient =3D false, neg_remainder =3D false; + Int128 unsig_hi =3D *phigh, unsig_lo =3D *plow; + Int128 rem; + + if (!int128_nonneg(*phigh)) { + neg_quotient =3D !neg_quotient; + neg_remainder =3D !neg_remainder; + + if (!int128_nz(unsig_lo)) { + unsig_hi =3D int128_neg(unsig_hi); + } else { + unsig_hi =3D int128_not(unsig_hi); + unsig_lo =3D int128_neg(unsig_lo); + } + } + + if (!int128_nonneg(divisor)) { + neg_quotient =3D !neg_quotient; + + divisor =3D int128_neg(divisor); + } + + rem =3D divu256(&unsig_lo, &unsig_hi, divisor); + + if (neg_quotient) { + if (!int128_nz(unsig_lo)) { + *phigh =3D int128_neg(unsig_hi); + *plow =3D int128_zero(); + } else { + *phigh =3D int128_not(unsig_hi); + *plow =3D int128_neg(unsig_lo); + } + } else { + *phigh =3D unsig_hi; + *plow =3D unsig_lo; + } + + if (neg_remainder) { + return int128_neg(rem); + } else { + return rem; + } +} --=20 2.37.0.rc0 From nobody Mon Feb 9 13:25:08 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=1657619988; cv=none; d=zohomail.com; s=zohoarc; b=KU5CwH/tJYiDaaGwbFZKul4ySr6kWWMJQ7Dnsn3iH8NqqFHOl+zuwDt1+7tqN1Lfd2WfdpTTRsFsycYH6qjmc57YTgDkuwMjmAV5aIIQTp8YXYz2PeOK6MyHJshG1fdvyKV5oCUmp6QaBWn1kEawcgy23DBlabTBQRAZxqRtrl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619988; 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=RSWmqrCRifNkF/Ky3wI4xiwm7h2jr7Ylkixe4+gDIWI=; b=a95j4A7Fra9r8zUKIs2bo+RL/ZB2avSqcB3RZyv+RvJab/gmFwoCol+xezb0Ni+vCBPMaAfx7M54XSg4k0OBkdE8OwBGqQlHKlRn3F/yAA1ceECl9gVjqRibMpHUo1N6M7WWN6hYydveFVmDUlLkvBheErXxXAGiajm+MEucgq4= 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 1657619988285740.2241887545943; Tue, 12 Jul 2022 02:59:48 -0700 (PDT) Received: from localhost ([::1]:33050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCgE-0005il-Ad for importer@patchew.org; Tue, 12 Jul 2022 05:59:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCK5-00066s-1Q for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCK0-0000gP-Ie for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:36:52 -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-523-WRcDgSgDMv-C1_krHwVs6Q-1; Tue, 12 Jul 2022 05:36:44 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38829185A7BA; Tue, 12 Jul 2022 09:36:43 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EF81C15D40; Tue, 12 Jul 2022 09:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618607; 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=RSWmqrCRifNkF/Ky3wI4xiwm7h2jr7Ylkixe4+gDIWI=; b=i/iES+23WB2y839vsFOW6qRN6dnX3dZ1ixhFYgiBLrfXnHmVbqHiyXolCjyy0gX/k2oG3l cKa3PbWUcPe2bN1bxPzKruVOAOwoFlnT1EGB6WymMQAv5WjIm9esqNBwH2NI9u0LWJ5Hov PyQs5ESby4vMZayFKvAvPbFfWCwbR4w= X-MC-Unique: WRcDgSgDMv-C1_krHwVs6Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 10/15] qemu-common: introduce a common subproject Date: Tue, 12 Jul 2022 13:35:23 +0400 Message-Id: <20220712093528.4144184-11-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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.8 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: -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=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: 1657619990396100001 From: Marc-Andr=C3=A9 Lureau Add a new meson subproject to provide common code and scripts for QEMU and tools. Initially, it will offer QAPI/QMP code generation and common utilities. libvhost-user & libvduse will make use of the subproject to avoid having include/ links to common headers. The other targeted user is qemu-ga, which will also be converted to a subproject (so it can be built, moved, released etc independent from QEMU). Other projects such as qemu-storage-daemon could be built standalone eventually in the future. Note that with meson subprojects are "global". Projects will share subprojects (https://mesonbuild.com/Subprojects.html#subprojects-depending-= on-other-subprojects). We will add extra subprojects/ links to allow standalone subproject compilation though. This initial commit simply set the stage to build and link against it. Signed-off-by: Marc-Andr=C3=A9 Lureau --- meson.build | 9 ++++++++- .../qemu-common/include}/qemu/help-texts.h | 0 linux-user/meson.build | 4 ++-- subprojects/libvduse/meson.build | 2 ++ subprojects/libvduse/subprojects/qemu-common | 1 + subprojects/libvhost-user/meson.build | 2 ++ subprojects/libvhost-user/subprojects/qemu-common | 1 + subprojects/qemu-common/meson.build | 8 ++++++++ 8 files changed, 24 insertions(+), 3 deletions(-) rename {include =3D> subprojects/qemu-common/include}/qemu/help-texts.h (1= 00%) create mode 120000 subprojects/libvduse/subprojects/qemu-common create mode 120000 subprojects/libvhost-user/subprojects/qemu-common create mode 100644 subprojects/qemu-common/meson.build diff --git a/meson.build b/meson.build index bc5569ace159..254eb1263a66 100644 --- a/meson.build +++ b/meson.build @@ -167,6 +167,10 @@ if 'dtrace' in get_option('trace_backends') endif endif =20 +add_project_arguments('-I' + meson.current_source_dir() / 'subprojects/qem= u-common/include', + language: ['c', 'cpp', 'objc'], +) + if get_option('iasl') =3D=3D '' iasl =3D find_program('iasl', required: false) else @@ -1577,6 +1581,9 @@ if libbpf.found() and not cc.links(''' endif endif =20 +qemu_common =3D subproject('qemu-common') +qemu_common =3D qemu_common.get_variable('qemu_common_dep') + ################# # config-host.h # ################# @@ -3052,7 +3059,7 @@ util_ss.add_all(trace_ss) util_ss =3D util_ss.apply(config_all, strict: false) libqemuutil =3D static_library('qemuutil', sources: util_ss.sources() + stub_ss.sources(= ) + genh, - dependencies: [util_ss.dependencies(), libm, = threads, glib, socket, malloc, pixman]) + dependencies: [util_ss.dependencies(), libm, = threads, glib, socket, malloc, pixman, qemu_common]) qemuutil =3D declare_dependency(link_with: libqemuutil, sources: genh + version_res, dependencies: [event_loop_base]) diff --git a/include/qemu/help-texts.h b/subprojects/qemu-common/include/qe= mu/help-texts.h similarity index 100% rename from include/qemu/help-texts.h rename to subprojects/qemu-common/include/qemu/help-texts.h diff --git a/linux-user/meson.build b/linux-user/meson.build index de4320af053c..fc6cdb55d657 100644 --- a/linux-user/meson.build +++ b/linux-user/meson.build @@ -7,7 +7,7 @@ linux_user_ss =3D ss.source_set() common_user_inc +=3D include_directories('include/host/' / host_arch) common_user_inc +=3D include_directories('include') =20 -linux_user_ss.add(files( +linux_user_ss.add([files( 'elfload.c', 'exit.c', 'fd-trans.c', @@ -20,7 +20,7 @@ linux_user_ss.add(files( 'thunk.c', 'uaccess.c', 'uname.c', -)) +), qemu_common]) linux_user_ss.add(rt) =20 linux_user_ss.add(when: 'TARGET_HAS_BFLT', if_true: files('flatload.c')) diff --git a/subprojects/libvduse/meson.build b/subprojects/libvduse/meson.= build index ba08f5ee1a03..841509ecb996 100644 --- a/subprojects/libvduse/meson.build +++ b/subprojects/libvduse/meson.build @@ -2,6 +2,8 @@ project('libvduse', 'c', license: 'GPL-2.0-or-later', default_options: ['c_std=3Dgnu99']) =20 +qemu_common =3D subproject('qemu-common') + libvduse =3D static_library('vduse', files('libvduse.c'), c_args: '-D_GNU_SOURCE') diff --git a/subprojects/libvduse/subprojects/qemu-common b/subprojects/lib= vduse/subprojects/qemu-common new file mode 120000 index 000000000000..4c1c87018a7a --- /dev/null +++ b/subprojects/libvduse/subprojects/qemu-common @@ -0,0 +1 @@ +../../qemu-common \ No newline at end of file diff --git a/subprojects/libvhost-user/meson.build b/subprojects/libvhost-u= ser/meson.build index 39825d9404ae..73355908e072 100644 --- a/subprojects/libvhost-user/meson.build +++ b/subprojects/libvhost-user/meson.build @@ -5,6 +5,8 @@ project('libvhost-user', 'c', threads =3D dependency('threads') glib =3D dependency('glib-2.0') =20 +qemu_common =3D subproject('qemu-common') + vhost_user =3D static_library('vhost-user', files('libvhost-user.c'), dependencies: threads, diff --git a/subprojects/libvhost-user/subprojects/qemu-common b/subproject= s/libvhost-user/subprojects/qemu-common new file mode 120000 index 000000000000..4c1c87018a7a --- /dev/null +++ b/subprojects/libvhost-user/subprojects/qemu-common @@ -0,0 +1 @@ +../../qemu-common \ No newline at end of file diff --git a/subprojects/qemu-common/meson.build b/subprojects/qemu-common/= meson.build new file mode 100644 index 000000000000..8969b08473ef --- /dev/null +++ b/subprojects/qemu-common/meson.build @@ -0,0 +1,8 @@ +project('qemu-common', 'c', + license: 'GPL-2.0-or-later', + default_options: ['c_std=3Dgnu11'] +) + +qemu_common_dep =3D declare_dependency( + include_directories: include_directories('include'), +) --=20 2.37.0.rc0 From nobody Mon Feb 9 13:25:08 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=1657620372; cv=none; d=zohomail.com; s=zohoarc; b=mzqA1/y39QgI6hP/Y5M3wt6nviE3r1Q44UWRHm6CxU2WWsnjGLQBlN+kouEWOM875F5UHwazpmzEMV3WOsbR/+AiV2jN+MyEaJL4JkR+JvHdG1qZ93yBgregk7VObGeurpHnNkwOUoqtPlnRFOYDOAwIBUwLxGyXtV0KasiJgTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657620372; 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=SwaBP8hFBuotG5J6yd49FTMQtesqfc4olAZlluLUNm8=; b=bVqGAoxqBcr7o88S+SspdzR9F0+GP6Zme7WZPAOm/KhiiVu4wpiWVkATfszxb1AVyl1nkcgKg7vZvQhZ29xkD3nK1TM4OxPm2e2yk5Va5EKBIAusL70nESsMMAqQyNbaiVCWJpukzHwFtPkZGcYpX+YlrX9DqVfFbbbD0a1Fu/I= 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 1657620372286188.711704028682; Tue, 12 Jul 2022 03:06:12 -0700 (PDT) Received: from localhost ([::1]:41446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCmQ-000360-Uc for importer@patchew.org; Tue, 12 Jul 2022 06:06:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKP-0006Ce-6o for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCK5-0000y0-Cr for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:06 -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-511-KltQUYI8M4SPWWWohmR82w-1; Tue, 12 Jul 2022 05:36:49 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6909280D212; Tue, 12 Jul 2022 09:36:48 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10E8540CF8EF; Tue, 12 Jul 2022 09:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618612; 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=SwaBP8hFBuotG5J6yd49FTMQtesqfc4olAZlluLUNm8=; b=gdN6XR/gbJ/cABrJWOQJENUhKC7FzwSK6N5QAXGkDXhDvBvFLgOt41x0kkopIwvkva1fqI B85AJZ/i2qPkwlO2YmuL1hkxOgDuim6EqdukiecNb/RswOlIsee7Epqm/EhwZF9Yfp9b0f bQi9XGLRLfIej9EnTB0Y+uFoWoXcoUw= X-MC-Unique: KltQUYI8M4SPWWWohmR82w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 11/15] qemu-common: move scripts/qapi Date: Tue, 12 Jul 2022 13:35:24 +0400 Message-Id: <20220712093528.4144184-12-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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.1 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_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: 1657620374135100001 From: Marc-Andr=C3=A9 Lureau This is just moving qapi-gen.py and related subdir to qemu-common, to ease review and proceed step by step. The following patches will move related necessary code, tests etc. Signed-off-by: Marc-Andr=C3=A9 Lureau --- docs/conf.py | 2 +- meson.build | 19 ++----------------- MAINTAINERS | 4 ++-- subprojects/qemu-common/meson.build | 2 ++ subprojects/qemu-common/scripts/meson.build | 3 +++ .../qemu-common/scripts}/qapi-gen.py | 0 .../qemu-common/scripts}/qapi/.flake8 | 0 .../qemu-common/scripts}/qapi/.isort.cfg | 0 .../qemu-common/scripts}/qapi/__init__.py | 0 .../qemu-common/scripts}/qapi/commands.py | 0 .../qemu-common/scripts}/qapi/common.py | 0 .../qemu-common/scripts}/qapi/error.py | 0 .../qemu-common/scripts}/qapi/events.py | 0 .../qemu-common/scripts}/qapi/expr.py | 0 .../qemu-common/scripts}/qapi/gen.py | 0 .../qemu-common/scripts}/qapi/introspect.py | 0 .../qemu-common/scripts}/qapi/main.py | 0 .../qemu-common/scripts/qapi/meson.build | 16 ++++++++++++++++ .../qemu-common/scripts}/qapi/mypy.ini | 0 .../qemu-common/scripts}/qapi/parser.py | 0 .../qemu-common/scripts}/qapi/pylintrc | 0 .../qemu-common/scripts}/qapi/schema.py | 0 .../qemu-common/scripts}/qapi/source.py | 0 .../qemu-common/scripts}/qapi/types.py | 0 .../qemu-common/scripts}/qapi/visit.py | 0 tests/qapi-schema/meson.build | 2 +- 26 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 subprojects/qemu-common/scripts/meson.build rename {scripts =3D> subprojects/qemu-common/scripts}/qapi-gen.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/.flake8 (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/.isort.cfg (100= %) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/__init__.py (10= 0%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/commands.py (10= 0%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/common.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/error.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/events.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/expr.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/gen.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/introspect.py (= 100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/main.py (100%) create mode 100644 subprojects/qemu-common/scripts/qapi/meson.build rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/mypy.ini (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/parser.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/pylintrc (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/schema.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/source.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/types.py (100%) rename {scripts =3D> subprojects/qemu-common/scripts}/qapi/visit.py (100%) diff --git a/docs/conf.py b/docs/conf.py index e33cf3d38121..02dcd987b426 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -56,7 +56,7 @@ # Our extensions are in docs/sphinx; the qapidoc extension requires # the QAPI modules from scripts/. sys.path.insert(0, os.path.join(qemu_docdir, "sphinx")) -sys.path.insert(0, os.path.join(qemu_docdir, "../scripts")) +sys.path.insert(0, os.path.join(qemu_docdir, "../subprojects/qemu-common/s= cripts")) =20 =20 # -- General configuration ------------------------------------------------ diff --git a/meson.build b/meson.build index 254eb1263a66..97e8ab37eb08 100644 --- a/meson.build +++ b/meson.build @@ -1582,6 +1582,8 @@ if libbpf.found() and not cc.links(''' endif =20 qemu_common =3D subproject('qemu-common') +qapi_gen =3D qemu_common.get_variable('qapi_gen') +qapi_gen_depends =3D qemu_common.get_variable('qapi_gen_depends') qemu_common =3D qemu_common.get_variable('qemu_common_dep') =20 ################# @@ -2790,23 +2792,6 @@ genh +=3D configure_file(output: 'config-host.h', co= nfiguration: config_host_data) =20 hxtool =3D find_program('scripts/hxtool') shaderinclude =3D find_program('scripts/shaderinclude.pl') -qapi_gen =3D find_program('scripts/qapi-gen.py') -qapi_gen_depends =3D [ meson.current_source_dir() / 'scripts/qapi/__init__= .py', - meson.current_source_dir() / 'scripts/qapi/commands.p= y', - meson.current_source_dir() / 'scripts/qapi/common.py', - meson.current_source_dir() / 'scripts/qapi/error.py', - meson.current_source_dir() / 'scripts/qapi/events.py', - meson.current_source_dir() / 'scripts/qapi/expr.py', - meson.current_source_dir() / 'scripts/qapi/gen.py', - meson.current_source_dir() / 'scripts/qapi/introspect= .py', - meson.current_source_dir() / 'scripts/qapi/parser.py', - meson.current_source_dir() / 'scripts/qapi/schema.py', - meson.current_source_dir() / 'scripts/qapi/source.py', - meson.current_source_dir() / 'scripts/qapi/types.py', - meson.current_source_dir() / 'scripts/qapi/visit.py', - meson.current_source_dir() / 'scripts/qapi/common.py', - meson.current_source_dir() / 'scripts/qapi-gen.py' -] =20 tracetool =3D [ python, files('scripts/tracetool.py'), diff --git a/MAINTAINERS b/MAINTAINERS index 450abd025271..b45511dab550 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2847,8 +2847,8 @@ F: tests/unit/test-*-visitor.c F: tests/unit/test-qapi-*.c F: tests/unit/test-qmp-*.c F: tests/unit/test-visitor-serialization.c -F: scripts/qapi-gen.py -F: scripts/qapi/* +F: subprojects/qemu-common/scripts/qapi-gen.py +F: subprojects/qemu-common/scripts/qapi/* F: docs/sphinx/qapidoc.py F: docs/devel/qapi* T: git https://repo.or.cz/qemu/armbru.git qapi-next diff --git a/subprojects/qemu-common/meson.build b/subprojects/qemu-common/= meson.build index 8969b08473ef..207e53991061 100644 --- a/subprojects/qemu-common/meson.build +++ b/subprojects/qemu-common/meson.build @@ -6,3 +6,5 @@ project('qemu-common', 'c', qemu_common_dep =3D declare_dependency( include_directories: include_directories('include'), ) + +subdir('scripts') diff --git a/subprojects/qemu-common/scripts/meson.build b/subprojects/qemu= -common/scripts/meson.build new file mode 100644 index 000000000000..626bed6dcdfe --- /dev/null +++ b/subprojects/qemu-common/scripts/meson.build @@ -0,0 +1,3 @@ +qapi_gen =3D find_program('qapi-gen.py') + +subdir('qapi') diff --git a/scripts/qapi-gen.py b/subprojects/qemu-common/scripts/qapi-gen= .py similarity index 100% rename from scripts/qapi-gen.py rename to subprojects/qemu-common/scripts/qapi-gen.py diff --git a/scripts/qapi/.flake8 b/subprojects/qemu-common/scripts/qapi/.f= lake8 similarity index 100% rename from scripts/qapi/.flake8 rename to subprojects/qemu-common/scripts/qapi/.flake8 diff --git a/scripts/qapi/.isort.cfg b/subprojects/qemu-common/scripts/qapi= /.isort.cfg similarity index 100% rename from scripts/qapi/.isort.cfg rename to subprojects/qemu-common/scripts/qapi/.isort.cfg diff --git a/scripts/qapi/__init__.py b/subprojects/qemu-common/scripts/qap= i/__init__.py similarity index 100% rename from scripts/qapi/__init__.py rename to subprojects/qemu-common/scripts/qapi/__init__.py diff --git a/scripts/qapi/commands.py b/subprojects/qemu-common/scripts/qap= i/commands.py similarity index 100% rename from scripts/qapi/commands.py rename to subprojects/qemu-common/scripts/qapi/commands.py diff --git a/scripts/qapi/common.py b/subprojects/qemu-common/scripts/qapi/= common.py similarity index 100% rename from scripts/qapi/common.py rename to subprojects/qemu-common/scripts/qapi/common.py diff --git a/scripts/qapi/error.py b/subprojects/qemu-common/scripts/qapi/e= rror.py similarity index 100% rename from scripts/qapi/error.py rename to subprojects/qemu-common/scripts/qapi/error.py diff --git a/scripts/qapi/events.py b/subprojects/qemu-common/scripts/qapi/= events.py similarity index 100% rename from scripts/qapi/events.py rename to subprojects/qemu-common/scripts/qapi/events.py diff --git a/scripts/qapi/expr.py b/subprojects/qemu-common/scripts/qapi/ex= pr.py similarity index 100% rename from scripts/qapi/expr.py rename to subprojects/qemu-common/scripts/qapi/expr.py diff --git a/scripts/qapi/gen.py b/subprojects/qemu-common/scripts/qapi/gen= .py similarity index 100% rename from scripts/qapi/gen.py rename to subprojects/qemu-common/scripts/qapi/gen.py diff --git a/scripts/qapi/introspect.py b/subprojects/qemu-common/scripts/q= api/introspect.py similarity index 100% rename from scripts/qapi/introspect.py rename to subprojects/qemu-common/scripts/qapi/introspect.py diff --git a/scripts/qapi/main.py b/subprojects/qemu-common/scripts/qapi/ma= in.py similarity index 100% rename from scripts/qapi/main.py rename to subprojects/qemu-common/scripts/qapi/main.py diff --git a/subprojects/qemu-common/scripts/qapi/meson.build b/subprojects= /qemu-common/scripts/qapi/meson.build new file mode 100644 index 000000000000..5f73a966f344 --- /dev/null +++ b/subprojects/qemu-common/scripts/qapi/meson.build @@ -0,0 +1,16 @@ +qapi_gen_depends =3D files( + '__init__.py', + 'commands.py', + 'common.py', + 'error.py', + 'events.py', + 'expr.py', + 'gen.py', + 'introspect.py', + 'parser.py', + 'schema.py', + 'source.py', + 'types.py', + 'visit.py', + 'common.py', +) diff --git a/scripts/qapi/mypy.ini b/subprojects/qemu-common/scripts/qapi/m= ypy.ini similarity index 100% rename from scripts/qapi/mypy.ini rename to subprojects/qemu-common/scripts/qapi/mypy.ini diff --git a/scripts/qapi/parser.py b/subprojects/qemu-common/scripts/qapi/= parser.py similarity index 100% rename from scripts/qapi/parser.py rename to subprojects/qemu-common/scripts/qapi/parser.py diff --git a/scripts/qapi/pylintrc b/subprojects/qemu-common/scripts/qapi/p= ylintrc similarity index 100% rename from scripts/qapi/pylintrc rename to subprojects/qemu-common/scripts/qapi/pylintrc diff --git a/scripts/qapi/schema.py b/subprojects/qemu-common/scripts/qapi/= schema.py similarity index 100% rename from scripts/qapi/schema.py rename to subprojects/qemu-common/scripts/qapi/schema.py diff --git a/scripts/qapi/source.py b/subprojects/qemu-common/scripts/qapi/= source.py similarity index 100% rename from scripts/qapi/source.py rename to subprojects/qemu-common/scripts/qapi/source.py diff --git a/scripts/qapi/types.py b/subprojects/qemu-common/scripts/qapi/t= ypes.py similarity index 100% rename from scripts/qapi/types.py rename to subprojects/qemu-common/scripts/qapi/types.py diff --git a/scripts/qapi/visit.py b/subprojects/qemu-common/scripts/qapi/v= isit.py similarity index 100% rename from scripts/qapi/visit.py rename to subprojects/qemu-common/scripts/qapi/visit.py diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index c18dd7d02f72..2c676360041e 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -1,5 +1,5 @@ test_env =3D environment() -test_env.set('PYTHONPATH', meson.project_source_root() / 'scripts') +test_env.set('PYTHONPATH', meson.project_source_root() / 'subprojects/qemu= -common/scripts') test_env.set('PYTHONIOENCODING', 'utf-8') =20 schemas =3D [ --=20 2.37.0.rc0 From nobody Mon Feb 9 13:25:08 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=1657619828; cv=none; d=zohomail.com; s=zohoarc; b=hLiqzfVVHmM+VMTB597+OP5vUymSRExPIDoBob6/ICkLvkslqF/i4lQtFUXDrgVVlPdt8tH4pPgUFNAgvQhv7rfhPSUpLxgKDEAAN/I6IDAcrGFvtD2wsem1Z0Wde7K7b8JCVaNGgEGFm4kRawqeUh/YJ24F0EREQI1NUlEYteo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619828; 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=ECB1rjXtaOld755Ej47L1U6FtyhUddpB7HqdBC6SqTw=; b=mFTnCYN8Noi19+WA9KB8qbltorAfmh9WVqSESP3vuCnz1Sls6rVUA6fiLTK/Y8So40Ckw3Nz25c08QztF7bsV41BGZ/6Eg8uKOzdJhvdruNvE+ohSxUmU8RMePjQYwS/df/zimhl5K46d5C+eQxALWltKXmtXLB9tkqP5QIg18M= 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 1657619828014691.133734826901; Tue, 12 Jul 2022 02:57:08 -0700 (PDT) Received: from localhost ([::1]:56910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCde-0002mw-89 for importer@patchew.org; Tue, 12 Jul 2022 05:57:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKa-0006HV-Le for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKE-0001gj-Ai for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:21 -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-629-E0IAtwoQNEWSS5ZUlZhvuA-1; Tue, 12 Jul 2022 05:36:55 -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 9744D85A584; Tue, 12 Jul 2022 09:36:54 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A4241415117; Tue, 12 Jul 2022 09:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618621; 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=ECB1rjXtaOld755Ej47L1U6FtyhUddpB7HqdBC6SqTw=; b=IUmwh0JOprIoHiRnxbRb6tS/3adkHefq61/R4ETtmmGxzROsfZVEQFy3y7LuCIHBcOhHGu +2ajWTEJklJidJOdofU2jrC5uaxV1JNJt4HCvmfNHzs2PgDqW5g+F+zZGskeub2SZVqaiP V1xl7x3Anh22KS/PLK/lm0Ltd4nwbYM= X-MC-Unique: E0IAtwoQNEWSS5ZUlZhvuA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 12/15] qemu-common: move glib-compat.h Date: Tue, 12 Jul 2022 13:35:25 +0400 Message-Id: <20220712093528.4144184-13-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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_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: 1657619828850100001 From: Marc-Andr=C3=A9 Lureau qemu-common will have compatible dependency requirements with QEMU. Since qemu-common won't have a toplevel qemu/osdep.h which would include various system headers, include stdbool.h (bool is used for some declarations here). Replace getenv() with g_getenv() to avoid extra header inclusion. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Warner Losh --- {include =3D> subprojects/qemu-common/include}/glib-compat.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename {include =3D> subprojects/qemu-common/include}/glib-compat.h (97%) diff --git a/include/glib-compat.h b/subprojects/qemu-common/include/glib-c= ompat.h similarity index 97% rename from include/glib-compat.h rename to subprojects/qemu-common/include/glib-compat.h index 43a562974d80..2b0f2962f322 100644 --- a/include/glib-compat.h +++ b/subprojects/qemu-common/include/glib-compat.h @@ -30,6 +30,8 @@ #pragma GCC diagnostic ignored "-Wdeprecated-declarations" =20 #include +#include + #if defined(G_OS_UNIX) #include #include @@ -133,7 +135,7 @@ qemu_g_test_slow(void) { static int cached =3D -1; if (cached =3D=3D -1) { - cached =3D g_test_slow() || getenv("G_TEST_SLOW") !=3D NULL; + cached =3D g_test_slow() || g_getenv("G_TEST_SLOW") !=3D NULL; } return cached; } --=20 2.37.0.rc0 From nobody Mon Feb 9 13:25:08 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=1657620116; cv=none; d=zohomail.com; s=zohoarc; b=S3+t/S0UBbY1PP1vurfFFxFHppJ+d+qpyMoyr9WsaQN8KSP0y4mzYMMbSf+LcqWUYMCP7YwJjBNSmBQaYruGzf4FqX8ZEHiqK0sZwcNucg900CIb7P+FzvCdUx+6So08xeJRn7sWsBfTttR/qG39rYaDM+bSVEeQlTe/X12LjDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657620116; 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=F82WnW9k098m/J58lihfvrbbt/wO0m0PQjAOnV2hk5I=; b=RFFaBG3Bzr07PRNjYBjKCQtHzQJZihV35oDOgBXxk8hnOHnnNTSR7L5WBP/nSx5XJKk82bnmYxUABQJWXX4eOUf3rV2+cIiPIl5U/09g0BWkz8G85lzPpNkdUHwkyeXPv6urFSdK/qX01+u95Z6L47xJ5wmUmZrUrsPd6EnWX5Q= 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 1657620116209284.7482964624854; Tue, 12 Jul 2022 03:01:56 -0700 (PDT) Received: from localhost ([::1]:34944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCiJ-0006zY-0W for importer@patchew.org; Tue, 12 Jul 2022 06:01:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKa-0006Hu-NM for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKF-0001kn-9U for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:21 -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-401-nfMfF0tOPPaKRT-Cl_lLYw-1; Tue, 12 Jul 2022 05:37:00 -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 E26A0801231; Tue, 12 Jul 2022 09:36:59 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id A33FC9D7F; Tue, 12 Jul 2022 09:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618622; 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=F82WnW9k098m/J58lihfvrbbt/wO0m0PQjAOnV2hk5I=; b=iTnvWaTkXxzIThfC50tyX2kDZceF5Il8SRzSKdel3LG2n38hHiD9aVZLU/oItCNsrOYcKq a8RLr2eZ29pcthNyTcsp+nYIxBEWrFHJDRNfRteGQWQ4cleiZCjUN7k2N4spDSllJFMHUK 66I0hGKZj74mc468k7ScsDvZmT8bAsY= X-MC-Unique: nfMfF0tOPPaKRT-Cl_lLYw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 13/15] qemu-common: move error-report Date: Tue, 12 Jul 2022 13:35:26 +0400 Message-Id: <20220712093528.4144184-14-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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, 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: 1657620116480100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- .../qemu-common/include}/qemu/error-report.h | 2 ++ .../qemu-common/src}/error-is-detailed.c | 1 - .../qemu-common/src}/error-report.c | 4 +++- .../qemu-common/src/error-vprintf.c | 5 ++--- stubs/meson.build | 2 -- subprojects/qemu-common/meson.build | 20 ++++++++++++++++--- subprojects/qemu-common/src/meson.build | 5 +++++ util/meson.build | 2 +- 8 files changed, 30 insertions(+), 11 deletions(-) rename {include =3D> subprojects/qemu-common/include}/qemu/error-report.h = (98%) rename {stubs =3D> subprojects/qemu-common/src}/error-is-detailed.c (77%) rename {util =3D> subprojects/qemu-common/src}/error-report.c (99%) rename stubs/error-printf.c =3D> subprojects/qemu-common/src/error-vprintf= .c (78%) create mode 100644 subprojects/qemu-common/src/meson.build diff --git a/include/qemu/error-report.h b/subprojects/qemu-common/include/= qemu/error-report.h similarity index 98% rename from include/qemu/error-report.h rename to subprojects/qemu-common/include/qemu/error-report.h index 6ab25d458350..c62dd1a633b8 100644 --- a/include/qemu/error-report.h +++ b/subprojects/qemu-common/include/qemu/error-report.h @@ -13,6 +13,8 @@ #ifndef QEMU_ERROR_REPORT_H #define QEMU_ERROR_REPORT_H =20 +#include "glib-compat.h" + typedef struct Location { /* all members are private to qemu-error.c */ enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; diff --git a/stubs/error-is-detailed.c b/subprojects/qemu-common/src/error-= is-detailed.c similarity index 77% rename from stubs/error-is-detailed.c rename to subprojects/qemu-common/src/error-is-detailed.c index c47cd236932f..c3d9c3454d84 100644 --- a/stubs/error-is-detailed.c +++ b/subprojects/qemu-common/src/error-is-detailed.c @@ -1,4 +1,3 @@ -#include "qemu/osdep.h" #include "qemu/error-report.h" =20 bool error_is_detailed(void) diff --git a/util/error-report.c b/subprojects/qemu-common/src/error-report= .c similarity index 99% rename from util/error-report.c rename to subprojects/qemu-common/src/error-report.c index 4d1d66fc0650..616428fe9579 100644 --- a/util/error-report.c +++ b/subprojects/qemu-common/src/error-report.c @@ -10,7 +10,9 @@ * See the COPYING file in the top-level directory. */ =20 -#include "qemu/osdep.h" +#include +#include + #include "qemu/error-report.h" =20 /* diff --git a/stubs/error-printf.c b/subprojects/qemu-common/src/error-vprin= tf.c similarity index 78% rename from stubs/error-printf.c rename to subprojects/qemu-common/src/error-vprintf.c index 1afa0f62ca26..b815d88dfe65 100644 --- a/stubs/error-printf.c +++ b/subprojects/qemu-common/src/error-vprintf.c @@ -1,13 +1,12 @@ -#include "qemu/osdep.h" +#include #include "qemu/error-report.h" -#include "monitor/monitor.h" =20 int error_vprintf(const char *fmt, va_list ap) { int ret; =20 if (g_test_initialized() && !g_test_subprocess() && - getenv("QTEST_SILENT_ERRORS")) { + g_getenv("QTEST_SILENT_ERRORS")) { char *msg =3D g_strdup_vprintf(fmt, ap); g_test_message("%s", msg); ret =3D strlen(msg); diff --git a/stubs/meson.build b/stubs/meson.build index 0f3a782824f9..498b6ee0466e 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -9,8 +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-is-detailed.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')) diff --git a/subprojects/qemu-common/meson.build b/subprojects/qemu-common/= meson.build index 207e53991061..05bca6d30d49 100644 --- a/subprojects/qemu-common/meson.build +++ b/subprojects/qemu-common/meson.build @@ -3,8 +3,22 @@ project('qemu-common', 'c', default_options: ['c_std=3Dgnu11'] ) =20 -qemu_common_dep =3D declare_dependency( - include_directories: include_directories('include'), -) +glib_dep =3D dependency('glib-2.0') +inc =3D include_directories('include') + +sources =3D [] =20 subdir('scripts') +subdir('src') + +lib =3D static_library( + 'qemu-common', sources, + dependencies: [glib_dep], + include_directories: inc, +) + +qemu_common_dep =3D declare_dependency( + link_with: lib, + include_directories: inc, + dependencies: [glib_dep], +) diff --git a/subprojects/qemu-common/src/meson.build b/subprojects/qemu-com= mon/src/meson.build new file mode 100644 index 000000000000..d85a314065e5 --- /dev/null +++ b/subprojects/qemu-common/src/meson.build @@ -0,0 +1,5 @@ +sources +=3D files( + 'error-is-detailed.c', + 'error-report.c', + 'error-vprintf.c', +) diff --git a/util/meson.build b/util/meson.build index 8cce8f8968f6..4dae6f815e31 100644 --- a/util/meson.build +++ b/util/meson.build @@ -28,7 +28,7 @@ util_ss.add(files('host-utils.c')) util_ss.add(files('bitmap.c', 'bitops.c')) util_ss.add(files('fifo8.c')) util_ss.add(files('cacheflush.c')) -util_ss.add(files('error.c', 'error-report.c')) +util_ss.add(files('error.c')) util_ss.add(files('qemu-print.c')) util_ss.add(files('id.c')) util_ss.add(files('qemu-config.c', 'notify.c')) --=20 2.37.0.rc0 From nobody Mon Feb 9 13:25:08 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=1657619751; cv=none; d=zohomail.com; s=zohoarc; b=N5Q8YHN/xGjRibsOWVQrrks6CNYohpouB9UCGht1uCCDX8a9++JVtb4GqvbGFC7AJicR8EraN62FeK84l6nzXYRz7+rYzvT7lSXqMCzatGiAPmOTENzOZzaG0Eeuy58MeUIwpbtd/dV+IDuw1hwVNgouJx4dsccLLYknwrKQx44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657619751; 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=2nM7wrY/D3ugiS6pxblMsXcRuVCQA1Yk9Qt/yIkB040=; b=ZiaTyiv24JAKrpqmmjdk4SWVTg46kRA93KtkJR9A2RALBMUgGdRoSRlkQvK6E0yqr1ouqX4czMwZH3qJ6bY4aiLSm7OlOSRKOf3zM/10XVBThcl5baGGBxh/ivXPSPwfacQViPgXKfYp3qlBmt+4YNoIYFlR/FdckyjBWLHG2NM= 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 1657619751009934.9473250405212; Tue, 12 Jul 2022 02:55:51 -0700 (PDT) Received: from localhost ([::1]:54266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCcP-0000qC-Or for importer@patchew.org; Tue, 12 Jul 2022 05:55:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKS-0006Ev-LA for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKQ-0001rq-Eq for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:15 -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-282-xzoUKBeSMcGd8V7V2KxrGg-1; Tue, 12 Jul 2022 05:37:06 -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 73E1D185A7BA; Tue, 12 Jul 2022 09:37:05 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 804E340D2827; Tue, 12 Jul 2022 09:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618631; 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=2nM7wrY/D3ugiS6pxblMsXcRuVCQA1Yk9Qt/yIkB040=; b=H2OUU10+tXuozC1aE/IpE6Qi3Nd59WihxQxdTXGT61sarP4o5aAz/kAPxIh9EM6WTAY2HO t54209ZutE3xLYlozdjtcVXcqyPw3A/VwospH6mfbPyJMvl9wiTi436E2LRrYMgCLLvRkD 8+WHGalMx3en4y0FLqapJBx22eERMVo= X-MC-Unique: xzoUKBeSMcGd8V7V2KxrGg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 14/15] mtest2make.py: teach suite name that are just "PROJECT" Date: Tue, 12 Jul 2022 13:35:27 +0400 Message-Id: <20220712093528.4144184-15-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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, 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: 1657619752704100001 From: Marc-Andr=C3=A9 Lureau A subproject test may be simply in the "PROJECT" suite (such as "qemu-common" with the following patches) Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/mtest2make.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py index 0fe81efbbcec..606821ee2732 100644 --- a/scripts/mtest2make.py +++ b/scripts/mtest2make.py @@ -51,8 +51,11 @@ def process_tests(test, targets, suites): =20 test_suites =3D test['suite'] or ['default'] for s in test_suites: - # The suite name in the introspection info is "PROJECT:SUITE" - s =3D s.split(':')[1] + # The suite name in the introspection info is "PROJECT" or "PROJEC= T:SUITE" + try: + s =3D s.split(':')[1] + except IndexError: + continue if s =3D=3D 'slow' or s =3D=3D 'thorough': continue if s.endswith('-slow'): --=20 2.37.0.rc0 From nobody Mon Feb 9 13:25:08 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=1657620712; cv=none; d=zohomail.com; s=zohoarc; b=GJxY3CP2TpVWEffns6nurBpTgLceFVRW2bMQ/nQ/c8ZB0dqqqMfFIYzP9JG3p7ouLLEGmBoLX9L/UMDBK3T/JhKk5tmZsWnmOiwg4Vgn9fJFaCKHYZG1bvUxIvzhcEEYpE+smPe4qcPyj0I7fRujtNmKtRkLvHiAgwzM6tEuRmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657620712; 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=DGLKwGrwExfiJ5yPSl55RdoLzgPPkGL6kvwwHPribIk=; b=F/iiAjKTT0DyK6jbVeIr1efqfOhEvLlaxPZtd2MoqMIMWXUvyWtCOpMt5WA4NXqqj0xzYqsPKaCSR5co7Y7fMC7J5V+ViV9uVLbnh0+Duuu0JF0sAk56QKt1a870rsJKUfUlS9k+KwpenAXdX13N1r6QfPEGSkvme3noeGwf7XA= 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 165762071253099.41824670811502; Tue, 12 Jul 2022 03:11:52 -0700 (PDT) Received: from localhost ([::1]:50490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBCrv-00017y-E4 for importer@patchew.org; Tue, 12 Jul 2022 06:11:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKc-0006Jd-4E for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBCKU-0002HP-Ay for qemu-devel@nongnu.org; Tue, 12 Jul 2022 05:37:25 -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-317-Zi9bg23aMtCIlcqDpFgTjg-1; Tue, 12 Jul 2022 05:37:13 -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 8810180029D; Tue, 12 Jul 2022 09:37:12 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DFB21415117; Tue, 12 Jul 2022 09:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657618637; 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=DGLKwGrwExfiJ5yPSl55RdoLzgPPkGL6kvwwHPribIk=; b=QE2YQZBfDotreJT11JP0WY9VVVTgJPTRdE7HPUSBZsHJmK/7AQlED5hyF1UYe23dqkKc+M /MQyFMMQbGCRPvLnUfvo973ERtn1/NrdMJprCaNWDTP4dx2YwFDZ3hIrdVw0F0FsHMYMHf +L516ReTJVmGOeUZvGzFGzMOsxMq2II= X-MC-Unique: Zi9bg23aMtCIlcqDpFgTjg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Eric Blake , Cleber Rosa , qemu-block@nongnu.org, Paolo Bonzini , Xie Yongji , Kyle Evans , Peter Maydell , John Snow , Michael Roth , Warner Losh , Kevin Wolf , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Laurent Vivier , Fam Zheng , Hanna Reitz , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 15/15] qemu-common: add error-report test Date: Tue, 12 Jul 2022 13:35:28 +0400 Message-Id: <20220712093528.4144184-16-marcandre.lureau@redhat.com> In-Reply-To: <20220712093528.4144184-1-marcandre.lureau@redhat.com> References: <20220712093528.4144184-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: -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: 1657620714249100001 From: Marc-Andr=C3=A9 Lureau Add new tests to check the behaviour of error reporting functions. Signed-off-by: Marc-Andr=C3=A9 Lureau --- .../qemu-common/tests/test-error-report.c | 120 ++++++++++++++++++ subprojects/qemu-common/meson.build | 2 + subprojects/qemu-common/tests/meson.build | 12 ++ 3 files changed, 134 insertions(+) create mode 100644 subprojects/qemu-common/tests/test-error-report.c create mode 100644 subprojects/qemu-common/tests/meson.build diff --git a/subprojects/qemu-common/tests/test-error-report.c b/subproject= s/qemu-common/tests/test-error-report.c new file mode 100644 index 000000000000..09a2d122a0e1 --- /dev/null +++ b/subprojects/qemu-common/tests/test-error-report.c @@ -0,0 +1,120 @@ +/* + * Error reporting test + * + * Copyright (C) 2022 Red Hat Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "glib-compat.h" +#include + +#include "qemu/error-report.h" + +static void +test_error_report_simple(void) +{ + if (g_test_subprocess()) { + error_report("%s", "test error"); + warn_report("%s", "test warn"); + info_report("%s", "test info"); + return; + } + + g_test_trap_subprocess(NULL, 0, 0); + g_test_trap_assert_passed(); + g_test_trap_assert_stderr("\ +test-error-report: test error*\ +test-error-report: warning: test warn*\ +test-error-report: info: test info*\ +"); +} + +static void +test_error_report_loc(void) +{ + if (g_test_subprocess()) { + loc_set_file("some-file.c", 7717); + error_report("%s", "test error1"); + loc_set_none(); + error_report("%s", "test error2"); + return; + } + + g_test_trap_subprocess(NULL, 0, 0); + g_test_trap_assert_passed(); + g_test_trap_assert_stderr("\ +test-error-report:some-file.c:7717: test error1*\ +test-error-report: test error2*\ +"); +} + +static void +test_error_report_glog(void) +{ + if (g_test_subprocess()) { + g_message("gmessage"); + return; + } + + g_test_trap_subprocess(NULL, 0, 0); + g_test_trap_assert_passed(); + g_test_trap_assert_stderr("test-error-report: info: gmessage*"); +} + +static void +test_error_report_once(void) +{ + int i; + + if (g_test_subprocess()) { + for (i =3D 0; i < 3; i++) { + warn_report_once("warn"); + error_report_once("err"); + } + return; + } + + g_test_trap_subprocess(NULL, 0, 0); + g_test_trap_assert_passed(); + g_test_trap_assert_stderr("\ +test-error-report: warning: warn*\ +test-error-report: err*\ +"); +} + +static void +test_error_report_timestamp(void) +{ + if (g_test_subprocess()) { + message_with_timestamp =3D true; + warn_report("warn"); + error_report("err"); + return; + } + + g_test_trap_subprocess(NULL, 0, 0); + g_test_trap_assert_passed(); + g_test_trap_assert_stderr("\ +*-*-*:*:* test-error-report: warning: warn*\ +*-*-*:*:* test-error-report: err*\ +"); +} + +int +main(int argc, char *argv[]) +{ + setlocale(LC_ALL, ""); + + g_test_init(&argc, &argv, NULL); + error_init("test-error-report"); + + g_test_add_func("/error-report/simple", test_error_report_simple); + g_test_add_func("/error-report/loc", test_error_report_loc); + g_test_add_func("/error-report/glog", test_error_report_glog); + g_test_add_func("/error-report/once", test_error_report_once); + g_test_add_func("/error-report/timestamp", test_error_report_timestamp= ); + + return g_test_run(); +} diff --git a/subprojects/qemu-common/meson.build b/subprojects/qemu-common/= meson.build index 05bca6d30d49..991aaac52040 100644 --- a/subprojects/qemu-common/meson.build +++ b/subprojects/qemu-common/meson.build @@ -22,3 +22,5 @@ qemu_common_dep =3D declare_dependency( include_directories: inc, dependencies: [glib_dep], ) + +subdir('tests') diff --git a/subprojects/qemu-common/tests/meson.build b/subprojects/qemu-c= ommon/tests/meson.build new file mode 100644 index 000000000000..3dd10c180b50 --- /dev/null +++ b/subprojects/qemu-common/tests/meson.build @@ -0,0 +1,12 @@ +env =3D [ + 'G_TEST_SRCDIR=3D@0@'.format(meson.current_source_dir()), + 'G_TEST_BUILDDIR=3D@0@'.format(meson.current_build_dir()), +] + +test('error-report', + executable('test-error-report', + sources: files('test-error-report.c'), + dependencies: qemu_common_dep, + ), + env: env, +) --=20 2.37.0.rc0