From nobody Mon Feb 9 03:30:48 2026 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 --- 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