[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/7] qga: move w32 service handling out of run_a
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH 3/7] qga: move w32 service handling out of run_agent() |
Date: |
Thu, 27 Sep 2018 15:44:56 +0400 |
Hi
On Thu, Sep 27, 2018 at 11:39 AM Bishara AbuHattoum <address@hidden> wrote:
>
> From: Michael Roth <address@hidden>
>
> Eventually we want a w32 service to be able to restart the qga main
> loop from within service_main(). To allow for this we move service
> handling out of run_agent() such that service_main() calls
> run_agent() instead of the reverse.
>
> Signed-off-by: Michael Roth <address@hidden>
> Message-Id: <address@hidden>
Same remark about message-id
> ---
> qga/main.c | 25 ++++++++++++++-----------
> 1 file changed, 14 insertions(+), 11 deletions(-)
>
> diff --git a/qga/main.c b/qga/main.c
> index 7381053a0f..d9888bff5f 100644
> --- a/qga/main.c
> +++ b/qga/main.c
> @@ -136,6 +136,7 @@ DWORD WINAPI service_ctrl_handler(DWORD ctrl, DWORD type,
> LPVOID data,
> LPVOID ctx);
> VOID WINAPI service_main(DWORD argc, TCHAR *argv[]);
> #endif
> +static int run_agent(GAState *s);
>
> static void
> init_dfl_pathnames(void)
> @@ -763,7 +764,7 @@ VOID WINAPI service_main(DWORD argc, TCHAR *argv[])
> service->status.dwWaitHint = 0;
> SetServiceStatus(service->status_handle, &service->status);
>
> - g_main_loop_run(ga_state->main_loop);
> + run_agent(ga_state);
>
> service->status.dwCurrentState = SERVICE_STOPPED;
> SetServiceStatus(service->status_handle, &service->status);
> @@ -1372,17 +1373,8 @@ static int run_agent(GAState *s)
> g_critical("failed to initialize guest agent channel");
> return EXIT_FAILURE;
> }
> -#ifndef _WIN32
> +
> g_main_loop_run(ga_state->main_loop);
> -#else
> - if (config->daemonize) {
> - SERVICE_TABLE_ENTRY service_table[] = {
> - { (char *)QGA_SERVICE_NAME, service_main }, { NULL, NULL } };
> - StartServiceCtrlDispatcher(service_table);
> - } else {
> - g_main_loop_run(ga_state->main_loop);
> - }
> -#endif
>
> return EXIT_SUCCESS;
> }
> @@ -1468,7 +1460,18 @@ int main(int argc, char **argv)
> g_critical("error initializing guest agent");
> goto end;
> }
> +
> +#ifdef _WIN32
> + if (config->daemonize) {
> + SERVICE_TABLE_ENTRY service_table[] = {
> + { (char *)QGA_SERVICE_NAME, service_main }, { NULL, NULL } };
> + StartServiceCtrlDispatcher(service_table);
> + } else {
> + ret = run_agent(s);
> + }
> +#endif
> ret = run_agent(s);
run_agent() is called twice.
> +
> cleanup_agent(s);
>
> end:
> --
> 2.17.0
>
>
--
Marc-André Lureau
- [Qemu-devel] [PATCH 0/7] qga: add support for re-opening channel on error, Bishara AbuHattoum, 2018/09/27
- [Qemu-devel] [PATCH 3/7] qga: move w32 service handling out of run_agent(), Bishara AbuHattoum, 2018/09/27
- Re: [Qemu-devel] [PATCH 3/7] qga: move w32 service handling out of run_agent(),
Marc-André Lureau <=
- [Qemu-devel] [PATCH 1/7] qga: group agent init/cleanup init separate routines, Bishara AbuHattoum, 2018/09/27
- [Qemu-devel] [PATCH 4/7] qga: add --retry-path option for re-initializing channel on failure, Bishara AbuHattoum, 2018/09/27
- [Qemu-devel] [PATCH 2/7] qga: hang GAConfig/socket_activation off of GAState global, Bishara AbuHattoum, 2018/09/27
- [Qemu-devel] [PATCH 5/7] qga-win: install service with --retry-path set by default, Bishara AbuHattoum, 2018/09/27
- [Qemu-devel] [PATCH 6/7] qga-win: report specific error when failing to open channel, Bishara AbuHattoum, 2018/09/27
- [Qemu-devel] [PATCH 7/7] qga-win: changing --retry-path option behavior, Bishara AbuHattoum, 2018/09/27