From 9d69bc19b94544b06838b2e2895826991d107178 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 19 Dec 2019 10:11:04 +0100 Subject: [PATCH] virhostuptime: Introduce virHostBootTimeInit() 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 | 12 +++++++++++- src/util/virhostuptime.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1f4d281849..b97906b852 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2199,6 +2199,7 @@ virHostMemSetParameters; # util/virhostuptime.h +virHostBootTimeInit; virHostGetBootTime; diff --git a/src/util/virhostuptime.c b/src/util/virhostuptime.c index 8c49c3d40e..661ed588cd 100644 --- a/src/util/virhostuptime.c +++ b/src/util/virhostuptime.c @@ -126,7 +126,7 @@ virHostGetBootTimeOnceInit(void) int virHostGetBootTime(unsigned long long *when) { - if (virOnce(&virHostGetBootTimeOnce, virHostGetBootTimeOnceInit) < 0) + if (virHostBootTimeInit() < 0) return -1; if (bootTimeErrno) { @@ -137,3 +137,13 @@ virHostGetBootTime(unsigned long long *when) *when = 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);