[PATCH 4/6] admin: Introduce virAdmConnectSetDaemonTimeout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use of the admin APIs to modify logging temporarily has a rather serious
deficiency when the daemon whose config is being changed is using
auto-shutdown (default with socket-activated deployments) as the
configuration is discarded if there is no client or VM/other object
blocking auto shutdown.

This API allows users to disable/postpone shutdown timeout so that the
configuration doesn't change under their hands.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 include/libvirt/libvirt-admin.h     |  4 ++++
 src/admin/admin_protocol.x          | 12 +++++++++-
 src/admin/admin_server_dispatch.c   | 12 ++++++++++
 src/admin/libvirt-admin.c           | 34 +++++++++++++++++++++++++++++
 src/admin/libvirt_admin_public.syms |  5 +++++
 src/admin_protocol-structs          |  5 +++++
 6 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h
index 8533658932..ae4703f89b 100644
--- a/include/libvirt/libvirt-admin.h
+++ b/include/libvirt/libvirt-admin.h
@@ -480,6 +480,10 @@ int virAdmConnectSetLoggingFilters(virAdmConnectPtr conn,
                                    const char *filters,
                                    unsigned int flags);

+int virAdmConnectSetDaemonTimeout(virAdmConnectPtr conn,
+                                  unsigned int timeout,
+                                  unsigned int flags);
+
 # ifdef __cplusplus
 }
 # endif
diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x
index 7dc6724032..f3130efd2d 100644
--- a/src/admin/admin_protocol.x
+++ b/src/admin/admin_protocol.x
@@ -214,6 +214,11 @@ struct admin_connect_set_logging_filters_args {
     unsigned int flags;
 };

+struct admin_connect_set_daemon_timeout_args {
+    unsigned int timeout;
+    unsigned int flags;
+};
+
 /* Define the program number, protocol version and procedure numbers here. */
 const ADMIN_PROGRAM = 0x06900690;
 const ADMIN_PROTOCOL_VERSION = 1;
@@ -324,5 +329,10 @@ enum admin_procedure {
     /**
      * @generate: both
      */
-    ADMIN_PROC_SERVER_UPDATE_TLS_FILES = 18
+    ADMIN_PROC_SERVER_UPDATE_TLS_FILES = 18,
+
+    /**
+     * @generate: both
+     */
+    ADMIN_PROC_CONNECT_SET_DAEMON_TIMEOUT = 19
 };
diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dispatch.c
index 893c7f1de2..8ab243c8eb 100644
--- a/src/admin/admin_server_dispatch.c
+++ b/src/admin/admin_server_dispatch.c
@@ -466,6 +466,18 @@ adminConnectSetLoggingFilters(virNetDaemon *dmn G_GNUC_UNUSED,
     return virLogSetFilters(filters);
 }

+
+static int
+adminConnectSetDaemonTimeout(virNetDaemon *dmn,
+                             unsigned int timeout,
+                             unsigned int flags)
+{
+    virCheckFlags(0, -1);
+
+    return virNetDaemonAutoShutdown(dmn, timeout);
+}
+
+
 static int
 adminDispatchConnectGetLoggingOutputs(virNetServer *server G_GNUC_UNUSED,
                                       virNetServerClient *client G_GNUC_UNUSED,
diff --git a/src/admin/libvirt-admin.c b/src/admin/libvirt-admin.c
index 5f64784a13..4b5d615e9d 100644
--- a/src/admin/libvirt-admin.c
+++ b/src/admin/libvirt-admin.c
@@ -1329,3 +1329,37 @@ virAdmConnectSetLoggingFilters(virAdmConnectPtr conn,
     virDispatchError(NULL);
     return -1;
 }
+
+
+/**
+ * virAdmConnectSetDaemonTimeout:
+ * @conn: pointer to an active admin connection
+ * @timeout: timeout to set in seconds (0 disables timeout)
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Reconfigure the existing timeout of the daemon to @timeout. Setting timeout
+ * to 0 disables the daemon timeout.
+ *
+ * Returns 0 on success, -1 on error.
+ *
+ * Since: 8.5.0
+ */
+int
+virAdmConnectSetDaemonTimeout(virAdmConnectPtr conn,
+                              unsigned int timeout,
+                              unsigned int flags)
+{
+    int ret;
+
+    VIR_DEBUG("conn=%p, timeout=%u, flags=0x%x", conn, timeout, flags);
+
+    virResetLastError();
+    virCheckAdmConnectReturn(conn, -1);
+
+    if ((ret = remoteAdminConnectSetDaemonTimeout(conn, timeout, flags)) < 0) {
+        virDispatchError(NULL);
+        return -1;
+    }
+
+    return ret;
+}
diff --git a/src/admin/libvirt_admin_public.syms b/src/admin/libvirt_admin_public.syms
index 8126973e5b..554269613c 100644
--- a/src/admin/libvirt_admin_public.syms
+++ b/src/admin/libvirt_admin_public.syms
@@ -48,3 +48,8 @@ LIBVIRT_ADMIN_3.0.0 {
         virAdmConnectSetLoggingOutputs;
         virAdmConnectSetLoggingFilters;
 } LIBVIRT_ADMIN_2.0.0;
+
+LIBVIRT_ADMIN_8.5.0 {
+    global:
+        virAdmConnectSetDaemonTimeout;
+} LIBVIRT_ADMIN_3.0.0;
diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs
index 76c511babf..8caac59824 100644
--- a/src/admin_protocol-structs
+++ b/src/admin_protocol-structs
@@ -144,6 +144,10 @@ struct admin_connect_set_logging_filters_args {
         admin_string               filters;
         u_int                      flags;
 };
+struct admin_connect_set_daemon_timeout_args {
+        u_int                      timeout;
+        u_int                      flags;
+};
 enum admin_procedure {
         ADMIN_PROC_CONNECT_OPEN = 1,
         ADMIN_PROC_CONNECT_CLOSE = 2,
@@ -163,4 +167,5 @@ enum admin_procedure {
         ADMIN_PROC_CONNECT_SET_LOGGING_OUTPUTS = 16,
         ADMIN_PROC_CONNECT_SET_LOGGING_FILTERS = 17,
         ADMIN_PROC_SERVER_UPDATE_TLS_FILES = 18,
+        ADMIN_PROC_CONNECT_SET_DAEMON_TIMEOUT       = 19,
 };
-- 
2.36.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux