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 <mprivozn(a)redhat.com>
---
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"
#include "driver.h"
@@ -1151,6 +1152,14 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
+ /* 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);
if (daemonSetupAccessManager(config) < 0) {
--
2.24.1