From nobody Fri May 3 04:25:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576589184; cv=none; d=zohomail.com; s=zohoarc; b=iatjzzpRhhqlaybGyEJMqt6CUJJmMTHQDLyDtfa7KsVyZd2iiAKv/hAj7u1QqWyEF/JQstRDHPHBQM3AGsN33LOxO54nfft4VEuTNTblxlQMUJBYhqywm9REA0DNy9oz/qH4iLHxbLNXzG2CtGEPTddQi3K86KusfC6P2hxvqUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576589184; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=sD8wYP1fMa8FDXhT1HvfNJFxGluZXJ2H/XClFo39OIM=; b=oG9dmd/RB9LB9GM3lz+ysOFHH1wFiQuAbTkf4KPUnO7bbGK+WR0Ic0A+C/2vsZTXSAsYr3RqizJLxKkvr8lg4xNWuZLV+sWT69De5iMDrp+oMLylxBzAs28QK7IDlqZbdAvmdjMStsqWOAn/WpDJ/7fC8WTAIoIN6qp0dn94nVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1576589184679534.8351272075463; Tue, 17 Dec 2019 05:26:24 -0800 (PST) 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-59-Oz6HJZzVNmilrP9KNxHUqw-1; Tue, 17 Dec 2019 08:26:21 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53D6B800D48; Tue, 17 Dec 2019 13:26:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A06562657E; Tue, 17 Dec 2019 13:26:13 +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 8B92A1832DEE; Tue, 17 Dec 2019 13:26:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBHDQ4ts024107 for ; Tue, 17 Dec 2019 08:26:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id D6CFF60E1C; Tue, 17 Dec 2019 13:26:04 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-155.brq.redhat.com [10.40.204.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56C4B60C88 for ; Tue, 17 Dec 2019 13:26:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576589183; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sD8wYP1fMa8FDXhT1HvfNJFxGluZXJ2H/XClFo39OIM=; b=cMg5yeQZFnJMrm2DampIaDZMko7URNYXdLuDISMIF7LHdGW3UjeWryR7wqtol38dv1SpNH Y1toZb0wMmmVIe/KI/eEH7IFVlEaicuocY5w1KGS1QEtE/D7iOKVIpL7bPQH9218Aqk3FB O3jZ7HeOO1BE7K8Gae5XIKyNlGwS09o= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 17 Dec 2019 14:25:58 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] remote_daemon: Log host boot time 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: Oz6HJZzVNmilrP9KNxHUqw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is not strictly needed, but it makes sure we initialize the @bootTime global variable. Thing is, in order to validate XATTRs and prune those set in some previous runs of the host, a timestamp is recorded in XATTRs. The host boot time was unique enough so it was chosen as the timestamp value. And to avoid querying and parsing /proc/uptime every time, the query function does that only once and stores the boot time in a global variable. However, the only time the query function is called is in a child process that does lock files and changes seclabels. So effectively, we are doing exactly what we wanted to prevent from happening. The fix is simple, call the query function whilst the daemon is initializing. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson --- Since this will be used by security driver only, I was tempted to put this somewhere under src/security/, but especially because of split daemon I didn't. Placing this into remote_daemon.c makes sure all sub-daemons will have the variable initialized and won't suffer the problem. src/remote/remote_daemon.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index b400b1dd10..5debb6ce97 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -57,6 +57,7 @@ #include "virgettext.h" #include "util/virnetdevopenvswitch.h" #include "virsystemd.h" +#include "virhostuptime.h" =20 #include "driver.h" =20 @@ -1020,6 +1021,7 @@ int main(int argc, char **argv) { bool implicit_conf =3D false; char *run_dir =3D NULL; mode_t old_umask; + unsigned long long bootTime; =20 struct option opts[] =3D { { "verbose", no_argument, &verbose, 'v'}, @@ -1151,6 +1153,12 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } =20 + if (virHostGetBootTime(&bootTime) < 0) { + VIR_DEBUG("Unable to get host boot time"); + } else { + VIR_DEBUG("host boot time: %lld", bootTime); + } + daemonSetupNetDevOpenvswitch(config); =20 if (daemonSetupAccessManager(config) < 0) { --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list