qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add service recovery options for QGA on windows
@ 2021-11-15  2:21 yshxxsjt715
  2021-12-30 10:28 ` Konstantin Kostiuk
  0 siblings, 1 reply; 2+ messages in thread
From: yshxxsjt715 @ 2021-11-15  2:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: shenjiatong, michael.roth

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,
+        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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Add service recovery options for QGA on windows
  2021-11-15  2:21 [PATCH] Add service recovery options for QGA on windows yshxxsjt715
@ 2021-12-30 10:28 ` Konstantin Kostiuk
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Kostiuk @ 2021-12-30 10:28 UTC (permalink / raw)
  To: yshxxsjt715; +Cc: Michael Roth, Developers

[-- Attachment #1: Type: text/plain, Size: 1780 bytes --]

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
>
>

[-- Attachment #2: Type: text/html, Size: 2680 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-30 10:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15  2:21 [PATCH] Add service recovery options for QGA on windows yshxxsjt715
2021-12-30 10:28 ` Konstantin Kostiuk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).