Re: [libvirt] [PATCH v3 08/48] remote: conditionalize daemon name in libvirtd daemon

2019-07-30 Thread Christophe de Dinechin
 P. Berrangé writes:

> Prepare for reusing libvirtd source to create other daemons by making
> the daemon name conditionally defined by the make rules.
>
> Reviewed-by: Andrea Bolognani 
> Signed-off-by: Daniel P. Berrangé 
> ---
>  src/remote/Makefile.inc.am|  1 +
>  src/remote/remote_daemon.c| 50 +--
>  src/remote/remote_daemon_config.c |  5 ++--
>  3 files changed, 31 insertions(+), 25 deletions(-)
>
> diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
> index ced940d3c1..b72186109a 100644
> --- a/src/remote/Makefile.inc.am
> +++ b/src/remote/Makefile.inc.am
> @@ -147,6 +147,7 @@ libvirtd_CFLAGS = \
>   -I$(srcdir)/conf \
>   -I$(srcdir)/rpc \
>   -DSOCK_PREFIX="\"libvirt\"" \
> + -DDAEMON_NAME="\"libvirtd\"" \
>   $(NULL)
>
>  libvirtd_LDFLAGS = \
> diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
> index f9d923b357..f1daaeb944 100644
> --- a/src/remote/remote_daemon.c
> +++ b/src/remote/remote_daemon.c
> @@ -64,7 +64,11 @@
>
>  #include "virdbus.h"
>
> -VIR_LOG_INIT("daemon.libvirtd");
> +VIR_LOG_INIT("daemon." DAEMON_NAME);
> +
> +#ifndef SOCK_PREFIX
> +# define SOCK_PREFIX DAEMON_NAME
> +#endif
>
>  #if WITH_SASL
>  virNetSASLContextPtr saslCtxt = NULL;
> @@ -383,11 +387,11 @@ daemonSetupNetworking(virNetServerPtr srv,
>  int ret = -1;
>  VIR_AUTOPTR(virSystemdActivation) act = NULL;
>  virSystemdActivationMap actmap[] = {
> -{ .name = "libvirtd.socket", .family = AF_UNIX, .path = sock_path },
> -{ .name = "libvirtd-ro.socket", .family = AF_UNIX, .path = 
> sock_path_ro },
> -{ .name = "libvirtd-admin.socket", .family = AF_UNIX, .path = 
> sock_path_adm },
> -{ .name = "libvirtd-tcp.socket", .family = AF_INET },
> -{ .name = "libvirtd-tls.socket", .family = AF_INET },
> +{ .name = DAEMON_NAME ".socket", .family = AF_UNIX, .path = 
> sock_path },
> +{ .name = DAEMON_NAME "-ro.socket", .family = AF_UNIX, .path = 
> sock_path_ro },
> +{ .name = DAEMON_NAME "-admin.socket", .family = AF_UNIX, .path = 
> sock_path_adm },
> +{ .name = DAEMON_NAME "-tcp.socket", .family = AF_INET },
> +{ .name = DAEMON_NAME "-tls.socket", .family = AF_INET },
>  };
>
>  if ((actmap[3].port = virSocketAddrResolveService(config->tcp_port)) < 0)
> @@ -421,7 +425,7 @@ daemonSetupNetworking(virNetServerPtr srv,
>
>  if (virNetServerAddServiceUNIX(srv,
> act,
> -   "libvirtd.socket",
> +   DAEMON_NAME ".socket",
> sock_path,
> unix_sock_rw_mask,
> unix_sock_gid,
> @@ -434,7 +438,7 @@ daemonSetupNetworking(virNetServerPtr srv,
>  if (sock_path_ro &&
>  virNetServerAddServiceUNIX(srv,
> act,
> -   "libvirtd-ro.socket",
> +   DAEMON_NAME "-ro.socket",
> sock_path_ro,
> unix_sock_ro_mask,
> unix_sock_gid,
> @@ -448,7 +452,7 @@ daemonSetupNetworking(virNetServerPtr srv,
>  if (sock_path_adm &&
>  virNetServerAddServiceUNIX(srvAdm,
> act,
> -   "libvirtd-admin.socket",
> +   DAEMON_NAME "-admin.socket",
> sock_path_adm,
> unix_sock_adm_mask,
> unix_sock_gid,
> @@ -462,7 +466,7 @@ daemonSetupNetworking(virNetServerPtr srv,
>  if (((ipsock && config->listen_tcp) || act) &&
>  virNetServerAddServiceTCP(srv,
>act,
> -  "libvirtd-tcp.socket",
> +  DAEMON_NAME "-tcp.socket",
>config->listen_addr,
>config->tcp_port,
>AF_UNSPEC,
> @@ -519,7 +523,7 @@ daemonSetupNetworking(virNetServerPtr srv,
>config->listen_addr, config->tls_port);
>  if (virNetServerAddServiceTCP(srv,
>act,
> -  "libvirtd-tls.socket",
> +  DAEMON_NAME "-tls.socket",
>config->listen_addr,
>config->tls_port,
>AF_UNSPEC,
> @@ -564,7 +568,7 @@ daemonSetupNetDevOpenvswitch(struct daemonConfig *config)
>
>  /*
>   * Set up the logging environment
> - * By default if daemonized all errors go to the logfile libvirtd.log,
> + * By default if daemonized all errors go to jour

[libvirt] [PATCH v3 08/48] remote: conditionalize daemon name in libvirtd daemon

2019-07-29 Thread Daniel P . Berrangé
Prepare for reusing libvirtd source to create other daemons by making
the daemon name conditionally defined by the make rules.

Reviewed-by: Andrea Bolognani 
Signed-off-by: Daniel P. Berrangé 
---
 src/remote/Makefile.inc.am|  1 +
 src/remote/remote_daemon.c| 50 +--
 src/remote/remote_daemon_config.c |  5 ++--
 3 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index ced940d3c1..b72186109a 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -147,6 +147,7 @@ libvirtd_CFLAGS = \
-I$(srcdir)/conf \
-I$(srcdir)/rpc \
-DSOCK_PREFIX="\"libvirt\"" \
+   -DDAEMON_NAME="\"libvirtd\"" \
$(NULL)
 
 libvirtd_LDFLAGS = \
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index f9d923b357..f1daaeb944 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -64,7 +64,11 @@
 
 #include "virdbus.h"
 
-VIR_LOG_INIT("daemon.libvirtd");
+VIR_LOG_INIT("daemon." DAEMON_NAME);
+
+#ifndef SOCK_PREFIX
+# define SOCK_PREFIX DAEMON_NAME
+#endif
 
 #if WITH_SASL
 virNetSASLContextPtr saslCtxt = NULL;
@@ -383,11 +387,11 @@ daemonSetupNetworking(virNetServerPtr srv,
 int ret = -1;
 VIR_AUTOPTR(virSystemdActivation) act = NULL;
 virSystemdActivationMap actmap[] = {
-{ .name = "libvirtd.socket", .family = AF_UNIX, .path = sock_path },
-{ .name = "libvirtd-ro.socket", .family = AF_UNIX, .path = 
sock_path_ro },
-{ .name = "libvirtd-admin.socket", .family = AF_UNIX, .path = 
sock_path_adm },
-{ .name = "libvirtd-tcp.socket", .family = AF_INET },
-{ .name = "libvirtd-tls.socket", .family = AF_INET },
+{ .name = DAEMON_NAME ".socket", .family = AF_UNIX, .path = sock_path 
},
+{ .name = DAEMON_NAME "-ro.socket", .family = AF_UNIX, .path = 
sock_path_ro },
+{ .name = DAEMON_NAME "-admin.socket", .family = AF_UNIX, .path = 
sock_path_adm },
+{ .name = DAEMON_NAME "-tcp.socket", .family = AF_INET },
+{ .name = DAEMON_NAME "-tls.socket", .family = AF_INET },
 };
 
 if ((actmap[3].port = virSocketAddrResolveService(config->tcp_port)) < 0)
@@ -421,7 +425,7 @@ daemonSetupNetworking(virNetServerPtr srv,
 
 if (virNetServerAddServiceUNIX(srv,
act,
-   "libvirtd.socket",
+   DAEMON_NAME ".socket",
sock_path,
unix_sock_rw_mask,
unix_sock_gid,
@@ -434,7 +438,7 @@ daemonSetupNetworking(virNetServerPtr srv,
 if (sock_path_ro &&
 virNetServerAddServiceUNIX(srv,
act,
-   "libvirtd-ro.socket",
+   DAEMON_NAME "-ro.socket",
sock_path_ro,
unix_sock_ro_mask,
unix_sock_gid,
@@ -448,7 +452,7 @@ daemonSetupNetworking(virNetServerPtr srv,
 if (sock_path_adm &&
 virNetServerAddServiceUNIX(srvAdm,
act,
-   "libvirtd-admin.socket",
+   DAEMON_NAME "-admin.socket",
sock_path_adm,
unix_sock_adm_mask,
unix_sock_gid,
@@ -462,7 +466,7 @@ daemonSetupNetworking(virNetServerPtr srv,
 if (((ipsock && config->listen_tcp) || act) &&
 virNetServerAddServiceTCP(srv,
   act,
-  "libvirtd-tcp.socket",
+  DAEMON_NAME "-tcp.socket",
   config->listen_addr,
   config->tcp_port,
   AF_UNSPEC,
@@ -519,7 +523,7 @@ daemonSetupNetworking(virNetServerPtr srv,
   config->listen_addr, config->tls_port);
 if (virNetServerAddServiceTCP(srv,
   act,
-  "libvirtd-tls.socket",
+  DAEMON_NAME "-tls.socket",
   config->listen_addr,
   config->tls_port,
   AF_UNSPEC,
@@ -564,7 +568,7 @@ daemonSetupNetDevOpenvswitch(struct daemonConfig *config)
 
 /*
  * Set up the logging environment
- * By default if daemonized all errors go to the logfile libvirtd.log,
+ * By default if daemonized all errors go to journald/a logfile
  * but if verbose or error debugging is asked for then also output
  * informational and debug messages. Default size if 64 kB.
  */
@@ -577,7 +581,7 @@ daemonSetupLogging(struct daemonConfig *config,