aboutsummaryrefslogtreecommitdiff
path: root/qga/main.c
diff options
context:
space:
mode:
authorSameeh Jubran <sameeh@daynix.com>2017-04-11 10:50:36 +0300
committerMichael Roth <mdroth@linux.vnet.ibm.com>2017-04-26 23:56:47 -0500
commit94d81ae896810beafa60c85b88e991daa986e1fc (patch)
tree7401ff7550fac55e2465c87929a8c15f681dfe2f /qga/main.c
parent54858553def1879a3b0781529fb12a028ba36713 (diff)
downloadqemu-arm-94d81ae896810beafa60c85b88e991daa986e1fc.tar.gz
qga-win: Fix a bug where qemu-ga service is stuck during stop operation
After triggering a freeze command without any following thaw command, qemu-ga will not respond to stop operation. This behaviour is wanted on Linux as there is no time limit for a freeze command and we want to prevent quitting in the middle of freeze, on the other hand on Windows the time limit for freeze is 10 seconds, so we should wait for the timeout, thaw the file system and quit. Signed-off-by: Sameeh Jubran <sameeh@daynix.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga/main.c')
-rw-r--r--qga/main.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/qga/main.c b/qga/main.c
index 07c295376f..ad6f68f187 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -131,9 +131,32 @@ static void quit_handler(int sig)
* unless all log/pid files are on unfreezable filesystems. there's
* also a very likely chance killing the agent before unfreezing
* the filesystems is a mistake (or will be viewed as one later).
+ * On Windows the freeze interval is limited to 10 seconds, so
+ * we should quit, but first we should wait for the timeout, thaw
+ * the filesystem and quit.
*/
if (ga_is_frozen(ga_state)) {
+#ifdef _WIN32
+ int i = 0;
+ Error *err = NULL;
+ HANDLE hEventTimeout;
+
+ g_debug("Thawing filesystems before exiting");
+
+ hEventTimeout = OpenEvent(EVENT_ALL_ACCESS, FALSE, EVENT_NAME_TIMEOUT);
+ if (hEventTimeout) {
+ WaitForSingleObject(hEventTimeout, 0);
+ CloseHandle(hEventTimeout);
+ }
+ qga_vss_fsfreeze(&i, false, &err);
+ if (err) {
+ g_debug("Error unfreezing filesystems prior to exiting: %s",
+ error_get_pretty(err));
+ error_free(err);
+ }
+#else
return;
+#endif
}
g_debug("received signal num %d, quitting", sig);