[PATCH 07/41] remote: conditionalize socket names in libvirtd daemon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Prepare for reusing libvirtd source to create other daemons by making
the socket names conditionally defined by the make rules.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/remote/Makefile.inc.am |  1 +
 src/remote/remote_daemon.c | 24 ++++++++++++------------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 0400dabad9..ced940d3c1 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -146,6 +146,7 @@ libvirtd_CFLAGS = \
 	-I$(srcdir)/access \
 	-I$(srcdir)/conf \
 	-I$(srcdir)/rpc \
+	-DSOCK_PREFIX="\"libvirt\"" \
 	$(NULL)
 
 libvirtd_LDFLAGS = \
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index 49ac3f0ae5..056ae2ba91 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -221,19 +221,19 @@ daemonUnixSocketPaths(struct daemonConfig *config,
     char *rundir = NULL;
 
     if (config->unix_sock_dir) {
-        if (virAsprintf(sockfile, "%s/libvirt-sock", config->unix_sock_dir) < 0)
+        if (virAsprintf(sockfile, "%s/" SOCK_PREFIX "-sock", config->unix_sock_dir) < 0)
             goto cleanup;
 
         if (privileged) {
-            if (virAsprintf(rosockfile, "%s/libvirt-sock-ro", config->unix_sock_dir) < 0 ||
-                virAsprintf(admsockfile, "%s/libvirt-admin-sock", config->unix_sock_dir) < 0)
+            if (virAsprintf(rosockfile, "%s/" SOCK_PREFIX "-sock-ro", config->unix_sock_dir) < 0 ||
+                virAsprintf(admsockfile, "%s/" SOCK_PREFIX "-admin-sock", config->unix_sock_dir) < 0)
                 goto cleanup;
         }
     } else {
         if (privileged) {
-            if (VIR_STRDUP(*sockfile, LOCALSTATEDIR "/run/libvirt/libvirt-sock") < 0 ||
-                VIR_STRDUP(*rosockfile, LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro") < 0 ||
-                VIR_STRDUP(*admsockfile, LOCALSTATEDIR "/run/libvirt/libvirt-admin-sock") < 0)
+            if (VIR_STRDUP(*sockfile, LOCALSTATEDIR "/run/libvirt/" SOCK_PREFIX "-sock") < 0 ||
+                VIR_STRDUP(*rosockfile, LOCALSTATEDIR "/run/libvirt/" SOCK_PREFIX "-sock-ro") < 0 ||
+                VIR_STRDUP(*admsockfile, LOCALSTATEDIR "/run/libvirt/" SOCK_PREFIX "-admin-sock") < 0)
                 goto cleanup;
         } else {
             mode_t old_umask;
@@ -248,8 +248,8 @@ daemonUnixSocketPaths(struct daemonConfig *config,
             }
             umask(old_umask);
 
-            if (virAsprintf(sockfile, "%s/libvirt-sock", rundir) < 0 ||
-                virAsprintf(admsockfile, "%s/libvirt-admin-sock", rundir) < 0)
+            if (virAsprintf(sockfile, "%s/" SOCK_PREFIX "-sock", rundir) < 0 ||
+                virAsprintf(admsockfile, "%s/" SOCK_PREFIX "-admin-sock", rundir) < 0)
                 goto cleanup;
         }
     }
@@ -900,12 +900,12 @@ daemonUsage(const char *argv0, bool privileged)
     fprintf(stderr, "\n");
 
     fprintf(stderr, "    %s:\n", _("Sockets"));
-    fprintf(stderr, "      %s\n",
-            privileged ? LOCALSTATEDIR "/run/libvirt/libvirt-sock" :
-            "$XDG_RUNTIME_DIR/libvirt/libvirt-sock");
+    fprintf(stderr, "      %s/libvirt/" SOCK_PREFIX "-sock\n",
+            privileged ? LOCALSTATEDIR "/run" :
+            "$XDG_RUNTIME_DIR");
     if (privileged)
         fprintf(stderr, "      %s\n",
-                LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro");
+                LOCALSTATEDIR "/run/libvirt/" SOCK_PREFIX "-sock-ro");
     fprintf(stderr, "\n");
 
     fprintf(stderr, "    %s:\n", _("TLS"));
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux