to disable auto-shutdown of the daemon.
+daemon-shutdown
+---------------
+
+**Syntax:**
+
+::
+
+ daemon-shutdown [--preserve]
+
+Instruct the daemon to exit gracefully. If the ``--preserve`` flag is given,
+it will save state in the same manner that would be done on a host OS shutdown
+(privileged daemons) or a login session quit (unprivileged daemons).
+
SERVER COMMANDS
===============
unsigned int timeout,
unsigned int flags);
+/**
+ * virAdmConnectDaemonShutdownFlags:
+ *
+ * Since: 11.2.0
+ */
+typedef enum {
+ /* Preserve state before shutting down daemon (Since: 11.2.0) */
+ VIR_DAEMON_SHUTDOWN_PRESERVE = (1 << 0),
+} virAdmConnectDaemonShutdownFlags;
+
+int virAdmConnectDaemonShutdown(virAdmConnectPtr conn,
+ unsigned int flags);
+
# ifdef __cplusplus
}
# endif
unsigned int flags;
};
+struct admin_connect_daemon_shutdown_args {
+ unsigned int flags;
+};
+
/* Define the program number, protocol version and procedure numbers here. */
const ADMIN_PROGRAM = 0x06900690;
const ADMIN_PROTOCOL_VERSION = 1;
/**
* @generate: both
*/
- ADMIN_PROC_CONNECT_SET_DAEMON_TIMEOUT = 19
+ ADMIN_PROC_CONNECT_SET_DAEMON_TIMEOUT = 19,
+
+ /**
+ * @generate: both
+ */
+ ADMIN_PROC_CONNECT_DAEMON_SHUTDOWN = 20
};
return virNetDaemonAutoShutdown(dmn, timeout);
}
+static int
+adminConnectDaemonShutdown(virNetDaemon *dmn,
+ unsigned int flags)
+{
+ virCheckFlags(VIR_DAEMON_SHUTDOWN_PRESERVE, -1);
+
+ if (flags & VIR_DAEMON_SHUTDOWN_PRESERVE)
+ virNetDaemonStop(dmn);
+
+ virNetDaemonQuit(dmn);
+
+ return 0;
+}
static int
adminDispatchConnectGetLoggingOutputs(virNetServer *server G_GNUC_UNUSED,
return ret;
}
+
+
+/**
+ * virAdmConnectDaemonShutdown:
+ * @conn: pointer to an active admin connection
+ * @flags: optional extra falgs
+ *
+ * Trigger shutdown of the daemon, if @flags includes
+ * VIR_DAEMON_SHUTDOWN_PRESERVE then state will be
+ * preserved before shutting down
+ *
+ * Returns 0 on success, -1 on error.
+ *
+ * Since: 11.2.0
+ */
+int
+virAdmConnectDaemonShutdown(virAdmConnectPtr conn,
+ unsigned int flags)
+{
+ int ret;
+
+ VIR_DEBUG("conn=%p, flags=0x%x", conn, flags);
+
+ virResetLastError();
+ virCheckAdmConnectReturn(conn, -1);
+
+ if ((ret = remoteAdminConnectDaemonShutdown(conn, flags)) < 0) {
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ return ret;
+}
global:
virAdmConnectSetDaemonTimeout;
} LIBVIRT_ADMIN_3.0.0;
+
+LIBVIRT_ADMIN_11.2.0 {
+ global:
+ virAdmConnectDaemonShutdown;
+} LIBVIRT_ADMIN_8.6.0;
u_int timeout;
u_int flags;
};
+struct admin_connect_daemon_shutdown_args {
+ u_int flags;
+};
enum admin_procedure {
ADMIN_PROC_CONNECT_OPEN = 1,
ADMIN_PROC_CONNECT_CLOSE = 2,
ADMIN_PROC_CONNECT_SET_LOGGING_FILTERS = 17,
ADMIN_PROC_SERVER_UPDATE_TLS_FILES = 18,
ADMIN_PROC_CONNECT_SET_DAEMON_TIMEOUT = 19,
+ ADMIN_PROC_CONNECT_DAEMON_SHUTDOWN = 20,
};
}
+/* --------------------------
+ * Command daemon-shutdown
+ * --------------------------
+ */
+static const vshCmdInfo info_daemon_shutdown = {
+ .help = N_("stop the daemon"),
+ .desc = N_("stop the daemon"),
+};
+
+static const vshCmdOptDef opts_daemon_shutdown[] = {
+ {.name = "preserve",
+ .type = VSH_OT_BOOL,
+ .required = false,
+ .positional = false,
+ .help = N_("preserve state before shutting down"),
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdDaemonShutdown(vshControl *ctl, const vshCmd *cmd)
+{
+ vshAdmControl *priv = ctl->privData;
+ unsigned int flags = 0;
+
+ if (vshCommandOptBool(cmd, "preserve"))
+ flags |= VIR_DAEMON_SHUTDOWN_PRESERVE;
+
+ if (virAdmConnectDaemonShutdown(priv->conn, flags) < 0)
+ return false;
+
+ return true;
+}
+
+
static void *
vshAdmConnectionHandler(vshControl *ctl)
{
.info = &info_daemon_timeout,
.flags = 0
},
+ {.name = "daemon-shutdown",
+ .handler = cmdDaemonShutdown,
+ .opts = opts_daemon_shutdown,
+ .info = &info_daemon_shutdown,
+ .flags = 0
+ },
{.name = NULL}
};