From patchwork Tue Nov 8 14:00:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 13036332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6541C433FE for ; Tue, 8 Nov 2022 14:01:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osPAA-0006er-6x; Tue, 08 Nov 2022 09:01:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osP9v-0006YK-3U for qemu-devel@nongnu.org; Tue, 08 Nov 2022 09:01:01 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osP9s-0005Ja-9q for qemu-devel@nongnu.org; Tue, 08 Nov 2022 09:00:58 -0500 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-300-2y77KKN1MqailUdodescBg-1; Tue, 08 Nov 2022 09:00:41 -0500 X-MC-Unique: 2y77KKN1MqailUdodescBg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53B78383D0C6; Tue, 8 Nov 2022 14:00:41 +0000 (UTC) Received: from bahia.redhat.com (unknown [10.39.192.123]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D6A2C15E76; Tue, 8 Nov 2022 14:00:39 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson , Greg Kurz Subject: [PATCH v3 0/2] util/log: Always send errors to logfile when daemonized Date: Tue, 8 Nov 2022 15:00:30 +0100 Message-Id: <20221108140032.1460307-1-groug@kaod.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: softfail client-ip=205.139.111.44; envelope-from=groug@kaod.org; helo=us-smtp-delivery-44.mimecast.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org When QEMU is started with `--daemonize -D ${logfile} -d ${some_log_item}`, error logs from error_report() and friends go to ${logfile}, but if QEMU is started with `-daemonize -D ${logfile}` and no `-d`, the file isn't even created and all logs go to /dev/null. This inconsistency is quite confusing for users and gives the impression that QEMU doesn't log errors at all. It seems much saner to always create the log file when `-D` was passed and to be able to report errors. It was spotted by the kata-containers project, which happens to do just that `--daemonize -D` without `-d` trick. v3: - drop log_append (Paolo's patch) - new approach : call qemu_log_trylock() from qemu_set_log_internal() in the per-thread case, instead of trying to special case the main thread v2: - new log_thread_id() implementation for hosts without gettid() syscall - avoid conflict between global log file and per-thread logfile - style improvements Greg Kurz (1): util/log: Always send errors to logfile when daemonized Paolo Bonzini (1): util/log: do not close and reopen log files when flags are turned off util/log.c | 84 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 26 deletions(-)