Re: [libvirt] [PATCH v4 20/42] remote: introduce virtproxyd daemon to handle IP connectivity

2019-08-08 Thread Andrea Bolognani
On Thu, 2019-08-08 at 16:10 +0100, Daniel P. Berrangé wrote:
> +++ b/src/remote/remote_daemon.c
> @@ -906,9 +912,9 @@ daemonUsage(const char *argv0, bool privileged)
>  { "-h | --help", N_("Display program help") },
>  { "-v | --verbose", N_("Verbose messages") },
>  { "-d | --daemon", N_("Run as a daemon & write PID file") },
> -#ifdef WITH_IP
> +#if defined(WITH_IP) && defined(LIBVIRTD)
>  { "-l | --listen", N_("Listen for TCP/IP connections") },
> -#endif /* !WITH_IP */
> +#endif /* !WITH_IP && !LIBVIRTD */

Nit: the comment should read

  /* ! (WITH_IP && LIBVIRTD) */

More instances of the same later.


With that fixed,

  Reviewed-by: Andrea Bolognani 

which I apparently forgot to give the last time around.

-- 
Andrea Bolognani / Red Hat / Virtualization

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

[libvirt] [PATCH v4 20/42] remote: introduce virtproxyd daemon to handle IP connectivity

2019-08-08 Thread Daniel P . Berrangé
The libvirtd daemon provides the traditional libvirt experience where
all the drivers are in a single daemon, and is accessible over both
local UNIX sockets and remote IP sockets.

In the new world we're having a set of per-driver daemons which will
primarily be accessed locally via their own UNIX sockets.

We still, however, need to allow for case of applications which will
connect to libvirt remotely. These remote connections can be done as
TCP/TLS sockets, or by SSH tunnelling to the UNIX socket.

In the later case, the old libvirt.so clients will only know about
the path to the old libvirtd socket /var/run/libvirt/libvirt-sock,
and not the new driver sockets /var/run/libvirt/virtqemud-sock.

It is also not desirable to expose the main driver specific daemons
over IP directly to minimize their attack service.

Thus the virtproxyd daemon steps into place, to provide TCP/TLS sockets,
and back compat for the old libvirtd UNIX socket path(s). It will then
forward all RPC calls made to the appropriate driver specific daemon.

Essentially it is equivalent to the old libvirtd with absolutely no
drivers registered except for the remote driver (and other stateless
drivers in libvirt.so).

We could have modified libvirtd so none of the drivers are registed
to get the same end result. We could even add a libvirtd.conf parameter
to control whether the drivers are loaded to enable users to switch back
to the old world if we discover bugs in the split-daemon model. Using a
new daemon though has some advantages

 - We can make virtproxyd and the virtXXXd per-driver daemons all
   have "Conflicts: libvirtd.service" in their systemd unit files.
   This will guarantee that libvirtd is never started at the same
   time, as this would result in two daemons running the same driver.
   Fortunately drivers use locking to protect themselves, but it is
   better to avoid starting a daemon we know will conflict.

 - It allows us to break CLI compat to remove the --listen parameter.
   Both listen_tcp and listen_tls parameters in /etc/libvirtd/virtd.conf
   will default to zero. Either TLS or TCP can be enabled exclusively
   though virtd.conf without requiring the extra step of adding --listen.

 - It allows us to set a strict SELinux policy over virtproxyd. For
   back compat the libvirtd policy must continue to allow all drivers
   to run. We can't easily give a second policy to libvirtd which
   locks it down. By introducing a new virtproxyd we can set a strict
   policy for that daemon only.

 - It gets rid of the weird naming of having a daemon with "lib" in
   its name. Now all normal daemons libvirt ships will have "virt"
   as their prefix not "libvirt".

 - Distros can more easily choose their upgrade path. They can
   ship both sets of daemons in their packages, and choose to
   either enable libvirtd, or enable the per-driver daemons and
   virtproxyd out of the box. Users can easily override this if
   desired by just tweaking which systemd units are active.

After some time we can deprecate use of libvirtd and after some more
time delete it entirely, leaving us in a pretty world filled with
prancing unicorns.

The main downside with introducing a new daemon, and with the
per-driver daemons in general, is figuring out the correct upgrade
path.

The conservative option is to leave libvirtd running if it was
an existing installation. Only use the new daemons & virtproxyd
on completely new installs.

The aggressive option is to disable libvirtd if already running
and activate all the new daemons.

Reviewed-by: Christophe de Dinechin 
Signed-off-by: Daniel P. Berrangé 
---
 .gitignore|   4 ++
 libvirt.spec.in   |  10 +++
 src/remote/Makefile.inc.am| 108 +++---
 src/remote/remote_daemon.c|  30 ++---
 src/remote/remote_daemon_config.c |   6 +-
 src/remote/virtproxyd.service.in  |  24 +++
 6 files changed, 162 insertions(+), 20 deletions(-)
 create mode 100644 src/remote/virtproxyd.service.in

diff --git a/.gitignore b/.gitignore
index 35dc2c8bec..9ad159ecfd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -161,6 +161,9 @@
 /src/remote/libvirtd.aug
 /src/remote/libvirtd.conf
 /src/remote/test_libvirtd.aug
+/src/remote/test_virtproxyd.aug
+/src/remote/virtproxyd.aug
+/src/remote/virtproxyd.conf
 /src/rpc/virkeepaliveprotocol.[ch]
 /src/rpc/virnetprotocol.[ch]
 /src/test*.aug
@@ -169,6 +172,7 @@
 /src/virt-aa-helper
 /src/virtlockd
 /src/virtlogd
+/src/virtproxyd
 /src/virt-guest-shutdown.target
 /tests/*.log
 /tests/*.pid
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 6f96fbec33..2acff40ea7 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1527,6 +1527,12 @@ exit 0
 %{_unitdir}/libvirtd-admin.socket
 %{_unitdir}/libvirtd-tcp.socket
 %{_unitdir}/libvirtd-tls.socket
+%{_unitdir}/virtproxyd.service
+%{_unitdir}/virtproxyd.socket
+%{_unitdir}/virtproxyd-ro.socket
+%{_unitdir}/virtproxyd-admin.socket
+%{_unitdir}/virtproxyd-tcp.socket
+%