Re: [PATCH 2/6] virNetDaemonAutoShutdown: Allow live update of shutdown timeout

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

 



On 6/13/22 15:56, Peter Krempa wrote:
> Modify the code so that calling 'virNetDaemonAutoShutdown' will update
> the auto shutdown timeout also for running daemons.
> 
> This involves changing the logic when to do the update of the timer so
> that it can be called from both when the daemon is not yet runnign and
> when doing a live update.
> 
> Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> ---
>  src/locking/lock_daemon.c  |  5 ++---
>  src/logging/log_daemon.c   |  5 ++---
>  src/remote/remote_daemon.c |  4 ++--
>  src/rpc/virnetdaemon.c     | 29 +++++++++++++++++++++--------
>  src/rpc/virnetdaemon.h     |  4 ++--
>  5 files changed, 29 insertions(+), 18 deletions(-)
> 


> diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
> index 7bf27eed9d..84af1adc06 100644
> --- a/src/rpc/virnetdaemon.c
> +++ b/src/rpc/virnetdaemon.c
> @@ -75,6 +75,7 @@ struct _virNetDaemon {
>      bool finished;
>      bool graceful;
>      bool execRestart;
> +    bool running; /* the daemon has reached the running phase */
> 
>      unsigned int autoShutdownTimeout;
>      int autoShutdownTimerID;
> @@ -424,7 +425,7 @@ virNetDaemonAutoShutdownTimer(int timerid G_GNUC_UNUSED,
>  static int
>  virNetDaemonShutdownTimerRegister(virNetDaemon *dmn)
>  {
> -    if (dmn->autoShutdownTimeout == 0)
> +    if (dmn->autoShutdownTimerID != -1)
>          return 0;
> 
>      if ((dmn->autoShutdownTimerID = virEventAddTimeout(-1,
> @@ -442,7 +443,7 @@ virNetDaemonShutdownTimerRegister(virNetDaemon *dmn)
>  static void
>  virNetDaemonShutdownTimerUpdate(virNetDaemon *dmn)
>  {
> -    if (dmn->autoShutdownTimeout == 0)
> +    if (dmn->autoShutdownTimerID == -1)
>          return;
> 
>      /* A shutdown timeout is specified, so check
> @@ -450,13 +451,15 @@ virNetDaemonShutdownTimerUpdate(virNetDaemon *dmn)
>       * shutdown after timeout seconds
>       */
>      if (dmn->autoShutdownTimerActive) {
> -        if (virNetDaemonHasClients(dmn)) {
> +        if (virNetDaemonHasClients(dmn) ||
> +            dmn->autoShutdownTimeout == 0) {

Here the logical OR makes sense, because either of the conditions has to
lead to timer deactivation, however ...

>              VIR_DEBUG("Deactivating shutdown timer %d", dmn->autoShutdownTimerID);
>              virEventUpdateTimeout(dmn->autoShutdownTimerID, -1);
>              dmn->autoShutdownTimerActive = false;
>          }
>      } else {
> -        if (!virNetDaemonHasClients(dmn)) {
> +        if (!virNetDaemonHasClients(dmn) ||
> +            dmn->autoShutdownTimeout != 0) {

... here both conditions have to be met. Otherwise setting timeout to 0
and disconnecting the last client will lead to immediate quit of the daemon.

Michal




[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