From nobody Wed May 8 21:01:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1546525188301711.2674712167295; Thu, 3 Jan 2019 06:19:48 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 2E4824D4DD; Thu, 3 Jan 2019 14:19:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2D785C223; Thu, 3 Jan 2019 14:19:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9F9533F605; Thu, 3 Jan 2019 14:19:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x03EJiuI004687 for ; Thu, 3 Jan 2019 09:19:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7791126DD6; Thu, 3 Jan 2019 14:19:44 +0000 (UTC) Received: from beluga.usersys.redhat.com (unknown [10.43.2.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB40B2657D; Thu, 3 Jan 2019 14:19:39 +0000 (UTC) From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 3 Jan 2019 15:19:30 +0100 Message-Id: <64f3e59420a7fb546e9cc976bdb8634a09544020.1546524970.git.eskultet@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [PATCH] util: Fix the default log output to 'journald' when running under systemd X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 03 Jan 2019 14:19:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Essentially, bring back the old behaviour as of commit eba36a38 which was later changed by commit ae06048bf5d. Even though all the stderr messages will eventually end up in the journal, we're not making use of the fields journald provides. https://bugzilla.redhat.com/show_bug.cgi?id=3D1592644 Signed-off-by: Erik Skultety --- src/util/virlog.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index cb6901d9bf..3ee58c5db6 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -223,11 +223,17 @@ virLogSetDefaultOutputToFile(const char *filename, bo= ol privileged) int virLogSetDefaultOutput(const char *filename, bool godaemon, bool privilege= d) { - if (!godaemon) + bool have_journald =3D access("/run/systemd/journal/socket", W_OK) >= =3D 0; + + if (godaemon) { + if (have_journald) + return virLogSetDefaultOutputToJournald(); + } else { + if (!isatty(STDIN_FILENO) && have_journald) + return virLogSetDefaultOutputToJournald(); + return virLogSetDefaultOutputToStderr(); - - if (access("/run/systemd/journal/socket", W_OK) >=3D 0) - return virLogSetDefaultOutputToJournald(); + } =20 return virLogSetDefaultOutputToFile(filename, privileged); } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list