[libvirt PATCH 1/8] daemons: Support --timeout 0
Daniel P. Berrangé
berrange at redhat.com
Thu Apr 2 12:05:16 UTC 2020
On Wed, Apr 01, 2020 at 08:53:38PM +0200, Andrea Bolognani wrote:
> When using systemd we want to take advantage of socket activation
> instead of keeping daemons running all the time, so we default to
> shutting them down after two minutes of inactivity.
>
> At the same time, we want it to be possible for the admin to opt
> out of this behavior and disable timeouts entirely. A very natural
> way to do so would be to specify a zero-length timeout, but that's
> currently not accepted by the command line parser. Address that.
>
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
> src/locking/lock_daemon.c | 6 +++---
> src/logging/log_daemon.c | 6 +++---
> src/remote/remote_daemon.c | 6 +++---
> 3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
> index 3d33995beb..4eff63014a 100644
> --- a/src/locking/lock_daemon.c
> +++ b/src/locking/lock_daemon.c
> @@ -872,7 +872,7 @@ int main(int argc, char **argv) {
> int pid_file_fd = -1;
> char *sock_file = NULL;
> char *admin_sock_file = NULL;
> - int timeout = -1; /* -t: Shutdown timeout */
> + int timeout = 0; /* -t: Shutdown timeout */
> char *state_file = NULL;
> bool implicit_conf = false;
> mode_t old_umask;
> @@ -922,7 +922,7 @@ int main(int argc, char **argv) {
>
> case 't':
> if (virStrToLong_i(optarg, &tmp, 10, &timeout) != 0
> - || timeout <= 0
> + || timeout < 0
> /* Ensure that we can multiply by 1000 without overflowing. */
> || timeout > INT_MAX / 1000) {
> VIR_ERROR(_("Invalid value for timeout"));
> @@ -1123,7 +1123,7 @@ int main(int argc, char **argv) {
> adminSrv = virNetDaemonGetServer(lockDaemon->dmn, "admin");
> }
>
> - if (timeout != -1) {
> + if (timeout > 0) {
> VIR_DEBUG("Registering shutdown timeout %d", timeout);
> virNetDaemonAutoShutdown(lockDaemon->dmn,
> timeout);
This conditional can be removed because virNetDaemonAutoShutdown
treats "timeout == 0" as meaning no timeout.
Likewise in other files.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the libvir-list
mailing list