[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/24] qga: move w32 service handling out of run_agen
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PULL 20/24] qga: move w32 service handling out of run_agent() |
Date: |
Tue, 30 Oct 2018 09:43:54 -0500 |
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>
Signed-off-by: Bishara AbuHattoum <address@hidden>
Signed-off-by: Michael Roth <address@hidden>
---
qga/main.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/qga/main.c b/qga/main.c
index eb31f99b38..761007deb4 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -119,6 +119,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)
@@ -712,7 +713,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);
@@ -1340,17 +1341,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 (s->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;
}
@@ -1436,7 +1428,19 @@ 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);
+ }
+#else
ret = run_agent(s);
+#endif
+
cleanup_agent(s);
end:
--
2.17.1
- [Qemu-devel] [PULL 11/24] qga-win: refactor disk properties (bus), (continued)
- [Qemu-devel] [PULL 11/24] qga-win: refactor disk properties (bus), Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 15/24] qga-win: return disk device in guest-get-fsinfo, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 10/24] qga-win: add debugging information, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 14/24] qga-win: handle multi-disk volumes, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 12/24] qga-win: report disk serial number, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 13/24] qga-win: refactor disk info, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 18/24] qga: group agent init/cleanup init separate routines, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 16/24] qga-win: demystify namespace stripping, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 17/24] qga: fix an off-by-one issue, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 19/24] qga: hang GAConfig/socket_activation off of GAState global, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 20/24] qga: move w32 service handling out of run_agent(),
Michael Roth <=
- [Qemu-devel] [PULL 01/24] qga: Support Unicode paths in guest-file-open on win32, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 22/24] qga-win: install service with --retry-path set by default, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 21/24] qga: add --retry-path option for re-initializing channel on failure, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 23/24] qga-win: report specific error when failing to open channel, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 02/24] qga-win: add support for qmp_guest_fsfreeze_freeze_list, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 24/24] qga-win: changing --retry-path option behavior, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 03/24] qga: ignore non present cpus when handling qmp_guest_get_vcpus(), Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 04/24] configure: add test for libudev, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 05/24] qga: linux: report disk serial number, Michael Roth, 2018/10/30
- [Qemu-devel] [PULL 07/24] qga-win: prevent crash when executing fsinfo command, Michael Roth, 2018/10/30