Re: [PATCH 01/26] util: add APIs for more systemd notifications

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

 



On Wed, Jan 08, 2025 at 19:42:34 +0000, Daniel P. Berrangé wrote:
> We have a way to notify systemd when we're done starting the daemon.
> 
> Systemd supports many more notifications, however, and many of them
> are quite relevant to our needs:
> 
>   https://www.freedesktop.org/software/systemd/man/latest/sd_notify.html
> 
> This renames the existing notification API to better reflect its
> semantics, and adds new APIs for reporting
> 
>  * Initiation of config file reload
>  * Initiation of daemon shutdown process
>  * Adhoc progress status messages
>  * Request to extend service shutdown timeout
> 
> Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
> ---
>  src/libvirt_private.syms |  6 +++++-
>  src/rpc/virnetdaemon.c   |  2 +-
>  src/util/virsystemd.c    | 41 +++++++++++++++++++++++++++++++++++++---
>  src/util/virsystemd.h    |  6 +++++-
>  4 files changed, 49 insertions(+), 6 deletions(-)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 33b93cbd3e..d0c116b78c 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -3524,7 +3524,11 @@ virSystemdHasResolved;
>  virSystemdHasResolvedResetCachedValue;
>  virSystemdMakeScopeName;
>  virSystemdMakeSliceName;
> -virSystemdNotifyStartup;
> +virSystemdNotifyExtendTimeout;
> +virSystemdNotifyReady;
> +virSystemdNotifyReload;
> +virSystemdNotifyStatus;
> +virSystemdNotifyStopping;
>  virSystemdResolvedRegisterNameServer;
>  virSystemdTerminateMachine;
>  
> diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
> index e4c6261536..bb7d2ff9a0 100644
> --- a/src/rpc/virnetdaemon.c
> +++ b/src/rpc/virnetdaemon.c
> @@ -749,7 +749,7 @@ virNetDaemonRun(virNetDaemon *dmn)
>  
>      /* We are accepting connections now. Notify systemd
>       * so it can start dependent services. */
> -    virSystemdNotifyStartup();
> +    virSystemdNotifyReady();
>  
>      VIR_DEBUG("dmn=%p quit=%d", dmn, dmn->quit);
>      while (!dmn->finished) {
> diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
> index 5b772e29dd..2c09b9ab2b 100644
> --- a/src/util/virsystemd.c
> +++ b/src/util/virsystemd.c
> @@ -624,12 +624,11 @@ int virSystemdTerminateMachine(const char *name)
>      return 0;
>  }
>  
> -void
> -virSystemdNotifyStartup(void)
> +static void
> +virSystemdNotify(const char *msg)
>  {
>  #ifndef WIN32
>      const char *path;
> -    const char *msg = "READY=1";
>      int fd;
>      struct sockaddr_un un = {
>          .sun_family = AF_UNIX,
> @@ -644,6 +643,8 @@ virSystemdNotifyStartup(void)
>          .msg_iovlen = 1,
>      };
>  
> +    VIR_DEBUG("Notify '%s'", msg);
> +
>      if (!(path = getenv("NOTIFY_SOCKET"))) {
>          VIR_DEBUG("Skipping systemd notify, not requested");
>          return;
> @@ -674,6 +675,40 @@ virSystemdNotifyStartup(void)
>  #endif /* !WIN32 */
>  }
>  
> +void virSystemdNotifyReady(void)
> +{
> +    virSystemdNotify("READY=1");
> +}
> +
> +void virSystemdNotifyReload(void)
> +{
> +    virSystemdNotify("RELOAD=1");
> +}

Per the man page for 'sd_notify' this should be 'RELOADING=1';




[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