From nobody Mon Feb 9 03:55:59 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580420517854925.8090695714307; Thu, 30 Jan 2020 13:41:57 -0800 (PST) Received: from localhost ([::1]:39512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHZT-00078I-6j for importer@patchew.org; Thu, 30 Jan 2020 16:41:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59060) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHWI-0002G4-Fk for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHWH-0000js-7V for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:38 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:37656 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixHWH-0000ia-3K for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-3-vNHtgLZ9MEyZb4hdSnIHdA-1; Thu, 30 Jan 2020 16:38:31 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C50635F9; Thu, 30 Jan 2020 21:38:30 +0000 (UTC) Received: from localhost (unknown [10.36.118.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C9BA5C1B2; Thu, 30 Jan 2020 21:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420316; 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=M5I3Td1QdEAZSEZF4gwact89ja48eL8CsMNkahbAyUg=; b=GG2QfK9YMy+b4YBrJg3tvi3sfEeTs0Z5zpIcdvEsAO2adO9WeWe1QlrvtcH9PB7F6X9qqA HidM0Vy6lzohw3xLuBUauII4U9l3tcooKC6fkHvg2FOAfurop+OYkKiuXm5BxG/e9AroE7 Of48ehFwtLrG8Zv/MKmq6VFmKCXD5Zk= From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 1/5] Makefile: Keep trace-events-subdirs ordered Date: Thu, 30 Jan 2020 21:38:10 +0000 Message-Id: <20200130213814.334195-2-stefanha@redhat.com> In-Reply-To: <20200130213814.334195-1-stefanha@redhat.com> References: <20200130213814.334195-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: vNHtgLZ9MEyZb4hdSnIHdA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Peter Maydell , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Adding the same directory multiple times to trace-events-subdirs might trigger build failures, in particular when using the LTTng Userspace Tracer library as backend. For example when using two times the hw/core/ directory: $ ./configure --enable-trace-backends=3Dust && make [...] CC trace-ust-all.o In file included from trace-ust-all.h:13, from trace-ust-all.c:13: trace-ust-all.h:35151:1: error: redefinition of =E2=80=98__tracepoint_cb= _qemu___loader_write_rom=E2=80=99 35151 | TRACEPOINT_EVENT( | ^~~~~~~~~~~~~~~~ trace-ust-all.h:31791:1: note: previous definition of =E2=80=98__tracepo= int_cb_qemu___loader_write_rom=E2=80=99 was here 31791 | TRACEPOINT_EVENT( | ^~~~~~~~~~~~~~~~ To ease review and reduce likelihood of merge failures (see [*]), keep trace-events-subdirs ordered when possible, following eb7ccb3c0. [*] https://www.mail-archive.com/qemu-devel@nongnu.org/msg671007.html Duplicate trace-events-subdirs entries generates duplicated symbols when using the LTTng Userspace Tracer library. Reviewed-by: Damien Hedde Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20200116114339.30670-1-philmd@redhat.com Message-Id: <20200116114339.30670-1-philmd@redhat.com> Signed-off-by: Stefan Hajnoczi --- Makefile.objs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index f2da7241fc..26b9cff954 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -132,8 +132,8 @@ trace-events-subdirs +=3D nbd trace-events-subdirs +=3D scsi endif ifeq ($(CONFIG_SOFTMMU),y) -trace-events-subdirs +=3D chardev trace-events-subdirs +=3D audio +trace-events-subdirs +=3D chardev trace-events-subdirs +=3D hw/9pfs trace-events-subdirs +=3D hw/acpi trace-events-subdirs +=3D hw/alpha @@ -181,6 +181,7 @@ trace-events-subdirs +=3D migration trace-events-subdirs +=3D net trace-events-subdirs +=3D ui endif +trace-events-subdirs +=3D hw/core trace-events-subdirs +=3D hw/display trace-events-subdirs +=3D qapi trace-events-subdirs +=3D qom @@ -193,7 +194,6 @@ trace-events-subdirs +=3D target/riscv trace-events-subdirs +=3D target/s390x trace-events-subdirs +=3D target/sparc trace-events-subdirs +=3D util -trace-events-subdirs +=3D hw/core =20 trace-events-files =3D $(SRC_PATH)/trace-events $(trace-events-subdirs:%= =3D$(SRC_PATH)/%/trace-events) =20 --=20 2.24.1 From nobody Mon Feb 9 03:55:59 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580420701198612.1359827149686; Thu, 30 Jan 2020 13:45:01 -0800 (PST) Received: from localhost ([::1]:39572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHcS-00048N-54 for importer@patchew.org; Thu, 30 Jan 2020 16:45:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59073) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHWY-0002Lp-3N for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHWI-0000lW-41 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:43 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:29195 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixHWI-0000lO-07 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-zykWt2SkPCGM92aN8gdr3w-1; Thu, 30 Jan 2020 16:38:33 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9EC8018A6EC0; Thu, 30 Jan 2020 21:38:32 +0000 (UTC) Received: from localhost (unknown [10.36.118.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3380A84BCE; Thu, 30 Jan 2020 21:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420317; 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=aY59D12iK9EuHf67AzITwqwSdm0FUzPT3g3NX2Qq8xQ=; b=JOScTWY18MRerETozS+PUeHZVxoV1Boq57uOc/IiwYsh3aIDcSWswfqOi/nCEZtnCaShzO e5nWBh57nfib5kXCX98WYVXkb1DnReabP8DtXX4en4kd4Y/FXSZgw36j1GZkpKYROCVTOi /w2Ca//O+tPstpSKxOX/YygYMAl8bgg= From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 2/5] docs/devel/tracing.txt: Recommend only trace_event_get_state_backends() Date: Thu, 30 Jan 2020 21:38:11 +0000 Message-Id: <20200130213814.334195-3-stefanha@redhat.com> In-Reply-To: <20200130213814.334195-1-stefanha@redhat.com> References: <20200130213814.334195-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: zykWt2SkPCGM92aN8gdr3w-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Maydell Instead of recommending checking the TRACE_FOO_ENABLED macro to skip expensive computations needed only for tracing, recommend only using trace_event_get_state_backends(). This works for both compile-time and run-time disabling of events, and has no extra performance impact if the event is compile-time disabled. Signed-off-by: Peter Maydell Message-id: 20200120151142.18954-2-peter.maydell@linaro.org Message-Id: <20200120151142.18954-2-peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi --- docs/devel/tracing.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/devel/tracing.txt b/docs/devel/tracing.txt index 8c0376fefa..cb5f685de9 100644 --- a/docs/devel/tracing.txt +++ b/docs/devel/tracing.txt @@ -342,8 +342,10 @@ edit the "trace-events-all" file). =20 In addition, there might be cases where relatively complex computations mu= st be performed to generate values that are only used as arguments for a trace -function. In these cases you can use the macro 'TRACE_${EVENT_NAME}_ENABLE= D' to -guard such computations and avoid its compilation when the event is disabl= ed: +function. In these cases you can use 'trace_event_get_state_backends()' to +guard such computations, so they are skipped if the event has been either +compile-time disabled or run-time disabled. If the event is compile-time +disabled, this check will have no performance impact. =20 #include "trace.h" /* needed for trace event prototype */ =20 @@ -356,7 +358,7 @@ guard such computations and avoid its compilation when = the event is disabled: align =3D getpagesize(); } ptr =3D qemu_memalign(align, size); - if (TRACE_QEMU_VMALLOC_ENABLED) { /* preprocessor macro */ + if (trace_event_get_state_backends(TRACE_QEMU_VMALLOC)) { void *complex; /* some complex computations to produce the 'complex' value */ trace_qemu_vmalloc(size, ptr, complex); @@ -364,10 +366,6 @@ guard such computations and avoid its compilation when= the event is disabled: return ptr; } =20 -You can check both if the event has been disabled and is dynamically enabl= ed at -the same time using the 'trace_event_get_state_backends' routine (see head= er -"trace/control.h" for more information). - =3D=3D=3D "tcg" =3D=3D=3D =20 Guest code generated by TCG can be traced by defining an event with the "t= cg" --=20 2.24.1 From nobody Mon Feb 9 03:55:59 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158042095420153.581942157083176; Thu, 30 Jan 2020 13:49:14 -0800 (PST) Received: from localhost ([::1]:39746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHgX-0002pu-3M for importer@patchew.org; Thu, 30 Jan 2020 16:49:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59102) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHWc-0002Oy-Nf for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHWb-0000sd-18 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:58 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:36834 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixHWa-0000op-D3 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-303-kCCDpSp0M3aETlBpPT3fLg-1; Thu, 30 Jan 2020 16:38:40 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9443118A6EC1; Thu, 30 Jan 2020 21:38:39 +0000 (UTC) Received: from localhost (unknown [10.36.118.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id C141960BE0; Thu, 30 Jan 2020 21:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420323; 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=4bJ8TzHQALlGcsbo6CfAHKgxLT0lBqzcK+7zzlvq1Zs=; b=bDCVml6qB/VWmaMTxLWCwfTAYcFeU2ZvmqpIg3BB8xo5mgKsoa2DPxBG9NIpq8idw5o2Iy U8QTasgG0fqAl/uSwkjtb3MwzLJ2GNXK1nAeMDR173dFTwUMLlFnGqgbliT/AHxgDhDnwv XWPWsU8k/lb6+lHdoOvuM3uaa8bqBbc= From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 3/5] memory.c: Use trace_event_get_state_backends() Date: Thu, 30 Jan 2020 21:38:12 +0000 Message-Id: <20200130213814.334195-4-stefanha@redhat.com> In-Reply-To: <20200130213814.334195-1-stefanha@redhat.com> References: <20200130213814.334195-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: kCCDpSp0M3aETlBpPT3fLg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Maydell The preferred way to test whether a trace event is enabled is to use trace_event_get_state_backends(), because this will give the correct answer (allowing expensive computations to be skipped) whether the trace event is compile-time or run-time disabled. Convert the four old-style direct uses of TRACE_FOO_ENABLED in memory.c. Signed-off-by: Peter Maydell Message-id: 20200120151142.18954-3-peter.maydell@linaro.org Message-Id: <20200120151142.18954-3-peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi --- memory.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/memory.c b/memory.c index 854798791e..aeaa8dcc9e 100644 --- a/memory.c +++ b/memory.c @@ -434,7 +434,7 @@ static MemTxResult memory_region_read_accessor(MemoryR= egion *mr, tmp =3D mr->ops->read(mr->opaque, addr, size); if (mr->subpage) { trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, s= ize); - } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { + } else if (trace_event_get_state_backends(TRACE_MEMORY_REGION_OPS_READ= )) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); } @@ -456,7 +456,7 @@ static MemTxResult memory_region_read_with_attrs_access= or(MemoryRegion *mr, r =3D mr->ops->read_with_attrs(mr->opaque, addr, &tmp, size, attrs); if (mr->subpage) { trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, s= ize); - } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { + } else if (trace_event_get_state_backends(TRACE_MEMORY_REGION_OPS_READ= )) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, s= ize); } @@ -476,7 +476,7 @@ static MemTxResult memory_region_write_accessor(MemoryR= egion *mr, =20 if (mr->subpage) { trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, = size); - } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { + } else if (trace_event_get_state_backends(TRACE_MEMORY_REGION_OPS_WRIT= E)) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); } @@ -496,7 +496,7 @@ static MemTxResult memory_region_write_with_attrs_acces= sor(MemoryRegion *mr, =20 if (mr->subpage) { trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, = size); - } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { + } else if (trace_event_get_state_backends(TRACE_MEMORY_REGION_OPS_WRIT= E)) { hwaddr abs_addr =3D memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, = size); } --=20 2.24.1 From nobody Mon Feb 9 03:55:59 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580420559468175.60398860401142; Thu, 30 Jan 2020 13:42:39 -0800 (PST) Received: from localhost ([::1]:39526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHaA-00087s-Ay for importer@patchew.org; Thu, 30 Jan 2020 16:42:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59101) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHWc-0002Ov-NT for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHWb-0000sY-16 for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:58 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48611 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixHWa-0000qA-BG for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-138-Srb6hHFnMDO8bl6-4fxtgQ-1; Thu, 30 Jan 2020 16:38:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AE92800D48; Thu, 30 Jan 2020 21:38:46 +0000 (UTC) Received: from localhost (unknown [10.36.118.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 048E987B00; Thu, 30 Jan 2020 21:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420329; 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=eOdBGk8Ti42m26thpGsTgXlNQcjGRQeyLHjmuldSczI=; b=edXKZc8p/UahxnfOE2N+CEwR/0tNJMpI8HiuLHVAtuslqxAljjahWC6hxlX5IprJ5v+je/ 8NQob//8Ij8yvm8OSCGgNa2jP2UrSU9/MbzeTlEb+7RbeLmDoTt87p69EgqLHVb8PgYHJS 2jV2QvtnYE9QUVJClweaexDBWMP2BKM= From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 4/5] hw/display/qxl.c: Use trace_event_get_state_backends() Date: Thu, 30 Jan 2020 21:38:13 +0000 Message-Id: <20200130213814.334195-5-stefanha@redhat.com> In-Reply-To: <20200130213814.334195-1-stefanha@redhat.com> References: <20200130213814.334195-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Srb6hHFnMDO8bl6-4fxtgQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Peter Maydell The preferred way to test whether a trace event is enabled is to use trace_event_get_state_backends(), because this will give the correct answer (allowing expensive computations to be skipped) whether the trace event is compile-time or run-time disabled. Convert the old-style direct use of TRACE_FOO_ENABLED. Signed-off-by: Peter Maydell Acked-by: Gerd Hoffmann Message-id: 20200120151142.18954-4-peter.maydell@linaro.org Message-Id: <20200120151142.18954-4-peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi --- hw/display/qxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 944c02ce56..c33b1915a5 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1764,7 +1764,7 @@ async_common: qxl_set_mode(d, val, 0); break; case QXL_IO_LOG: - if (TRACE_QXL_IO_LOG_ENABLED || d->guestdebug) { + if (trace_event_get_state_backends(TRACE_QXL_IO_LOG) || d->guestde= bug) { /* We cannot trust the guest to NUL terminate d->ram->log_buf = */ char *log_buf =3D g_strndup((const char *)d->ram->log_buf, sizeof(d->ram->log_buf)); --=20 2.24.1 From nobody Mon Feb 9 03:55:59 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580420671877425.9004316588363; Thu, 30 Jan 2020 13:44:31 -0800 (PST) Received: from localhost ([::1]:39562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHby-000395-EW for importer@patchew.org; Thu, 30 Jan 2020 16:44:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59138) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixHWf-0002UD-2A for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:39:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixHWb-0000tM-KW for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:39:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27045 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ixHWb-0000s3-0n for qemu-devel@nongnu.org; Thu, 30 Jan 2020 16:38:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-3-vjG5wI40Nr-WL6SgY4zSPw-1; Thu, 30 Jan 2020 16:38:54 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8265818A6EC0; Thu, 30 Jan 2020 21:38:53 +0000 (UTC) Received: from localhost (unknown [10.36.118.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD81E5C296; Thu, 30 Jan 2020 21:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580420336; 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=7fwh0ME1HVlBOgnkxranGKr/eF5Lv+1xWTQqUr+ffoQ=; b=FRT1CmdBrCjeSD3NmSFbT6jA+NXivSk1lClWbOYQPY4qTPrUVms/1n0l8jNDxUJXKCxr4m RLGnEnNEbqVp6QhNW++a+RW4FZASeNXQ6K3qV8V7DAwIX+zZfVB/lG+rShABScET/UN+sD 3D0b7ShHpAreYZMHLxduLwzBVDkMaqE= From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PULL 5/5] qemu_set_log_filename: filename argument may be NULL Date: Thu, 30 Jan 2020 21:38:14 +0000 Message-Id: <20200130213814.334195-6-stefanha@redhat.com> In-Reply-To: <20200130213814.334195-1-stefanha@redhat.com> References: <20200130213814.334195-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: vjG5wI40Nr-WL6SgY4zSPw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Salvador Fandino , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Salvador Fandino NULL is a valid log filename used to indicate we want to use stderr but qemu_set_log_filename (which is called by bsd-user/main.c) was not handling it correctly. That also made redundant a couple of NULL checks in calling code which have been removed. Signed-off-by: Salvador Fandino Message-Id: <20200123193626.19956-1-salvador@qindel.com> Signed-off-by: Stefan Hajnoczi --- trace/control.c | 4 +--- util/log.c | 28 ++++++++++++++++------------ vl.c | 5 +---- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/trace/control.c b/trace/control.c index 0fb8124160..6c775e68eb 100644 --- a/trace/control.c +++ b/trace/control.c @@ -229,9 +229,7 @@ void trace_init_file(const char *file) /* If both the simple and the log backends are enabled, "--trace file" * only applies to the simple backend; use "-D" for the log backend. */ - if (file) { - qemu_set_log_filename(file, &error_fatal); - } + qemu_set_log_filename(file, &error_fatal); #else if (file) { fprintf(stderr, "error: --trace file=3D...: " diff --git a/util/log.c b/util/log.c index 867264da8d..47f2827397 100644 --- a/util/log.c +++ b/util/log.c @@ -148,25 +148,29 @@ void qemu_log_needs_buffers(void) * Allow the user to include %d in their logfile which will be * substituted with the current PID. This is useful for debugging many * nested linux-user tasks but will result in lots of logs. + * + * filename may be NULL. In that case, log output is sent to stderr */ void qemu_set_log_filename(const char *filename, Error **errp) { - char *pidstr; g_free(logfilename); logfilename =3D NULL; =20 - pidstr =3D strstr(filename, "%"); - if (pidstr) { - /* We only accept one %d, no other format strings */ - if (pidstr[1] !=3D 'd' || strchr(pidstr + 2, '%')) { - error_setg(errp, "Bad logfile format: %s", filename); - return; - } else { - logfilename =3D g_strdup_printf(filename, getpid()); - } - } else { - logfilename =3D g_strdup(filename); + if (filename) { + char *pidstr =3D strstr(filename, "%"); + if (pidstr) { + /* We only accept one %d, no other format strings */ + if (pidstr[1] !=3D 'd' || strchr(pidstr + 2, '%')) { + error_setg(errp, "Bad logfile format: %s", filename); + return; + } else { + logfilename =3D g_strdup_printf(filename, getpid()); + } + } else { + logfilename =3D g_strdup(filename); + } } + qemu_log_close(); qemu_set_log(qemu_loglevel); } diff --git a/vl.c b/vl.c index 24951b51a9..7dcb0879c4 100644 --- a/vl.c +++ b/vl.c @@ -3903,10 +3903,7 @@ int main(int argc, char **argv, char **envp) =20 /* Open the logfile at this point and set the log mask if necessary. */ - if (log_file) { - qemu_set_log_filename(log_file, &error_fatal); - } - + qemu_set_log_filename(log_file, &error_fatal); if (log_mask) { int mask; mask =3D qemu_str_to_log_mask(log_mask); --=20 2.24.1