]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virt-admin: Introduce 'daemon-timeout'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 13 Jun 2022 13:27:27 +0000 (15:27 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 7 Jul 2022 12:35:30 +0000 (14:35 +0200)
Add a simple command to drive the new 'virAdmConnectSetDaemonTimeout'
API.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/manpages/virt-admin.rst
tools/virt-admin.c

index 30cfd24e7300bb4d6e92fc71e03f541d17f85dfc..479e27b2c240c6f14afbc4ad28d82e4cfb577e76 100644 (file)
@@ -313,6 +313,18 @@ To define multiple outputs at once they need to be delimited by spaces:
 
    $ virt-admin daemon-log-outputs "4:stderr 2:syslog:<msg_ident>"
 
+daemon-timeout
+--------------
+
+**Syntax:**
+
+::
+
+   daemon-timeout --timeout NUM
+
+Sets the daemon timeout to the value of '--timeout' argument. Use ``--timeout 0``
+to disable auto-shutdown of the daemon.
+
 
 SERVER COMMANDS
 ===============
index 952999ca3caea9b4f13ea71175ebab32e63a2ed5..11ba242742d8f2b9244be24094de5ced69e71beb 100644 (file)
@@ -1071,6 +1071,45 @@ static const vshCmdInfo info_daemon_log_outputs[] = {
     {.name = NULL}
 };
 
+static const vshCmdOptDef opts_daemon_timeout[] = {
+    {.name = "timeout",
+     .type = VSH_OT_INT,
+     .help = N_("number of seconds the daemon will run without any active connection"),
+     .flags = VSH_OFLAG_REQ | VSH_OFLAG_REQ_OPT
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdDaemonTimeout(vshControl *ctl, const vshCmd *cmd)
+{
+    vshAdmControl *priv = ctl->privData;
+    unsigned int timeout = 0;
+
+    if (vshCommandOptUInt(ctl, cmd, "timeout", &timeout) < 0)
+        return false;
+
+    if (virAdmConnectSetDaemonTimeout(priv->conn, timeout, 0) < 0)
+        return false;
+
+    return true;
+}
+
+
+/* --------------------------
+ * Command daemon-timeout
+ * --------------------------
+ */
+static const vshCmdInfo info_daemon_timeout[] = {
+    {.name = "help",
+     .data = N_("set the auto shutdown timeout of the daemon")
+    },
+    {.name = "desc",
+     .data = N_("set the auto shutdown timeout of the daemon")
+    },
+    {.name = NULL}
+};
+
 static const vshCmdOptDef opts_daemon_log_outputs[] = {
     {.name = "outputs",
      .type = VSH_OT_STRING,
@@ -1498,6 +1537,12 @@ static const vshCmdDef managementCmds[] = {
      .info = info_daemon_log_outputs,
      .flags = 0
     },
+    {.name = "daemon-timeout",
+     .handler = cmdDaemonTimeout,
+     .opts = opts_daemon_timeout,
+     .info = info_daemon_timeout,
+     .flags = 0
+    },
     {.name = NULL}
 };