From nobody Sun Sep 28 15:29:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1758794972; cv=none; d=zohomail.com; s=zohoarc; b=Uf2xYKV0DOt6egshIvOW1gWtgGCi3PbUIHs7yDBu/E6SVzM/1d31wzZac3EgmSrGb6VCoKAbd/D9XOXjpxrsZgualOW6wnkqadqFUOPWyMbrjMuBB2pXZHRJ65DftmWc+1fPGF0U4oD/howXE45rzU5plPaYmbrzdM9V4imO37U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758794972; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=lhvlmbocLMImejtfkUQoIH3CBQ2wk54B4Lb6eRqTx5U=; b=lvNJtEg4/piLZ8ZjWIk0aZbp6l5q84X3EwyfxA8veCZlVjeot2mvkDdhB7a98ydfNvpLBGNuZxOBBYi1FkTF3zpkvZB38o1kWSMe7XNEJWGMW7uZpdNouIg3z7KPxlXdMNkeRLaCvAj8V+W0v7x4XOHhPA50rdPEBeTEZTxpGLg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17587949720861013.5242044213453; Thu, 25 Sep 2025 03:09:32 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 2D85543F75; Thu, 25 Sep 2025 06:09:30 -0400 (EDT) Received: from [172.19.199.14] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 2EF7B44094; Thu, 25 Sep 2025 05:48:55 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id BFDBC41A9A; Thu, 25 Sep 2025 05:48:20 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5337343DC3 for ; Thu, 25 Sep 2025 05:45:42 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-410-EoJm9mPwOkqu78JmdZ4qmg-1; Thu, 25 Sep 2025 05:45:37 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 25C001955D48; Thu, 25 Sep 2025 09:45:36 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.163]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B24C4300021A; Thu, 25 Sep 2025 09:45:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758793542; 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=lhvlmbocLMImejtfkUQoIH3CBQ2wk54B4Lb6eRqTx5U=; b=HQxlqo2fJAP82LgD/oOvqHrCmnH/tQ8xmdFxkomnaYhmqLvsm+plq/0rr67IZQAoO8savc BMBC4O8EBO/KVeQQjvFItbRQR4aTmZguzsvIHxUr7oKCCn3yO4bviVOFkPleWowFUGfpQs NTkghu7NzDp443cNW6NrcZKIpIobKS4= X-MC-Unique: EoJm9mPwOkqu78JmdZ4qmg-1 X-Mimecast-MFC-AGG-ID: EoJm9mPwOkqu78JmdZ4qmg_1758793536 To: qemu-devel@nongnu.org Subject: [PATCH v4 08/23] log: avoid repeated prefix on incremental qemu_log calls Date: Thu, 25 Sep 2025 10:44:26 +0100 Message-ID: <20250925094441.1651372-9-berrange@redhat.com> In-Reply-To: <20250925094441.1651372-1-berrange@redhat.com> References: <20250925094441.1651372-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Message-ID-Hash: SJ6CZSYEMVBRBPPMA7Q7NBHTMWK3BFOI X-Message-ID-Hash: SJ6CZSYEMVBRBPPMA7Q7NBHTMWK3BFOI X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Hanna Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Kevin Wolf , qemu-rust@nongnu.org, Richard Henderson , Markus Armbruster , Christian Schoenebeck , qemu-block@nongnu.org, Stefan Weil , "Dr. David Alan Gilbert" , Manos Pitsidianakis , Gerd Hoffmann , devel@lists.libvirt.org, Paolo Bonzini X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9_via_Devel?= Reply-To: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1758794972880116601 Some code makes multiple qemu_log calls to incrementally emit a single message. Currently timestamps get prepended to all qemu_log calls, even those continuing a previous incomplete message. This changes the qemu_log so it skips adding a new line prefix, if the previous qemu_log call did NOT end with a newline. Fixes: 012842c07552 (log: make '-msg timestamp=3Don' apply to all qemu_log = usage) Reported-by: Richard Henderson Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 --- util/log.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util/log.c b/util/log.c index abdcb6b311..2642a55c59 100644 --- a/util/log.c +++ b/util/log.c @@ -143,6 +143,12 @@ void qemu_log_unlock(FILE *logfile) } } =20 +/* + * 'true' if the previous log message lacked a trailing '\n', + * and thus the subsequent call must skip any prefix + */ +static __thread bool incomplete; + void qemu_log(const char *fmt, ...) { FILE *f; @@ -154,7 +160,7 @@ void qemu_log(const char *fmt, ...) * was emitted if we are delayed acquiring the * mutex */ - if (message_with_timestamp) { + if (message_with_timestamp && !incomplete) { g_autoptr(GDateTime) dt =3D g_date_time_new_now_utc(); timestr =3D g_date_time_format_iso8601(dt); } @@ -170,6 +176,7 @@ void qemu_log(const char *fmt, ...) va_start(ap, fmt); vfprintf(f, fmt, ap); va_end(ap); + incomplete =3D fmt[strlen(fmt) - 1] !=3D '\n'; qemu_log_unlock(f); } } --=20 2.50.1