]> xenbits.xensource.com Git - libvirt.git/commitdiff
src: Detect close_range syscall during virGlobalInit()
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 22 Aug 2023 07:45:47 +0000 (09:45 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 24 Aug 2023 10:45:17 +0000 (12:45 +0200)
The whole purpose of virCloseRangeInit() is to be called
somewhere during initialization (ideally before first virExec()
or virCommandRun()), so that the rest of the code already knows
kernel capabilities. While I can put the call somewhere into
remote_daemon.c (when a daemon initializes), we might call
virCommand*() even from client library (i.e. no daemon).

Therefore, put it into virGlobalInit() with the rest of
initialization code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
src/libvirt.c

index 69d5b13bff6bf62be6ce59ce9da57855438b2599..26c3fe454fd68f77e8b9b5fc5d0761cfc59d3f22 100644 (file)
@@ -231,6 +231,10 @@ virGlobalInit(void)
         goto error;
     }
 
+    /* Do this upfront rather than every time a child is spawned. */
+    if (virCloseRangeInit() < 0)
+        goto error;
+
     if (virLogSetFromEnv() < 0)
         goto error;