[libvirt] [PATCH v2 00/19] Enable proper use of systemd socket activation with libvirtd

Daniel P. Berrangé posted 19 patches 13 weeks ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190711140742.31029-1-berrange@redhat.com
libvirt.spec.in                               |  24 +-
src/libvirt_private.syms                      |   8 +-
src/libvirt_remote.syms                       |   6 +-
src/locking/lock_daemon.c                     | 121 ++---
src/logging/log_daemon.c                      | 121 ++---
src/remote/Makefile.inc.am                    |  35 ++
src/remote/libvirtd-admin.socket.in           |  15 +
src/remote/libvirtd-ro.socket.in              |  15 +
src/remote/libvirtd-tcp.socket.in             |  14 +
src/remote/libvirtd-tls.socket.in             |  14 +
src/remote/libvirtd.conf                      |  31 ++
src/remote/libvirtd.service.in                |  16 +-
src/remote/libvirtd.socket.in                 |  13 +
src/remote/libvirtd.sysconf                   |   3 +-
src/remote/remote_daemon.c                    | 255 +++++-----
src/rpc/virnetdaemon.h                        |   2 -
src/rpc/virnetserver.c                        | 162 +++++++
src/rpc/virnetserver.h                        |  26 ++
src/rpc/virnetserverservice.c                 | 238 ++++------
src/rpc/virnetserverservice.h                 |  24 +-
src/rpc/virnetsocket.c                        |  83 +++-
src/rpc/virnetsocket.h                        |   1 +
src/util/vircommand.c                         |  99 ----
src/util/vircommand.h                         |   2 -
src/util/virsystemd.c                         | 434 ++++++++++++++++++
src/util/virsystemd.h                         |  32 ++
src/util/virutil.c                            | 116 -----
src/util/virutil.h                            |   3 -
tests/commanddata/test24.log                  |   8 -
tests/commandtest.c                           |  58 ---
.../input-data-anon-clients.json              |  12 +-
.../output-data-admin-server-names.json       |  24 +-
tests/virnetdaemondata/output-data-admin.json |  24 +-
.../output-data-anon-clients.json             |  12 +-
.../output-data-client-auth-pending.json      |  12 +-
.../output-data-client-ids.json               |  12 +-
.../output-data-client-timestamp.json         |  12 +-
.../virnetdaemondata/output-data-initial.json |  12 +-
.../output-data-no-keepalive-required.json    |  24 +-
tests/virsystemdtest.c                        | 169 +++++++
40 files changed, 1464 insertions(+), 828 deletions(-)
create mode 100644 src/remote/libvirtd-admin.socket.in
create mode 100644 src/remote/libvirtd-ro.socket.in
create mode 100644 src/remote/libvirtd-tcp.socket.in
create mode 100644 src/remote/libvirtd-tls.socket.in
create mode 100644 src/remote/libvirtd.socket.in
delete mode 100644 tests/commanddata/test24.log

[libvirt] [PATCH v2 00/19] Enable proper use of systemd socket activation with libvirtd

Posted by Daniel P. Berrangé 13 weeks ago
The libvirtd daemon has some support for systemd socket activation
from:

  commit 27a7081c2968ca0d7fbd590629b5a5303851f4a3
  Author: Martin Kletzander <mkletzan@redhat.com>
  Date:   Tue Jul 15 15:28:53 2014 +0200

    daemon: support passing FDs from the calling process

    First FD is the RW unix socket to listen on, second one (if
    applicable) is the RO unix socket.

This was originally intended for use by the libvirt client when doing
auto-spawning of libvirtd, but we later deleted that client side code
in

  commit be78814ae07f092d9c4e71fd82dd1947aba2f029
  Author: Michal Privoznik <mprivozn@redhat.com>
  Date:   Thu Apr 2 14:41:17 2015 +0200

    virNetSocketNewConnectUNIX: Use flocks when spawning a daemon

We never added systemd socket units before as we need libvirtd to start
on boot to perform autostart.

It was recently pointed out by Lennart that these two features are not
mutually exclusive though. Libvirtd can be set to start on boot, and
also have socket unit files.

The idea is that we start libvirtd on boot, perform autostart, and then
libvirtd can exit if nothing is running. The socket unit files are then
there to start it again when a mgmt app connects.

This series implements that strategy. In doing so the current socket
activation support was rewritten to be more flexible, able to cope with
the admin socket and the TCP/TLS sockets, all passed in any order.

NB, I don't believe I have got the RPM upgrade procedure right yet. As
there are alot of scenario to test for upgrades, I need more validation
of that. The series is long enough now though, that it would benefit
from code review already

This socket activation is also going to be important when we split out
the daemons, as we will use the same libvirtd codebase for these new
daemons, simply compiled with different options.

Changed in v2:

 - Merge 4 patches already ACKd by Jan
 - Drop VIR_AUTOSTRUCT patch
 - Fix patch ordering to be bisectable with "make check"

Daniel P. Berrangé (19):
  rpc: ensure all sockets bind to same port when service is NULL
  util: add APIs for facilitating use of systemd activation FDs
  rpc: refactor RPC service constructors to share more code
  rpc: allow creating RPC service from an array of FDs
  rpc: avoid unlinking sockets passed in from systemd
  rpc: add helper APIs for adding services with systemd activation
  rpc: add API for checking whether an auth scheme is in use on a server
  remote: simplify libvirtd code for deciding if SASL auth is needed
  remote: fix handling of systemd activation wrt socket ordering
  rpc: remove unused API for creating services from FDs
  remote: add systemd socket units for UNIX/TCP sockets
  remote: make system libvirtd exit when idle via timeout
  remote: update config files to note usage wrt systemd socket
    activation
  util: remove code spawning with systemd activation env vars
  locking: convert lock daemon to use systemd activation APIs
  logging: convert log daemon to use systemd activation APIs
  util: move code for getting listen FDs into systemd module
  util: remove unused helper for getting UNIX socket path
  rpc: remove unused typedef for auto shutdown function callback

 libvirt.spec.in                               |  24 +-
 src/libvirt_private.syms                      |   8 +-
 src/libvirt_remote.syms                       |   6 +-
 src/locking/lock_daemon.c                     | 121 ++---
 src/logging/log_daemon.c                      | 121 ++---
 src/remote/Makefile.inc.am                    |  35 ++
 src/remote/libvirtd-admin.socket.in           |  15 +
 src/remote/libvirtd-ro.socket.in              |  15 +
 src/remote/libvirtd-tcp.socket.in             |  14 +
 src/remote/libvirtd-tls.socket.in             |  14 +
 src/remote/libvirtd.conf                      |  31 ++
 src/remote/libvirtd.service.in                |  16 +-
 src/remote/libvirtd.socket.in                 |  13 +
 src/remote/libvirtd.sysconf                   |   3 +-
 src/remote/remote_daemon.c                    | 255 +++++-----
 src/rpc/virnetdaemon.h                        |   2 -
 src/rpc/virnetserver.c                        | 162 +++++++
 src/rpc/virnetserver.h                        |  26 ++
 src/rpc/virnetserverservice.c                 | 238 ++++------
 src/rpc/virnetserverservice.h                 |  24 +-
 src/rpc/virnetsocket.c                        |  83 +++-
 src/rpc/virnetsocket.h                        |   1 +
 src/util/vircommand.c                         |  99 ----
 src/util/vircommand.h                         |   2 -
 src/util/virsystemd.c                         | 434 ++++++++++++++++++
 src/util/virsystemd.h                         |  32 ++
 src/util/virutil.c                            | 116 -----
 src/util/virutil.h                            |   3 -
 tests/commanddata/test24.log                  |   8 -
 tests/commandtest.c                           |  58 ---
 .../input-data-anon-clients.json              |  12 +-
 .../output-data-admin-server-names.json       |  24 +-
 tests/virnetdaemondata/output-data-admin.json |  24 +-
 .../output-data-anon-clients.json             |  12 +-
 .../output-data-client-auth-pending.json      |  12 +-
 .../output-data-client-ids.json               |  12 +-
 .../output-data-client-timestamp.json         |  12 +-
 .../virnetdaemondata/output-data-initial.json |  12 +-
 .../output-data-no-keepalive-required.json    |  24 +-
 tests/virsystemdtest.c                        | 169 +++++++
 40 files changed, 1464 insertions(+), 828 deletions(-)
 create mode 100644 src/remote/libvirtd-admin.socket.in
 create mode 100644 src/remote/libvirtd-ro.socket.in
 create mode 100644 src/remote/libvirtd-tcp.socket.in
 create mode 100644 src/remote/libvirtd-tls.socket.in
 create mode 100644 src/remote/libvirtd.socket.in
 delete mode 100644 tests/commanddata/test24.log

-- 
2.21.0

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

Re: [libvirt] [PATCH v2 00/19] Enable proper use of systemd socket activation with libvirtd

Posted by Michal Privoznik 13 weeks ago
On 7/11/19 4:07 PM, Daniel P. Berrangé wrote:
> The libvirtd daemon has some support for systemd socket activation
> from:
> 
>    commit 27a7081c2968ca0d7fbd590629b5a5303851f4a3
>    Author: Martin Kletzander <mkletzan@redhat.com>
>    Date:   Tue Jul 15 15:28:53 2014 +0200
> 
>      daemon: support passing FDs from the calling process
> 
>      First FD is the RW unix socket to listen on, second one (if
>      applicable) is the RO unix socket.
> 
> This was originally intended for use by the libvirt client when doing
> auto-spawning of libvirtd, but we later deleted that client side code
> in
> 
>    commit be78814ae07f092d9c4e71fd82dd1947aba2f029
>    Author: Michal Privoznik <mprivozn@redhat.com>
>    Date:   Thu Apr 2 14:41:17 2015 +0200
> 
>      virNetSocketNewConnectUNIX: Use flocks when spawning a daemon
> 
> We never added systemd socket units before as we need libvirtd to start
> on boot to perform autostart.
> 
> It was recently pointed out by Lennart that these two features are not
> mutually exclusive though. Libvirtd can be set to start on boot, and
> also have socket unit files.
> 
> The idea is that we start libvirtd on boot, perform autostart, and then
> libvirtd can exit if nothing is running. The socket unit files are then
> there to start it again when a mgmt app connects.
> 
> This series implements that strategy. In doing so the current socket
> activation support was rewritten to be more flexible, able to cope with
> the admin socket and the TCP/TLS sockets, all passed in any order.
> 
> NB, I don't believe I have got the RPM upgrade procedure right yet. As
> there are alot of scenario to test for upgrades, I need more validation
> of that. The series is long enough now though, that it would benefit
> from code review already
> 
> This socket activation is also going to be important when we split out
> the daemons, as we will use the same libvirtd codebase for these new
> daemons, simply compiled with different options.
> 
> Changed in v2:
> 
>   - Merge 4 patches already ACKd by Jan
>   - Drop VIR_AUTOSTRUCT patch
>   - Fix patch ordering to be bisectable with "make check"
> 
> Daniel P. Berrangé (19):
>    rpc: ensure all sockets bind to same port when service is NULL
>    util: add APIs for facilitating use of systemd activation FDs
>    rpc: refactor RPC service constructors to share more code
>    rpc: allow creating RPC service from an array of FDs
>    rpc: avoid unlinking sockets passed in from systemd
>    rpc: add helper APIs for adding services with systemd activation
>    rpc: add API for checking whether an auth scheme is in use on a server
>    remote: simplify libvirtd code for deciding if SASL auth is needed
>    remote: fix handling of systemd activation wrt socket ordering
>    rpc: remove unused API for creating services from FDs
>    remote: add systemd socket units for UNIX/TCP sockets
>    remote: make system libvirtd exit when idle via timeout
>    remote: update config files to note usage wrt systemd socket
>      activation
>    util: remove code spawning with systemd activation env vars
>    locking: convert lock daemon to use systemd activation APIs
>    logging: convert log daemon to use systemd activation APIs
>    util: move code for getting listen FDs into systemd module
>    util: remove unused helper for getting UNIX socket path
>    rpc: remove unused typedef for auto shutdown function callback
> 
>   libvirt.spec.in                               |  24 +-
>   src/libvirt_private.syms                      |   8 +-
>   src/libvirt_remote.syms                       |   6 +-
>   src/locking/lock_daemon.c                     | 121 ++---
>   src/logging/log_daemon.c                      | 121 ++---
>   src/remote/Makefile.inc.am                    |  35 ++
>   src/remote/libvirtd-admin.socket.in           |  15 +
>   src/remote/libvirtd-ro.socket.in              |  15 +
>   src/remote/libvirtd-tcp.socket.in             |  14 +
>   src/remote/libvirtd-tls.socket.in             |  14 +
>   src/remote/libvirtd.conf                      |  31 ++
>   src/remote/libvirtd.service.in                |  16 +-
>   src/remote/libvirtd.socket.in                 |  13 +
>   src/remote/libvirtd.sysconf                   |   3 +-
>   src/remote/remote_daemon.c                    | 255 +++++-----
>   src/rpc/virnetdaemon.h                        |   2 -
>   src/rpc/virnetserver.c                        | 162 +++++++
>   src/rpc/virnetserver.h                        |  26 ++
>   src/rpc/virnetserverservice.c                 | 238 ++++------
>   src/rpc/virnetserverservice.h                 |  24 +-
>   src/rpc/virnetsocket.c                        |  83 +++-
>   src/rpc/virnetsocket.h                        |   1 +
>   src/util/vircommand.c                         |  99 ----
>   src/util/vircommand.h                         |   2 -
>   src/util/virsystemd.c                         | 434 ++++++++++++++++++
>   src/util/virsystemd.h                         |  32 ++
>   src/util/virutil.c                            | 116 -----
>   src/util/virutil.h                            |   3 -
>   tests/commanddata/test24.log                  |   8 -
>   tests/commandtest.c                           |  58 ---
>   .../input-data-anon-clients.json              |  12 +-
>   .../output-data-admin-server-names.json       |  24 +-
>   tests/virnetdaemondata/output-data-admin.json |  24 +-
>   .../output-data-anon-clients.json             |  12 +-
>   .../output-data-client-auth-pending.json      |  12 +-
>   .../output-data-client-ids.json               |  12 +-
>   .../output-data-client-timestamp.json         |  12 +-
>   .../virnetdaemondata/output-data-initial.json |  12 +-
>   .../output-data-no-keepalive-required.json    |  24 +-
>   tests/virsystemdtest.c                        | 169 +++++++
>   40 files changed, 1464 insertions(+), 828 deletions(-)
>   create mode 100644 src/remote/libvirtd-admin.socket.in
>   create mode 100644 src/remote/libvirtd-ro.socket.in
>   create mode 100644 src/remote/libvirtd-tcp.socket.in
>   create mode 100644 src/remote/libvirtd-tls.socket.in
>   create mode 100644 src/remote/libvirtd.socket.in
>   delete mode 100644 tests/commanddata/test24.log
> 

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal

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