qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Add service recovery options for QGA on windows


From: Konstantin Kostiuk
Subject: Re: [PATCH] Add service recovery options for QGA on windows
Date: Thu, 30 Dec 2021 12:28:26 +0200

Hi,

On Mon, Nov 15, 2021 at 4:30 AM <yshxxsjt715@gmail.com> wrote:
From: shenjiatong <yshxxsjt715@gmail.com>

Add default recovery options for QGA on windows. Previously, QGA
on windows will not try to restart service if it is down. This PS
add some default options for the first, second and other failures,
with an interval of 1min. Failure counter will reset after 1 day.

Signed-off-by: shenjiatong <yshxxsjt715@gmail.com>
---
 qga/service-win32.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/qga/service-win32.c b/qga/service-win32.c
index fd434e3f49..0fc93d38c3 100644
--- a/qga/service-win32.c
+++ b/qga/service-win32.c
@@ -105,6 +105,18 @@ int ga_install_service(const char *path, const char *logfile,
     GString *esc;
     GString *cmdline;
     SERVICE_DESCRIPTION desc = { (char *)QGA_SERVICE_DESCRIPTION };
+    SC_ACTION sa[] = {
+        { SC_ACTION_RESTART, 60000},
+        { SC_ACTION_RESTART, 60000},
+        { SC_ACTION_RESTART, 60000}
+    };
+    SERVICE_FAILURE_ACTIONS sfa = {
+        864000, // in seconds,
 
864000 seconds is 10 days, not 1 day.

 
+        NULL,
+        NULL,
+        sizeof(sa) / sizeof(*sa),
+        sa
+    };

     if (GetModuleFileName(NULL, module_fname, MAX_PATH) == 0) {
         printf_win_error("No full path to service's executable");
@@ -146,6 +158,7 @@ int ga_install_service(const char *path, const char *logfile,
     }

     ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &desc);
+    ChangeServiceConfig2(service, SERVICE_CONFIG_FAILURE_ACTIONS, &sfa);
     fprintf(stderr, "Service was installed successfully.\n");
     ret = EXIT_SUCCESS;
     CloseServiceHandle(service);
--
2.25.1


 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]