From nobody Thu May 2 05:20:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1576754732; cv=none; d=zohomail.com; s=zohoarc; b=X1J8gRy2Q+JJXPzMCOrsH2NRBNc/1U8L0l5RPxQ7s2GRyL4d9CotTsLBcW/nmhiAaHskGYaLZRaT4OMVwUQPvim75pMlxNKASnfDNrHfyj6XQaY+adu3YzrEB1d1s4vOK5ZMrYKcrLzwIAPffyVofj9U99Pj5NqdJebRiybW+/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576754732; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fzAz9pOxiSrh3w+XBcv9JERDjU0p2Yb0Sv3Hoi+Iq7Q=; b=Ub2mrZjf6/MPHl3juvvA35HnyAw4ZxnVxbPGULlo5UXjNt2VLFvf9wUNicf2Cf/sOICxlPE/WiPPFLdZYuHS5J/R5KjiECkqju2yXEjwLFbzKZUz0r34VsGgpATOnlPuD1IBw6i9w1OfyWVpnbrAkUe78nHFv6CNWdLOdX6+1Sc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1576754732107135.77315936400407; Thu, 19 Dec 2019 03:25:32 -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-180-2442KEdCNz2ju_4_utX3xQ-1; Thu, 19 Dec 2019 06:25:20 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A00F3DB20; Thu, 19 Dec 2019 11:25:14 +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 47E43675B8; Thu, 19 Dec 2019 11:25:14 +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 83D6818089C8; Thu, 19 Dec 2019 11:25:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBJBPAXv014555 for ; Thu, 19 Dec 2019 06:25:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7CA7260BBA; Thu, 19 Dec 2019 11:25:10 +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 F1CAB63B83 for ; Thu, 19 Dec 2019 11:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576754730; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fzAz9pOxiSrh3w+XBcv9JERDjU0p2Yb0Sv3Hoi+Iq7Q=; b=gtLCGT4XKsmCrj1agKF7jy8C+qTom3kH+09mgGl1dAbeFegfjlGMasACCHvaUPxxFBIDC7 s10TmCLLoRK1nTQ14ZUztCH0X1y1q1+fsJ980AUnnhiLJjKfj556royg8D/qPUO6txKZGp vHy9Dqw2LDOiTsV1en/nVSsAX+uUgvE= From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Dec 2019 12:25:00 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/2] virhostuptime: Introduce virHostBootTimeInit() 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.79 on 10.5.11.15 X-MC-Unique: 2442KEdCNz2ju_4_utX3xQ-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" The idea is to offer callers an init function that they can call independently to ensure that the global variables get initialized. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson --- src/libvirt_private.syms | 1 + src/util/virhostuptime.c | 13 ++++++++++++- src/util/virhostuptime.h | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a7b1ef23bc..257ce00615 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2194,6 +2194,7 @@ virHostMemSetParameters; =20 =20 # util/virhostuptime.h +virHostBootTimeInit; virHostGetBootTime; =20 =20 diff --git a/src/util/virhostuptime.c b/src/util/virhostuptime.c index 8c49c3d40e..6c251c0d2d 100644 --- a/src/util/virhostuptime.c +++ b/src/util/virhostuptime.c @@ -126,7 +126,8 @@ virHostGetBootTimeOnceInit(void) int virHostGetBootTime(unsigned long long *when) { - if (virOnce(&virHostGetBootTimeOnce, virHostGetBootTimeOnceInit) < 0) + if (bootTime =3D=3D 0 && + virHostBootTimeInit() < 0) return -1; =20 if (bootTimeErrno) { @@ -137,3 +138,13 @@ virHostGetBootTime(unsigned long long *when) *when =3D bootTime; return 0; } + + +int +virHostBootTimeInit(void) +{ + if (virOnce(&virHostGetBootTimeOnce, virHostGetBootTimeOnceInit) < 0) + return -1; + + return 0; +} diff --git a/src/util/virhostuptime.h b/src/util/virhostuptime.h index 7e2c4c0c81..1ac638fd6e 100644 --- a/src/util/virhostuptime.h +++ b/src/util/virhostuptime.h @@ -25,3 +25,6 @@ int virHostGetBootTime(unsigned long long *when) G_GNUC_NO_INLINE; + +int +virHostBootTimeInit(void); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 05:20:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1576754725; cv=none; d=zohomail.com; s=zohoarc; b=S4Xg8eAZ0yuW6AqA3Hup+b/zcSd6tSy8toDu6NneQFlgayxDa0O0WQiUq8u7v3oP6UaRXRM6TBW+l5/W3Vy9rjpk4gjaqBF14y8CYK8R4FA0w3x/O8cEUsALbWBtr098NuE4MGvaH5Aw+cXDb8p0DHu6t7+Msg5SgjMrzavoROo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576754725; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sYMmqm4bPOcJMNsferHoVNbYsBhPCecsjAbCwYjan94=; b=jr6sl6JaTBk7cxCBNk3bmxT310rx1MbM48lbC8i+jbzQNsx2g22pCrQ8alcPPOn+7TArt/9sHR3EQCJlRy5TjTvOhjbhyl7q1ZoWkEHrmVG9tUWOgSeOliIlDvvx34sxB7pTM3Ia3jLcUyHhge2kf6DvF1hyTzrqg+OGhs+VjMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1576754725957403.61833915559066; Thu, 19 Dec 2019 03:25:25 -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-260-a2FSi_hKNdK2hM3QMRCdcw-1; Thu, 19 Dec 2019 06:25:20 -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 E8F821005513; Thu, 19 Dec 2019 11:25:14 +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 BD6CB7D938; Thu, 19 Dec 2019 11:25:14 +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 54DE6827E3; Thu, 19 Dec 2019 11:25:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBJBPBK9014563 for ; Thu, 19 Dec 2019 06:25:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 59177620BE; Thu, 19 Dec 2019 11:25:11 +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 CE05E60BBA for ; Thu, 19 Dec 2019 11:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576754724; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sYMmqm4bPOcJMNsferHoVNbYsBhPCecsjAbCwYjan94=; b=DjSl5U5r2SsargY/csuyLDwvieBQwuufgB8pM520hfQ42/qdOfnbB86Od7Afuc3pWc8pBO RAnhWIgAvwnYREKulIH2JG4S7aqpP+DsaYRuFBJG5Qnide7kXs6bF9lt3sTF7icIDgasjL APBDxf9ybTyaeSGU0+qlTKLMpjSGzBk= From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 19 Dec 2019 12:25:01 +0100 Message-Id: <514b604e29290409ac6e1bada5958ed685d4dab7.1576754597.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/2] remote_daemon: Initialize host boot time global variable 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.79 on 10.5.11.13 X-MC-Unique: a2FSi_hKNdK2hM3QMRCdcw-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 virHostBootTimeInit() function which sets the global variable. Signed-off-by: Michal Privoznik Reviewed-by: Cole Robinson --- src/remote/remote_daemon.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index b400b1dd10..27b538b292 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 @@ -1151,6 +1152,14 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } =20 + /* Let's try to initialize global variable that holds the host's boot = time. */ + if (virHostBootTimeInit() < 0) { + /* This is acceptable failure. Maybe we won't need the boot time + * anyway, and if we do, then virHostGetBootTime() returns an + * appropriate error. */ + VIR_DEBUG("Ignoring failed boot time init"); + } + 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