virSystemdHasResolvedResetCachedValue;
virSystemdMakeScopeName;
virSystemdMakeSliceName;
-virSystemdNotifyStartup;
+virSystemdNotifyExtendTimeout;
+virSystemdNotifyReady;
+virSystemdNotifyReload;
+virSystemdNotifyStatus;
+virSystemdNotifyStopping;
virSystemdResolvedRegisterNameServer;
virSystemdTerminateMachine;
/* We are accepting connections now. Notify systemd
* so it can start dependent services. */
- virSystemdNotifyStartup();
+ virSystemdNotifyReady();
VIR_DEBUG("dmn=%p quit=%d", dmn, dmn->quit);
while (!dmn->finished) {
return 0;
}
-void
-virSystemdNotifyStartup(void)
+static void
+virSystemdNotify(const char *msg)
{
#ifndef WIN32
const char *path;
- const char *msg = "READY=1";
int fd;
struct sockaddr_un un = {
.sun_family = AF_UNIX,
.msg_iovlen = 1,
};
+ VIR_DEBUG("Notify '%s'", msg);
+
if (!(path = getenv("NOTIFY_SOCKET"))) {
VIR_DEBUG("Skipping systemd notify, not requested");
return;
#endif /* !WIN32 */
}
+void virSystemdNotifyReady(void)
+{
+ virSystemdNotify("READY=1");
+}
+
+void virSystemdNotifyReload(void)
+{
+ gint64 now = g_get_monotonic_time();
+ g_autofree char *msg = g_strdup_printf(
+ "RELOADING=1\nMONOTONIC_USEC=%lld", (long long int)now);
+ virSystemdNotify(msg);
+}
+
+void virSystemdNotifyStopping(void)
+{
+ virSystemdNotify("STOPPING=1");
+}
+
+void virSystemdNotifyExtendTimeout(int secs)
+{
+ g_autofree char *msg = g_strdup_printf("EXTEND_TIMEOUT_USEC=%llu",
+ secs * 1000ull * 1000ull);
+ virSystemdNotify(msg);
+}
+
+void virSystemdNotifyStatus(const char *fmt, ...)
+{
+ g_autofree char *msg1 = NULL;
+ g_autofree char *msg2 = NULL;
+ va_list ap;
+ va_start(ap, fmt);
+ msg1 = g_strdup_vprintf(fmt, ap);
+ va_end(ap);
+ msg2 = g_strdup_printf("STATUS=%s", msg1);
+ virSystemdNotify(msg2);
+}
+
static int
virSystemdPMSupportTarget(const char *methodName, bool *result)
{
int virSystemdTerminateMachine(const char *name);
-void virSystemdNotifyStartup(void);
+void virSystemdNotifyReady(void);
+void virSystemdNotifyReload(void);
+void virSystemdNotifyStopping(void);
+void virSystemdNotifyExtendTimeout(int secs);
+void virSystemdNotifyStatus(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
int virSystemdHasMachined(void);