From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: sameeh@daynix.com, yan@daynix.com, daniel@daynix.com
Subject: [Qemu-devel] [PATCH 3/6] qga: move w32 service handling out of run_agent()
Date: Thu, 26 Oct 2017 18:30:51 -0500 [thread overview]
Message-ID: <20171026233054.21133-4-mdroth@linux.vnet.ibm.com> (raw)
In-Reply-To: <20171026233054.21133-1-mdroth@linux.vnet.ibm.com>
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 <mdroth@linux.vnet.ibm.com>
---
qga/main.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/qga/main.c b/qga/main.c
index 6826cd5f45..2422ccf2f8 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -133,6 +133,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)
@@ -768,7 +769,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);
@@ -1377,17 +1378,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;
}
@@ -1473,7 +1465,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);
+
cleanup_agent(s);
end:
--
2.11.0
next prev parent reply other threads:[~2017-10-26 23:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 23:30 [Qemu-devel] [PATCH 0/6] qga: add support for re-opening channel on error Michael Roth
2017-10-26 23:30 ` [Qemu-devel] [PATCH 1/6] qga: group agent init/cleanup init separate routines Michael Roth
2017-10-26 23:30 ` [Qemu-devel] [PATCH 2/6] qga: hang GAConfig/socket_activation off of GAState global Michael Roth
2017-10-26 23:30 ` Michael Roth [this message]
2017-10-26 23:30 ` [Qemu-devel] [PATCH 4/6] qga: add --retry-path option for re-initializing channel on failure Michael Roth
2017-10-26 23:30 ` [Qemu-devel] [PATCH 5/6] qga-win: install service with --retry-path set by default Michael Roth
2017-10-26 23:30 ` [Qemu-devel] [PATCH 6/6] qga-win: report specific error when failing to open channel Michael Roth
2017-10-26 23:38 ` [Qemu-devel] [PATCH 0/6] qga: add support for re-opening channel on error no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171026233054.21133-4-mdroth@linux.vnet.ibm.com \
--to=mdroth@linux.vnet.ibm.com \
--cc=daniel@daynix.com \
--cc=qemu-devel@nongnu.org \
--cc=sameeh@daynix.com \
--cc=yan@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).