提交 a1c793ec 编写于 作者: A Andrea Bolognani

daemons: Support --timeout 0

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: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 9428c460
......@@ -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);
......
......@@ -653,7 +653,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;
......@@ -703,7 +703,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"));
......@@ -905,7 +905,7 @@ int main(int argc, char **argv) {
adminSrv = virNetDaemonGetServer(logDaemon->dmn, "admin");
}
if (timeout != -1) {
if (timeout > 0) {
VIR_DEBUG("Registering shutdown timeout %d", timeout);
virNetDaemonAutoShutdown(logDaemon->dmn,
timeout);
......
......@@ -770,7 +770,7 @@ int main(int argc, char **argv) {
char *sock_file = NULL;
char *sock_file_ro = NULL;
char *sock_file_adm = NULL;
int timeout = -1; /* -t: Shutdown timeout */
int timeout = 0; /* -t: Shutdown timeout */
int verbose = 0;
int godaemon = 0;
#ifdef WITH_IP
......@@ -844,7 +844,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"));
......@@ -1107,7 +1107,7 @@ int main(int argc, char **argv) {
goto cleanup;
}
if (timeout != -1) {
if (timeout > 0) {
VIR_DEBUG("Registering shutdown timeout %d", timeout);
virNetDaemonAutoShutdown(dmn, timeout);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册