]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools: fix ordering mistake in virt-admin daemon-set-timeout code
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 7 Jan 2025 11:37:57 +0000 (11:37 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 8 Jan 2025 13:00:44 +0000 (13:00 +0000)
Most of the impl for the 'daemon-set-timeout' command was ordered under
the heading for the 'daemon-log-filters' command.

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
tools/virt-admin.c

index 3eb4f0f3fddea7a7a869de1e52b8915913510b5c..325b7aa827544b624fda5103a1848c41ae5f54e6 100644 (file)
@@ -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)
 {