Most of the impl for the 'daemon-set-timeout' command was ordered under the heading for the 'daemon-log-filters' command. Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- tools/virt-admin.c | 67 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 3eb4f0f3fd..325b7aa827 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1005,27 +1005,38 @@ static const vshCmdInfo info_daemon_log_outputs = { "daemon."), }; -static const vshCmdOptDef opts_daemon_timeout[] = { - {.name = "timeout", - .type = VSH_OT_INT, - .required = true, +static const vshCmdOptDef opts_daemon_log_outputs[] = { + {.name = "outputs", + .type = VSH_OT_STRING, .positional = true, - .help = N_("number of seconds the daemon will run without any active connection"), + .help = N_("redefine the existing set of logging outputs"), + .allowEmpty = true }, {.name = NULL} }; static bool -cmdDaemonTimeout(vshControl *ctl, const vshCmd *cmd) +cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd) { vshAdmControl *priv = ctl->privData; - unsigned int timeout = 0; - if (vshCommandOptUInt(ctl, cmd, "timeout", &timeout) < 0) - return false; + if (vshCommandOptBool(cmd, "outputs")) { + const char *outputs = NULL; + if ((vshCommandOptString(ctl, cmd, "outputs", &outputs) < 0 || + virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) { + vshError(ctl, _("Unable to change daemon logging settings")); + return false; + } + } else { + g_autofree char *outputs = NULL; + if (virAdmConnectGetLoggingOutputs(priv->conn, &outputs, 0) < 0) { + vshError(ctl, _("Unable to get daemon logging outputs information")); + return false; + } - if (virAdmConnectSetDaemonTimeout(priv->conn, timeout, 0) < 0) - return false; + vshPrintExtra(ctl, " %-15s", _("Logging outputs: ")); + vshPrint(ctl, "%s\n", NULLSTR_EMPTY(outputs)); + } return true; } @@ -1040,42 +1051,32 @@ static const vshCmdInfo info_daemon_timeout = { .desc = N_("set the auto shutdown timeout of the daemon"), }; -static const vshCmdOptDef opts_daemon_log_outputs[] = { - {.name = "outputs", - .type = VSH_OT_STRING, +static const vshCmdOptDef opts_daemon_timeout[] = { + {.name = "timeout", + .type = VSH_OT_INT, + .required = true, .positional = true, - .help = N_("redefine the existing set of logging outputs"), - .allowEmpty = true + .help = N_("number of seconds the daemon will run without any active connection"), }, {.name = NULL} }; static bool -cmdDaemonLogOutputs(vshControl *ctl, const vshCmd *cmd) +cmdDaemonTimeout(vshControl *ctl, const vshCmd *cmd) { vshAdmControl *priv = ctl->privData; + unsigned int timeout = 0; - if (vshCommandOptBool(cmd, "outputs")) { - const char *outputs = NULL; - if ((vshCommandOptString(ctl, cmd, "outputs", &outputs) < 0 || - virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) { - vshError(ctl, _("Unable to change daemon logging settings")); - return false; - } - } else { - g_autofree char *outputs = NULL; - if (virAdmConnectGetLoggingOutputs(priv->conn, &outputs, 0) < 0) { - vshError(ctl, _("Unable to get daemon logging outputs information")); - return false; - } + if (vshCommandOptUInt(ctl, cmd, "timeout", &timeout) < 0) + return false; - vshPrintExtra(ctl, " %-15s", _("Logging outputs: ")); - vshPrint(ctl, "%s\n", NULLSTR_EMPTY(outputs)); - } + if (virAdmConnectSetDaemonTimeout(priv->conn, timeout, 0) < 0) + return false; return true; } + static void * vshAdmConnectionHandler(vshControl *ctl) { -- 2.47.1