|
@@ -83,6 +83,7 @@ struct GAState {
|
|
|
#ifdef _WIN32
|
|
|
GAService service;
|
|
|
HANDLE wakeup_event;
|
|
|
+ HANDLE event_log;
|
|
|
#endif
|
|
|
bool delimit_response;
|
|
|
bool frozen;
|
|
@@ -324,13 +325,14 @@ static void ga_log(const gchar *domain, GLogLevelFlags level,
|
|
|
}
|
|
|
|
|
|
level &= G_LOG_LEVEL_MASK;
|
|
|
-#ifndef _WIN32
|
|
|
if (g_strcmp0(domain, "syslog") == 0) {
|
|
|
+#ifndef _WIN32
|
|
|
syslog(LOG_INFO, "%s: %s", level_str, msg);
|
|
|
- } else if (level & s->log_level) {
|
|
|
#else
|
|
|
- if (level & s->log_level) {
|
|
|
+ ReportEvent(s->event_log, EVENTLOG_INFORMATION_TYPE,
|
|
|
+ 0, 1, NULL, 1, 0, &msg, NULL);
|
|
|
#endif
|
|
|
+ } else if (level & s->log_level) {
|
|
|
g_autoptr(GDateTime) now = g_date_time_new_now_utc();
|
|
|
g_autofree char *nowstr = g_date_time_format(now, "%s.%f");
|
|
|
fprintf(s->log_file, "%s: %s: %s\n", nowstr, level_str, msg);
|
|
@@ -1286,6 +1288,13 @@ static GAState *initialize_agent(GAConfig *config, int socket_activation)
|
|
|
g_debug("Guest agent version %s started", QEMU_FULL_VERSION);
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
+ s->event_log = RegisterEventSource(NULL, "qemu-ga");
|
|
|
+ if (!s->event_log) {
|
|
|
+ g_autofree gchar *errmsg = g_win32_error_message(GetLastError());
|
|
|
+ g_critical("unable to register event source: %s", errmsg);
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
/* On win32 the state directory is application specific (be it the default
|
|
|
* or a user override). We got past the command line parsing; let's create
|
|
|
* the directory (with any intermediate directories). If we run into an
|
|
@@ -1377,6 +1386,7 @@ static void cleanup_agent(GAState *s)
|
|
|
{
|
|
|
#ifdef _WIN32
|
|
|
CloseHandle(s->wakeup_event);
|
|
|
+ CloseHandle(s->event_log);
|
|
|
#endif
|
|
|
if (s->command_state) {
|
|
|
ga_command_state_cleanup_all(s->command_state);
|