From nobody Tue May 7 23:10:37 2024 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=1660136282; cv=none; d=zohomail.com; s=zohoarc; b=lmpj5DtzZWt+Pj6ufU/Fp1/+jVBqYzOMYuSmarpZ8NziO03ffoKD7uFdqknqdJ4yVhgslNtDbhM0wZX6WM5+JcX3X0WpgvXWsDfu4wL0zMUDtiGGqg4+kg8s2KAMpIWdtyIXK5JPNxwpIPTKJJawKgVY1kVNJ1ZbNAfw/Tqxa7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136282; 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=K7B8zoi12JI7J5DVOiEMpNRxnLo9t28miZfDuM0uHiM=; b=kzE7JeZnLR9wrPB4nwFPAzSXQFlKk2fD8142rHmFhE8ycRAGL++IuksyQolP2uP4fvIfpjtWh2AR3TxRgem9Yw6lJtjD8DpnrYB0ccusDek5lOn4eBiUghbo6biTDVEUrxdtU3q+ImCMcy4Lt/6cf5haovRE6Z3/4hUie3Zcduo= 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 1660136282717608.003535599684; Wed, 10 Aug 2022 05:58:02 -0700 (PDT) Received: from localhost ([::1]:60864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlHd-0008W9-HZ for importer@patchew.org; Wed, 10 Aug 2022 08:58:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl96-0001P6-Da for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl95-0007P8-1N for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49: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-141-Wllek6EXMy-sRqS6MDmQkQ-1; Wed, 10 Aug 2022 08:49:09 -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 8FE133C10237; Wed, 10 Aug 2022 12:49:08 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABBEA9457F; Wed, 10 Aug 2022 12:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135750; 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=K7B8zoi12JI7J5DVOiEMpNRxnLo9t28miZfDuM0uHiM=; b=VVJGQ942dfmYwv9uC/V2N7wi+FqlJ4rpwV1FT6U86IHSnSv+iNcgqTFI+XMSQ2CVI3d//s +kCMM1qTGYda0TixI11kLpY0FY6OSXN1JxqMls4l5Ot+lvBNhCKAxFHkoc8hhL8AhbqMlZ Rsz1jhgDWQy5Y8wr6lAZZS6GfT06pM8= X-MC-Unique: Wllek6EXMy-sRqS6MDmQkQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 01/16] error-report: misc comment fix Date: Wed, 10 Aug 2022 16:48:42 +0400 Message-Id: <20220810124857.1360211-2-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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: -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: 1660136283480100001 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 5edb2e6040..98f242b75b 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136042; cv=none; d=zohomail.com; s=zohoarc; b=OQeJE2neAMC5j/JjJsWgbsR9Hq/PxuYBoSlRiP5LB/6RwyiiWE0l/h/xAHUfVtE/OlLRqcBdVmxGq8x/6w8s2lbG4j28L/Yr0XCud5AQ/DLzX3PPW6xl1T6L6vnOHNy4yDxZTikZHnh3kGihu4a/k5vyDdkxh3TbejzJXI6r7ic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136042; 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=sSNnN7KvI9Po+0yP7BBZfjJSmlgmgIp1lOfe8H0psuk=; b=ETcfZJIsj1jypqIJ/uQJbXhxfbADg02KyN8WgUCSqur7WS5BmysJjrcw7yCfpDwkBrD7BSQQBClrdY6PfA9PMZFEBaoGd1VLIUCfv6dubrl0JI6S0p+HFP73hPnEgHkJ9sy1wOVEsGO5V0WRHubUWdKAAEgA4dVK0ho+fb8MMeo= 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 1660136042256931.3689576235943; Wed, 10 Aug 2022 05:54:02 -0700 (PDT) Received: from localhost ([::1]:54974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlDk-0004Pv-W8 for importer@patchew.org; Wed, 10 Aug 2022 08:54:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9B-0001RK-RB for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9A-0007QV-Bn for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:17 -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-339-TqtXslJeMMuNiU-0Rr_zXg-1; Wed, 10 Aug 2022 08:49:13 -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 087311C13959; Wed, 10 Aug 2022 12:49:13 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBC7F18EAA; Wed, 10 Aug 2022 12:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135754; 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=sSNnN7KvI9Po+0yP7BBZfjJSmlgmgIp1lOfe8H0psuk=; b=U9PB/wQHo0x+gHlqhVHbUtGZVeMhzBUbKRHWI9biNo/af527IkkdUDtXP9szZnb/3K9cP2 V6YYIG5yssF4BFHPWYOG++o3NoxsL9UnBQCS4PZORypgrdLKYTu+jx+ycQjaLlku5hrOCz vnF2R0BmMEQFyVkIpKFCBGTxQjKz718= X-MC-Unique: TqtXslJeMMuNiU-0Rr_zXg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 02/16] error-report: introduce "detailed" variable Date: Wed, 10 Aug 2022 16:48:43 +0400 Message-Id: <20220810124857.1360211-3-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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: -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: 1660136044568100001 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 98f242b75b..893da10f19 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136584; cv=none; d=zohomail.com; s=zohoarc; b=BziTqMv5Gc50/hhY03YyTiViLrrznSwNi/qHtyjum5MHlkjJVLfbeo0M2NEcUbWCp/FOQmbM9ba//yW1rftxqBQ79Xy6cn05URTc/nBOrQVj4iwLrZn6tPSkLr22cpWdTqdsLSSr+WcOrvD6YsdACn5udVrxtweWWPXknc0aim4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136584; 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=gQ8uwmvbN+N0hbjJdePDsMSmyYDI/eQHq0gIKAefHZA=; b=hv8XK2qvOTHvp0hoTIrNidkuGidCRyoQ1++G867KVVMityUezFOC6iTDwxav1g3mfDxZXc4Isw7JlEqo83c0nUV1OgpviMyHm6KAHW5M/sUX6JanqsLH6bqAASbMqS0nPV9rCZKkKis3qjCSqlrZUVGQSzlczJp6h0LNO4kIR+E= 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 166013658484430.293769243428983; Wed, 10 Aug 2022 06:03:04 -0700 (PDT) Received: from localhost ([::1]:40864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlMS-0006E6-OF for importer@patchew.org; Wed, 10 Aug 2022 09:03:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9F-0001TA-PV for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43168) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9E-0007Qg-AY for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49: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-600-vTE-6rS1N7KIhdKqfWAl9Q-1; Wed, 10 Aug 2022 08:49:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B7D98805B9A; Wed, 10 Aug 2022 12:49:17 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id C64182166B2A; Wed, 10 Aug 2022 12:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135759; 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=gQ8uwmvbN+N0hbjJdePDsMSmyYDI/eQHq0gIKAefHZA=; b=QkEhQt6yUUqMIIghnMKrQ12foMNIf9DZx92umeibMulU97Q1W0Xuy/kNievkHR/oFwnE0P T3CKDt75ReuUWVEom67KhZTlMgIsLhGf6ZhTr81rbNXvnAeUUXKNjRpogeCJb3VZmdBREj 1VpY4kNHs8A2eeqLEyhzEoqfoda76Gc= X-MC-Unique: vTE-6rS1N7KIhdKqfWAl9Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 03/16] error-report: simplify print_loc() Date: Wed, 10 Aug 2022 16:48:44 +0400 Message-Id: <20220810124857.1360211-4-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1660136585800100001 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 893da10f19..c43227a975 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136315; cv=none; d=zohomail.com; s=zohoarc; b=h68M0xc+SEJGOpFwRL4v6ATA5Xa2hyvfjjvVqqF5zZaPxCTrtN88fJ3Ky2zo4Wda8X3756OnEhlaI10a+4iwFg0/SKybXLYOzCBiCSNfY/GWao3MpwcDGfXzI92Xv5b0N6ofrDvhTxkZ6vE2PZtBxmmXJgoDT46DFbm2y79x2uU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136315; 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=xImcu8ZCziC7hkqoAXbEBH3kFR+44uOY0ZL6xcX76ZU=; b=Bcd12i4MTdUYBYnBM9S0KpP6KhY4ALUIHM1TFpypxnO1ydlXfb/S5F2cEP+FZo2MdT10esU4jZBFXZPBmp9ZHgZAmJXQmVewZSuAPQ1RBlf0HPqdvHYE2iy/7Q/XL50W9BzW5tUd1+nPinNjbKNWAso/P0+iR6VHXiBdEhC+cd8= 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 1660136315335857.6576177908745; Wed, 10 Aug 2022 05:58:35 -0700 (PDT) Received: from localhost ([::1]:35058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlIA-0001my-8t for importer@patchew.org; Wed, 10 Aug 2022 08:58:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9P-0001UR-0z for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9M-0007R0-1f for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:29 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-473-U3qVVv03NJ2dKdiDJdRIZw-1; Wed, 10 Aug 2022 08:49:22 -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 2F1CD8032F6; Wed, 10 Aug 2022 12:49:22 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 020E3492CA4; Wed, 10 Aug 2022 12:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135767; 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=xImcu8ZCziC7hkqoAXbEBH3kFR+44uOY0ZL6xcX76ZU=; b=DXshoQFPgP4bFHLuHJBNQtuHeVjX8yQI9sCwrUHAXgNtGgO6PHEIuj3wc5Nw1+niE4SrZt ZlyuGxuV7+LLVoh9rW1TdjZmftYtZ/5JLYZoTTrSv16ELIck41vRMz5AV0yBYjn7MUSrJd ZcbsCi05YiJxMtlocNrByADoSKQBZQk= X-MC-Unique: U3qVVv03NJ2dKdiDJdRIZw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 04/16] error-report: introduce overridable error_is_detailed() Date: Wed, 10 Aug 2022 16:48:45 +0400 Message-Id: <20220810124857.1360211-5-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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=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: 1660136317470100001 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 3ae2357fda..6ab25d4583 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 706bd7cff7..069ea50bed 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2603,6 +2603,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 0000000000..c47cd23693 --- /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 c43227a975..4d1d66fc06 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 d8f3fd5c44..0f3a782824 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136072; cv=none; d=zohomail.com; s=zohoarc; b=OOjF9qVw93x3HIo9NaNB1XtO+X5z+BXVjksPwjOsaMjI2OcqyZpSIN0dHE2raqUBQ6tTwlfSv8VhDpd1+2Pr62vX4WtBer+8X9St/QYwXctuzKDbg1hyIG+acQhfHWMUszRTTyG6eTu5TZijiloTPnVWEi2RfrFhQLJPDYkttLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136072; 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=xEoGBy9P7lkRCQLvKuZBgrXNasRnSsfVgx1nyigxT1g=; b=R8dPpF6gRRJFGRpaGfKzitMR0EoDBqfdT1tXlb2Mhk1er6qsIR6deAFShHGoIO8zxVfe+qpyo6bBu0bYamAAub56YJ5dC7DRex9LjPzRBETiweDJ1kmMB0VWa1z/dSL+bulDgsudXXSuYpKLuIoCsp3EzQ+9Z4cRpQYrPSHP0IA= 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 166013607279191.26489075129837; Wed, 10 Aug 2022 05:54:32 -0700 (PDT) Received: from localhost ([::1]:55418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlEF-0004i0-CW for importer@patchew.org; Wed, 10 Aug 2022 08:54:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9T-0001cc-05 for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55372) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9R-0007RE-Jp for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:34 -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-302-dM6kGSguP3OBZIwapYKf5Q-1; Wed, 10 Aug 2022 08:49:27 -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 ED5FD805B72; Wed, 10 Aug 2022 12:49:26 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2BE994585; Wed, 10 Aug 2022 12:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135773; 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=xEoGBy9P7lkRCQLvKuZBgrXNasRnSsfVgx1nyigxT1g=; b=A54opmS+aDFqZj8ByrZn0ELEPiWpikDdHNat8C67LuOZdEkpr7tztPOY9PxnTB8NlgN07e 38LLlq5PPzHK6ygLKlGbXlRhvW95eONdixzf6jiWg4STqDpWd5BmJstrtIJYYpeiqVdXGL Esb2OeRYEAr/PMg6mCMPRINgYdqcKiQ= X-MC-Unique: dM6kGSguP3OBZIwapYKf5Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 05/16] stubs: remove needless error_vprintf_unless_qmp() Date: Wed, 10 Aug 2022 16:48:46 +0400 Message-Id: <20220810124857.1360211-6-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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.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: 1660136073236100001 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 0e326d8010..1afa0f62ca 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136328; cv=none; d=zohomail.com; s=zohoarc; b=K726qz71LBu1hJLebUmMQwQsaqC0dlHYvkxdkyAkKR7cG60FrFsSMuXiANs0b3SIfF3uizF71tJ7/ngK67ELn0RJa0MsvLAApq98ZCeYrn3TL3e5udvM3mKy8Ex3DUfcJcW9uJK8Yk/AjOG3PeI8c40HpL/0Pk1RL+Qa++Vc4iE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136328; 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=s2PfwAuutwAKnpypBFRb1CerbqElSAVHx5Gghw+w17c=; b=jlXMGoP6R9iBxFE3/sH2TTOJEhZ67ni7NkQvP2e/qT2iaGW8LOjNDMHfmw17TyswgcOCX+Nnx3Ug+7xquYHcuXYx0H9euvIZ4G+RTC28raEdd+NU/JmfTDA9fNRxj0mwRHm3D5HMtHsAFfYxHQhQs/OeHvh+uwH8mEG04Gczd78= 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 166013632807448.79268046247023; Wed, 10 Aug 2022 05:58:48 -0700 (PDT) Received: from localhost ([::1]:35488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlIN-00024a-0h for importer@patchew.org; Wed, 10 Aug 2022 08:58:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9T-0001di-PF for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9R-0007RH-SR for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:35 -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-335-w7ixzOknMbWxIOceRfL8UA-1; Wed, 10 Aug 2022 08:49:32 -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 BD4ED103942C; Wed, 10 Aug 2022 12:49:31 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A9140315E; Wed, 10 Aug 2022 12:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135773; 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=s2PfwAuutwAKnpypBFRb1CerbqElSAVHx5Gghw+w17c=; b=EUHVeVogPY1djTHhpXzIbs/yeiqcz6CmlbrmREiumEqr3MHYqGXdwGGY8wzUXcvcifbYI9 CQJ+uNZE08R2z4FcR1SMKKZotw4RbaFsmP6/QDq2znK21HTb8L2iYvv8eJFdiB4Nspi4zs 9/i0prPsO0huZiCmMQzMNOxO5XYdVeg= X-MC-Unique: w7ixzOknMbWxIOceRfL8UA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 06/16] qapi: move QEMU-specific dispatch code in monitor Date: Wed, 10 Aug 2022 16:48:47 +0400 Message-Id: <20220810124857.1360211-7-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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: 1660136329569100003 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 coroutines). Introduce an overridable qmp_dispatch_exec() function, with a default a stub implementation, while the oob & coroutine dispatch logic is moved to monitor/qmp.c. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/qmp/dispatch.h | 3 ++ monitor/qmp.c | 63 +++++++++++++++++++++++++++++++++++++ qapi/qmp-dispatch.c | 60 +---------------------------------- stubs/qmp-dispatch-exec.c | 8 +++++ stubs/meson.build | 1 + 5 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 stubs/qmp-dispatch-exec.c diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 1e4240fd0d..6941a759a7 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -41,6 +41,9 @@ typedef struct QmpCommand =20 typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList; =20 +void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, Monitor *cur_mon, + QDict *args, QObject **ret, Error **err); + void qmp_register_command(QmpCommandList *cmds, const char *name, QmpCommandFunc *fn, QmpCommandOptions options, unsigned special_features); diff --git a/monitor/qmp.c b/monitor/qmp.c index 092c527b6f..b9b109a40a 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -132,6 +132,69 @@ 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. + */ +void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, Monitor *cur_mon, + QDict *args, QObject **ret, Error **errp) +{ + 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. diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 0990873ec8..bec07e4958 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,30 +107,6 @@ 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) { @@ -203,39 +176,8 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObjec= t *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); - } 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)); + qmp_dispatch_exec(cmd, oob, cur_mon, args, &ret, &err); =20 - 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(); - } qobject_unref(args); if (err) { /* or assert(!ret) after reviewing all handlers: */ diff --git a/stubs/qmp-dispatch-exec.c b/stubs/qmp-dispatch-exec.c new file mode 100644 index 0000000000..4aef28d198 --- /dev/null +++ b/stubs/qmp-dispatch-exec.c @@ -0,0 +1,8 @@ +#include "qemu/osdep.h" +#include "qapi/qmp/dispatch.h" + +void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, Monitor *cur_mon, + QDict *args, QObject **ret, Error **err) +{ + cmd->fn(args, ret, err); +} diff --git a/stubs/meson.build b/stubs/meson.build index 0f3a782824..14548633b0 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -32,6 +32,7 @@ stub_ss.add(files('monitor.c')) stub_ss.add(files('monitor-core.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('qmp_memory_device.c')) +stub_ss.add(files('qmp-dispatch-exec.c')) stub_ss.add(files('qmp-command-available.c')) stub_ss.add(files('qmp-quit.c')) stub_ss.add(files('qtest.c')) --=20 2.37.1 From nobody Tue May 7 23:10:37 2024 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=1660136692; cv=none; d=zohomail.com; s=zohoarc; b=cuKJkx0nmgjDfH67POlcR+4tro6XinLEdiiSixWiQtjgEyRQ/PcefTttrJLNu09BKJ6LUYbEAfNXcPKcBcZjFzQ3X/A1wFH7izz8jMc7qgSs5pw9mB/YSbpbHKD1ZrpKfIjY2hM8QOk49sz86ImedERT7GCisab/5mON7Rcv0mU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136692; 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=hrfDTuWUgST19eVeDMl7zAEG1isktyWLHIrGlJyRbsM=; b=PB3thlG2NhnXeI2OWT+Bj/pH9mvQBr7Rx6KBd7wc9CUndm5R2E630gzGQ9/uyXnNyCnpaIuAESYlPgg7mI1CIJgRBD4kX68IA970G8kCd/rtmpQ0Szeag5nBBIhofjJSzUJvwccxT6S5GGgtoAohoEAa9A6K306WqMPXnBL0v3k= 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 1660136692144482.5365000638293; Wed, 10 Aug 2022 06:04:52 -0700 (PDT) Received: from localhost ([::1]:43786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlOD-0008GL-0W for importer@patchew.org; Wed, 10 Aug 2022 09:04:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9Z-0001go-AP for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41582) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9X-0007Rv-MW for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:41 -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-552-TkR5iolJMRWwUe88HJSJbA-1; Wed, 10 Aug 2022 08:49:37 -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 19BC31C16B4B; Wed, 10 Aug 2022 12:49:37 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id E26C4492C3B; Wed, 10 Aug 2022 12:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135779; 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=hrfDTuWUgST19eVeDMl7zAEG1isktyWLHIrGlJyRbsM=; b=hXLakgPI1WMnnB3KSpu+dZN61GYmhPDfA3b5XFDl64pZvoaY+EJ2AEnXBt/WrjMz3mFTaB XBqjrlywe3YtbXHkVAkNGqJIclfgysMs9Lvv0TmHh9OZ6adglN22IaJ4dXLSRp0LBlyrvJ RZU4V4Nt00ODZi5ofhpOdPQ8JIQ5ypQ= X-MC-Unique: TkR5iolJMRWwUe88HJSJbA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 07/16] qapi: remove QEMU-specific monitor dependency from dispatch Date: Wed, 10 Aug 2022 16:48:48 +0400 Message-Id: <20220810124857.1360211-8-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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: 1660136692581100001 From: Marc-Andr=C3=A9 Lureau The monitor is specific to QEMU. Instead of passing a Monitor type argument to the exec handler, use a generic void* pointer. This simplify also the unit dependency, as now the dispatching code is free from QEMU-specifics. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/qmp/dispatch.h | 5 ++--- monitor/qmp.c | 3 ++- qapi/qmp-dispatch.c | 4 ++-- stubs/qmp-dispatch-exec.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index 6941a759a7..ee8a05015a 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,7 +40,7 @@ typedef struct QmpCommand =20 typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList; =20 -void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, Monitor *cur_mon, +void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, void *exec_data, QDict *args, QObject **ret, Error **err); =20 void qmp_register_command(QmpCommandList *cmds, const char *name, @@ -59,7 +58,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, void *exec_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 b9b109a40a..4f0eb6e200 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -156,9 +156,10 @@ static void do_qmp_dispatch_bh(void *opaque) * Runs outside of coroutine context for OOB commands, but in coroutine * context for everything else. */ -void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, Monitor *cur_mon, +void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, void *exec_data, QDict *args, QObject **ret, Error **errp) { + Monitor *cur_mon =3D exec_data; assert(!(oob && qemu_in_coroutine())); assert(monitor_cur() =3D=3D NULL); =20 diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index bec07e4958..2fea789fd3 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -108,7 +108,7 @@ bool qmp_is_oob(const QDict *dict) } =20 QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request, - bool allow_oob, Monitor *cur_mon) + bool allow_oob, void *exec_data) { Error *err =3D NULL; bool oob; @@ -176,7 +176,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObject= *request, qobject_ref(args); } =20 - qmp_dispatch_exec(cmd, oob, cur_mon, args, &ret, &err); + qmp_dispatch_exec(cmd, oob, exec_data, args, &ret, &err); =20 qobject_unref(args); if (err) { diff --git a/stubs/qmp-dispatch-exec.c b/stubs/qmp-dispatch-exec.c index 4aef28d198..4740f55222 100644 --- a/stubs/qmp-dispatch-exec.c +++ b/stubs/qmp-dispatch-exec.c @@ -1,7 +1,7 @@ #include "qemu/osdep.h" #include "qapi/qmp/dispatch.h" =20 -void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, Monitor *cur_mon, +void qmp_dispatch_exec(const QmpCommand *cmd, bool oob, void *exec_data, QDict *args, QObject **ret, Error **err) { cmd->fn(args, ret, err); --=20 2.37.1 From nobody Tue May 7 23:10:37 2024 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=1660136319; cv=none; d=zohomail.com; s=zohoarc; b=Eo1trwAWHaMGy79qrKbgOj2yaYtbLvQme31sfiUwXvQ8my07IqxfLfOPDOC93IeXed3tKdMZzKfKZJq88moY5Gc8QjX5g8n17KrCt8EoWHgvfG4rC9GIH1TKLsOe+Op5kae5jGPRuFKzewhDI5Ni7vVNjxgzFS9O1fXDx/4Q4io= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136319; 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=cXeHyRBJtGysaTbKi6BQA5NTou5Xw3Vjerjw7B6BxIY=; b=JucqL1eVmRjfbl7Q7FzAWf/uyZy65P45Ia9BQiCzsY5Ssw151CJBF5xR6TuiMN9oPn3jzIc8bk0JACVC2H9k42qt5IQjrurebB57A8bG0k0gSE8jigKGhUSScaL5Q8KEcLpVbJF9ogk2Hw507/Z113G5lES83GI9nHj/+qXmjaU= 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 1660136319151317.4042343200773; Wed, 10 Aug 2022 05:58:39 -0700 (PDT) Received: from localhost ([::1]:35256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlID-0001va-VX for importer@patchew.org; Wed, 10 Aug 2022 08:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9e-0001po-Sl for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9c-0007TZ-H9 for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:46 -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-324-lEevv345MSCQ5ztdh0Q2kg-1; Wed, 10 Aug 2022 08:49:42 -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 4F4983C14CC5; Wed, 10 Aug 2022 12:49:42 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59F39492C3B; Wed, 10 Aug 2022 12:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135784; 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=cXeHyRBJtGysaTbKi6BQA5NTou5Xw3Vjerjw7B6BxIY=; b=HE+7Jq29hLUXhhXJDuxLWfG5FVWXCp15wuoFvuj/g9mwIJzViUZDhuyHQnND3lUrJ4GlnX YF/s/172TKXCQeSPPDKWD2BPycQ9uDuzqnrpNL2qK1e0tOZXUuNDsaIVLusJn4CTzzWPDb J5kkKatF4K+jZkOFZo9KrB2tKh1+p8g= X-MC-Unique: lEevv345MSCQ5ztdh0Q2kg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 08/16] scripts/qapi-gen: add -i option Date: Wed, 10 Aug 2022 16:48:49 +0400 Message-Id: <20220810124857.1360211-9-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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: 1660136319566100001 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 | 15 +++++++++++++++ scripts/qapi/introspect.py | 11 +++++++---- scripts/qapi/main.py | 17 +++++++++++------ scripts/qapi/types.py | 17 +++++++++++------ scripts/qapi/visit.py | 17 +++++++++++------ 7 files changed, 76 insertions(+), 33 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 38ca38a7b9..781491b639 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 27b44c49f5..6e677d11d2 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 113b49134d..7db46653de 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,10 @@ 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([f'#include "{inc}"' for inc in include]) + + class QAPIGen: def __init__(self, fname: str): self.fname =3D fname @@ -228,16 +233,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 +256,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 +274,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 67c7d89aae..d965d17694 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 fc216a53d3..eba98cb9ac 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 477d027001..9617b7d4ed 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 380fa197f5..1ff464c036 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136898; cv=none; d=zohomail.com; s=zohoarc; b=DwN23rgLHjZj/sOIJ+0E7WCjZrNonUog2zjPQ0Ti6gau5tDs2cPY5Nxcu2PaqB+wLqL6tQ/zZVdjgFqXh/XGNsZoumn5WQEPpdQPq2F3L4Oj+M5iFSi2xozbEMkS6JC3VHnXZjM+G/FyjljbeWTGrsjYfKA5iSIU8JrOAkb4+/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136898; 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=WP4Tsro7iq92SWtEJiexLXCN4s47+YUpCxoFN4SCMN0=; b=U1UdhhHwnOlVoQo+GGfDMv50Ffcj+mZf8eD/QzRRy2UJMJbQuXyk6Wlx+6u/RfUETqvGvF9lDoAvbUobNgDtxp9wshrAucgcf8iaKD8FWjFQ9d5a9p+AESmyU6dzqF2/3KF+sXAZeLnTWjECNRtBzHcrbMgnI3NlWQ/EabsxHIg= 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 1660136898286968.3547673186283; Wed, 10 Aug 2022 06:08:18 -0700 (PDT) Received: from localhost ([::1]:49398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlRZ-0003mN-61 for importer@patchew.org; Wed, 10 Aug 2022 09:08:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9o-0001qt-5U for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9m-0007X2-M0 for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:49:55 -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-304-I0TFpxAqM3y3xfvtX9H2hQ-1; Wed, 10 Aug 2022 08:49:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 282BC3C10171; Wed, 10 Aug 2022 12:49:48 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 051942026D64; Wed, 10 Aug 2022 12:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135794; 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=WP4Tsro7iq92SWtEJiexLXCN4s47+YUpCxoFN4SCMN0=; b=Ijl7gTfZGYWVrAikig6CuCzFF5EgcW5RnobMgi1t3VVL7jYw8m7C9ZjCGPkZb4h9dAFHCS U8zSXgSuidRMrcifXGxGefcLbGGJCk/+nPAynVQOy4L3ihIM5Zf7UXEr1jt3zbWSpbTVdp IRBzwNYDFRMPS/NcXeT2vRrizCnW2pE= X-MC-Unique: I0TFpxAqM3y3xfvtX9H2hQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 09/16] scripts/qapi: add required system includes to visitor Date: Wed, 10 Aug 2022 16:48:50 +0400 Message-Id: <20220810124857.1360211-10-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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.4 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: 1660136900764100001 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 1ff464c036..4aba5ddd8a 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136690; cv=none; d=zohomail.com; s=zohoarc; b=JSnO71xWxo/gL+MPHiR62glrewAMkMTqNceJVHvHzsTYo+fhxP0FTNEphd1ucFWt1I+EGkpDO9+DguaJYGB4TiY7LtN8mEGKRLJRihRLYcIwdFvXOI0mUbAi7NS5LmvyMb4GlAmTCC2UrJJjp9CXhmriqjd+AqITlm5w0gXL6CY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136690; 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=+eXohUduyjohEF9ww8ZVus4+1CSV2I4j5kLCxGMy+20=; b=FFxMR80tNCsRqTqcA2cFzH/59EMNi2Gjm1ppD14MF/Emco/YLjJuVWXzOIuyQJ9f1QfFTeKecxGsp+oqlS1EUpsfpEVrCJifSDDraPZeyDTGl024wzunjdOOcR4s9H0XuYE8nVBplqgn47TzEmbwZ4F/h0RAHLR+6aeoHYZbvsY= 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 1660136690156303.473182218027; Wed, 10 Aug 2022 06:04:50 -0700 (PDT) Received: from localhost ([::1]:43794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlOB-0008Gg-R2 for importer@patchew.org; Wed, 10 Aug 2022 09:04:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9w-0001rA-HH for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLl9u-0007YY-5B for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:04 -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-292-k3d5mrr8PmW5IghLuY5pEg-1; Wed, 10 Aug 2022 08:49:59 -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 4DF3F91B1FA; Wed, 10 Aug 2022 12:49:53 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B041492CA9; Wed, 10 Aug 2022 12:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135801; 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=+eXohUduyjohEF9ww8ZVus4+1CSV2I4j5kLCxGMy+20=; b=MrQKRduYwNhwicrbSQZw6wF7P4F23yHLWlpLOMOmiDX3qQRNtMuGzz1Zkd/EUSBOgkkDI9 Rz4K7aFxPk4J2jJaJDJIvQyNlaeXf2ADf6Yflhg0xd/UTfH3FH4BwhI4vg9oZpoxE/QpKb miFnn1CZFMdzbOF0xtKhTcC7ixpvYuc= X-MC-Unique: k3d5mrr8PmW5IghLuY5pEg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 10/16] util: move 256-by-128 division helpers to int128 Date: Wed, 10 Aug 2022 16:48:51 +0400 Message-Id: <20220810124857.1360211-11-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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: 1660136692660100002 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 88d476161c..e8162fb6b0 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, @@ -784,6 +783,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 d2b76ca6ac..823c61edb0 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 fb91bcba82..96d5dc0bed 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 ed8f25fef1..482c63b655 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136950; cv=none; d=zohomail.com; s=zohoarc; b=cjEj8HkxIBm4zYDSfo3AZeCcdep+FN2tn17V+ZLSyPrKjSNBxkCA+3DVn+tqgEjr3Oo2GmZr4r7uiefn6WlQAD3tcVbwFNmhU9efql3E5huDHX1blKbVRGvgBnaasBu4QWWv7LP/qNRj9YJ4X7lf9e4wknTljsIpQ10sgwOwolo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136950; 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=FV5JOZPDoT9vhnkmPbtByhwUWEwvTo3eOwUz3nk743w=; b=LEfLgNQ3kTHcroi6qJKmqF1HKmPeDaBsNPYMymr2yz1DA/BRA3MnB4XCSSBvSmpn26j5Fgip/r70F0opjmke4W4XmN0RvBvZPHvphBYSxWDx9uh1vWEc69w8MghLXjMXsmF1HVQ3bbDaTuyksRQWDrz0sOw0MRHD3Qi8mgG+PP8= 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 1660136950772446.29464709041724; Wed, 10 Aug 2022 06:09:10 -0700 (PDT) Received: from localhost ([::1]:52278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlSP-0005vE-M7 for importer@patchew.org; Wed, 10 Aug 2022 09:09:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAV-0001uI-2I for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAD-0007qw-RF for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:28 -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-386-TluCTiIrOVyF1JJVtpcV6Q-1; Wed, 10 Aug 2022 08:50:14 -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 AD86D3C138DF; Wed, 10 Aug 2022 12:49:58 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46DD640CFD21; Wed, 10 Aug 2022 12:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135817; 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=FV5JOZPDoT9vhnkmPbtByhwUWEwvTo3eOwUz3nk743w=; b=bVyIf1zo4hx3sE/U/p7U5xwSgohx8DXhWcojnLvppjAgRPEA69bgee1tV4rI0nuoeYqJGO przHrrNZAjyzK4GherEuKB9qoCaXkuxIEDe4sZrSumxPX39d1soT5WWPBaiagTFBI0IKHr gCH/Fx7R+2XL9hSplB3Srpg+/QtOIbU= X-MC-Unique: TluCTiIrOVyF1JJVtpcV6Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 11/16] qemu-common: introduce a common subproject Date: Wed, 10 Aug 2022 16:48:52 +0400 Message-Id: <20220810124857.1360211-12-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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: 1660136952848100001 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 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 ++++++++ 7 files changed, 22 insertions(+), 1 deletion(-) 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 294e9a8f32..a47ce88c84 100644 --- a/meson.build +++ b/meson.build @@ -169,6 +169,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 @@ -1583,6 +1587,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 # ################# @@ -3057,7 +3064,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/subprojects/libvduse/meson.build b/subprojects/libvduse/meson.= build index ba08f5ee1a..841509ecb9 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 0000000000..4c1c87018a --- /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 39825d9404..73355908e0 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 0000000000..4c1c87018a --- /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 0000000000..8969b08473 --- /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.1 From nobody Tue May 7 23:10:37 2024 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=1660136810; cv=none; d=zohomail.com; s=zohoarc; b=ltWQdAtiCGPpJDspAL8Gcsl8TTn7o932Gd2GnGjiKIo6go/W4RC0H1JM4UoumzzVwcnlPH3aPran+AkZXvo5xG0tGW4sZBtcuNc8YIw1fgLfArRiIdXfylGdH4Ghqt5zuZ6fLctF1+/14Z2xCfZY1Y+Ryx2OMLxQmGUp4pkTIoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136810; 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=eHKLpZT4lsKz8ntscq6c0yk6FA9n5rHUUvBl+QS1vU4=; b=SgGVpT/3yTo3k9uNkN6Os1t7YeUF6o1kFc1+e2utRNigETXd3WL02LNVOo7qsCyTeZDThQ6eOH4tGxaQNo0IeKp/aHNhcc/sK4+NfIe7LsTCcEg/c8yDJdP1CZRDAjbVj03PYruj0DDFXCkE0V3iI6CBN/P365Rhglwn9ETlBRE= 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 1660136810019259.5956092647144; Wed, 10 Aug 2022 06:06:50 -0700 (PDT) Received: from localhost ([::1]:46432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlQ8-0001hx-TH for importer@patchew.org; Wed, 10 Aug 2022 09:06:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAV-0001uN-2l for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45656) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAI-0007sV-H1 for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:33 -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-507-wfwJi-tIP9iZcZnoh0q1rw-1; Wed, 10 Aug 2022 08:50:19 -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 EC155858F11; Wed, 10 Aug 2022 12:50:03 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CA899459C; Wed, 10 Aug 2022 12:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135823; 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=eHKLpZT4lsKz8ntscq6c0yk6FA9n5rHUUvBl+QS1vU4=; b=TN91+knJdIueK8W1oZL9HuFTnzIJz1DUVeD1fIzpXlpiSSDYg1BCb0APH8lKUdpw6YU5WA B3Zg+eKZ7zPv4FOV9dVrJmsSvBGtknjzKrlBrwkTayTV/qZsW6yzRXBlcKN5HrhXWYbjv5 /XXOVFMxUe1buwO/b0+PQpGxJBx87/8= X-MC-Unique: wfwJi-tIP9iZcZnoh0q1rw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 12/16] qemu-common: move scripts/qapi Date: Wed, 10 Aug 2022 16:48:53 +0400 Message-Id: <20220810124857.1360211-13-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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: -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: 1660136811943100003 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 e33cf3d381..02dcd987b4 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 a47ce88c84..e8ba4361df 100644 --- a/meson.build +++ b/meson.build @@ -1588,6 +1588,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 ################# @@ -2795,23 +2797,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 5ce4227ff6..abb75008fb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2848,8 +2848,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 8969b08473..207e539910 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 0000000000..626bed6dcd --- /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 0000000000..5f73a966f3 --- /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 c18dd7d02f..2c67636004 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.1 From nobody Tue May 7 23:10:37 2024 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=1660137197; cv=none; d=zohomail.com; s=zohoarc; b=Qt/G4rfjbUdRMc8R4EqnfslgObsfRGYmJHVofSMwv3qbUL1by+gmu4Qr1xxZHILyQqkAB6gqkCMsOFvGP3teGb0gda4ipnjalEIaaROhTSAJlQJ0uawn/0Xe1Vfw/q/29445rH93+j2oNbHLNEq9tS5gQmHymN/2wCrVusBtn6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660137197; 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=m9he5H3XIAFx+28xTXCytUMSLUaO3/+gi4NHH9/XvKw=; b=nUBwAI/nA+atMsb+V0ZY2X94NhpyPrgkmG35Re721GvrrF3m5N023Qp+3AP6YNqE+pRHF6rgKfI8EYs1M1fWT6Dd6zwnqayJ0rXaRlOzt0SKdNLFXdbm4YmgzsM4/j/E9awdW4lx9MeEOEQnRhlLG+DkPlQQhY8fszAZlTjsPLU= 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 1660137197116982.9850701632721; Wed, 10 Aug 2022 06:13:17 -0700 (PDT) Received: from localhost ([::1]:35404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlWN-0005Hn-VZ for importer@patchew.org; Wed, 10 Aug 2022 09:13:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAV-0001uJ-4N for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29510) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAC-0007r0-Pg for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:24 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-222-xyh6rb4QMtm2s1I9iusCNA-1; Wed, 10 Aug 2022 08:50:16 -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 5C4E63817A90; Wed, 10 Aug 2022 12:50:09 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05E511415124; Wed, 10 Aug 2022 12:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135817; 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=m9he5H3XIAFx+28xTXCytUMSLUaO3/+gi4NHH9/XvKw=; b=MaGK/MO4zWVpUiiUjwddNb+qG7TlJP7jaD9M8d0cEUTJUDumhgX/9JCCBfH83Fl6d6YP8p /GlzMEopadObuo+nHstGkLRbngTRKlVbS6c5cQo5Jjz7nb2PbgX7KS6elXBULo8t6P7llN dT/IrKA7d4r24/O3TDJi3bnOCBXjjYg= X-MC-Unique: xyh6rb4QMtm2s1I9iusCNA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 13/16] qemu-common: move glib-compat.h Date: Wed, 10 Aug 2022 16:48:54 +0400 Message-Id: <20220810124857.1360211-14-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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.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: 1660137198955100001 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 43a562974d..2b0f2962f3 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.1 From nobody Tue May 7 23:10:37 2024 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=1660136987; cv=none; d=zohomail.com; s=zohoarc; b=W5am86VcEgOlSrloF0i0kXmVFQfqwzc3bQSzqRRg+dt8i0aWHt0H1grqOQrMNk1lKuvJRPKp9ycoxLjxk/pEHJ2j+bCZVCaUtCBOad5nJGtTxj72gIQ4ctZeDP1ZZ0Rh4fMZD5nRNgNQF80KVWVmHAAu1m6viKUqtlVEaEi+8vs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660136987; 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=0HUTxhtgJORczNaSzLe/NTkSddDJpq5s+od7ABk2HhY=; b=dx/7ZggVybg7HBzrvw89RDZAtfo0cZdRTU8gApujl0I+UPfyR5RioSWGTwVFSPoIDj0CoE0Qs/r/tReHMINKVY0vkM3jDdQIEqghXFBrxfAknlfhL8dc8hDaXtEhU0mjix0WpLt41fe9ePhuTa18I1Nco4yS9inbxzDNUfywx3E= 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 1660136987269754.8547102289132; Wed, 10 Aug 2022 06:09:47 -0700 (PDT) Received: from localhost ([::1]:55142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlT0-0007pf-5w for importer@patchew.org; Wed, 10 Aug 2022 09:09:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAV-0001uK-2L for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAE-0007sJ-FD for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:30 -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-475-FhDdYDgCPBGazgpDwIcabQ-1; Wed, 10 Aug 2022 08:50:17 -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 EBF9383395D; Wed, 10 Aug 2022 12:50:13 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBEBF18EAA; Wed, 10 Aug 2022 12:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135819; 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=0HUTxhtgJORczNaSzLe/NTkSddDJpq5s+od7ABk2HhY=; b=VA3yafjNWe42g7MZKSL6gtlg+QZmJYIBed92DyVdTqeCCbhjhGmN7NYrUILybtmOdStk7G 4dS/iqDbiVpODhb34FhtxqqhqcBlYa+/0fh5HTATolwv0o9FIfCp1coH0C0IbXLTVuIheH 6fOEKxcZc1gPJhOkABZJTOC39nf+uzw= X-MC-Unique: FhDdYDgCPBGazgpDwIcabQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 14/16] qemu-common: move error-report Date: Wed, 10 Aug 2022 16:48:55 +0400 Message-Id: <20220810124857.1360211-15-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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: -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: 1660136989048100001 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 6ab25d4583..c62dd1a633 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 c47cd23693..c3d9c3454d 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 4d1d66fc06..616428fe95 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 1afa0f62ca..b815d88dfe 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 14548633b0..865b677f2a 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 207e539910..05bca6d30d 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 0000000000..d85a314065 --- /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 5e282130df..38bb08675b 100644 --- a/util/meson.build +++ b/util/meson.build @@ -29,7 +29,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.1 From nobody Tue May 7 23:10:37 2024 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=1660137458; cv=none; d=zohomail.com; s=zohoarc; b=RHoVltEI2du5fVX2rv8mEgm4EjUhyO9t+Ow8Gw24ghGRoF4Y4a62iwv/gYb4Sr4I3ElnEKYvZpCgFCA6OIrdqJwtt1m9RwcgQ01uRSyLh1uXzXPG1FFCPIjdAnSC4PX2/GJANzzPPa2WbN4l8NYJ1V7m2taDNfG1hery2Mnu0BQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660137458; 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=OJEjBHrHzv11//F1wtjzfMSrHuEe+LS5JdAUogditrc=; b=cg7r6suCWKtsCmi+PCe5gc58hqb8wdNiepvuSX8ZpuERu5TZ/85HoodmUg+1clWM9xXo5DmkKv3kPqeZiGUMhLPxfn9LeOMSKHgjX2OEgQQ5HqfZkq4JtU+YdlFXyvBLMBJpeN7wTbN6bTi7yV+mI/H8I7UCxMiwxVFaAvlWSlI= 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 1660137458122233.1258795765001; Wed, 10 Aug 2022 06:17:38 -0700 (PDT) Received: from localhost ([::1]:43836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlaZ-0002kB-AM for importer@patchew.org; Wed, 10 Aug 2022 09:17:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAV-0001uL-35 for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAM-0007t5-1O for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:32 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-630-2IOeSgQ_NXSG-kkmtZziwQ-1; Wed, 10 Aug 2022 08:50:25 -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 A5144806002; Wed, 10 Aug 2022 12:50:18 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id A45FE1121315; Wed, 10 Aug 2022 12:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135826; 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=OJEjBHrHzv11//F1wtjzfMSrHuEe+LS5JdAUogditrc=; b=PjUk81AkEm3YdMYvJ2PGdQ/5sN52xFKL7iZeXqhhMI66NWGW/xtt7QUEjSSry6rvUnNNNt 6ipkhclwhRTrnasg2JlKjHXRPczo3ywDi8DkaZoprtc3UPVOHDGogjPtVgxiaqafaIdyQY oa/lp3qbqVqS9K2XTGmikkzUKGE9cFY= X-MC-Unique: 2IOeSgQ_NXSG-kkmtZziwQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 15/16] mtest2make.py: teach suite name that are just "PROJECT" Date: Wed, 10 Aug 2022 16:48:56 +0400 Message-Id: <20220810124857.1360211-16-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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.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: 1660137460336100001 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py index 0fe81efbbc..179dd54871 100644 --- a/scripts/mtest2make.py +++ b/scripts/mtest2make.py @@ -51,10 +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] - if s =3D=3D 'slow' or s =3D=3D 'thorough': - continue + # The suite name in the introspection info is "PROJECT" or "PROJEC= T:SUITE" + if ':' in s: + s =3D s.split(':')[1] + if s =3D=3D 'slow' or s =3D=3D 'thorough': + continue if s.endswith('-slow'): s =3D s[:-5] suites[s].speeds.append('slow') --=20 2.37.1 From nobody Tue May 7 23:10:37 2024 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=1660137080; cv=none; d=zohomail.com; s=zohoarc; b=jYwaxcYe6zV9LqpBprDN0cSgct5jjnTp2B2hGAovZFtFcoeFb9LesCw4IJ1Muxz1hhtigsFy+ZjQZWH4uV+SAH6/Dh3AzF53PkCp0BsTz2/Qkv4nE4rXrXL774encWvpUiLwtdL0xAxqYQasyC/Lua6hmagi+ucFr6D82NhTZAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660137080; 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=QW2JkB+lQDvso8ZSmM25soHjoDYOqnfuVmKcQmRfYOk=; b=U8xyQ6H7q6FfAUnzcQC5uKcdq60FOjQ2UelU2wkka/TArn4HPuVBvBS6oKizpt97IfvCSS3zHSPCqCgWMDLkJIuYK3Ah8RJQO5clqhkey7CaLFd8xfY/VDJMBJbb18oV9bUGToTKLhmmcDyMbTITYWMLXcAFoJKX3el/mYVo1VU= 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 1660137080056454.522991705904; Wed, 10 Aug 2022 06:11:20 -0700 (PDT) Received: from localhost ([::1]:58084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLlUU-0001QD-T5 for importer@patchew.org; Wed, 10 Aug 2022 09:11:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAU-0001uM-VV for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLlAM-0007tQ-VJ for qemu-devel@nongnu.org; Wed, 10 Aug 2022 08:50:33 -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-266-euwjXadhOz-qM6XeYva41A-1; Wed, 10 Aug 2022 08:50:28 -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 2CECD19711D0; Wed, 10 Aug 2022 12:50:23 +0000 (UTC) Received: from localhost (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC9D340315E; Wed, 10 Aug 2022 12:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660135830; 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=QW2JkB+lQDvso8ZSmM25soHjoDYOqnfuVmKcQmRfYOk=; b=CL48cim94Ubl0IpOeyH0MymYdqhhY8Uu31Jf9yBPzWUe3RX7Vh45xqKL901HClE0MEQ0yk I0gT7gbV+G97SFb/VQ8jFCy31ywQuZ/ATjgGbU1Illk+JZWse0MJrHpqIiCCo/ZdumT5X3 EkyqufGZUUCS6WCPjUTpbKA7GKnjPWQ= X-MC-Unique: euwjXadhOz-qM6XeYva41A-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Markus Armbruster , Peter Maydell , Cleber Rosa , Michael Roth , John Snow , Xie Yongji , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v3 16/16] qemu-common: add error-report test Date: Wed, 10 Aug 2022 16:48:57 +0400 Message-Id: <20220810124857.1360211-17-marcandre.lureau@redhat.com> In-Reply-To: <20220810124857.1360211-1-marcandre.lureau@redhat.com> References: <20220810124857.1360211-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: 1660137082085100001 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 0000000000..09a2d122a0 --- /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 05bca6d30d..991aaac520 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 0000000000..3dd10c180b --- /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.1