mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-17 21:26:13 -07:00
qemu-ga: fixes for win32 build of qemu-ga
Various stubs and #ifdefs to compile for Windows using mingw cross-build. Still has 1 linker error due to a dependency on the forthcoming win32 versions of the GAChannel/transport class.
This commit is contained in:
parent
c216e5add1
commit
d8ca685acb
5 changed files with 114 additions and 6 deletions
16
qemu-ga.c
16
qemu-ga.c
|
|
@ -15,7 +15,9 @@
|
|||
#include <stdbool.h>
|
||||
#include <glib.h>
|
||||
#include <getopt.h>
|
||||
#ifndef _WIN32
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
#include "json-streamer.h"
|
||||
#include "json-parser.h"
|
||||
#include "qint.h"
|
||||
|
|
@ -44,6 +46,7 @@ struct GAState {
|
|||
|
||||
static struct GAState *ga_state;
|
||||
|
||||
#ifndef _WIN32
|
||||
static void quit_handler(int sig)
|
||||
{
|
||||
g_debug("received signal num %d, quitting", sig);
|
||||
|
|
@ -73,6 +76,7 @@ static gboolean register_signal_handlers(void)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void usage(const char *cmd)
|
||||
{
|
||||
|
|
@ -87,7 +91,9 @@ static void usage(const char *cmd)
|
|||
" -f, --pidfile specify pidfile (default is %s)\n"
|
||||
" -v, --verbose log extra debugging information\n"
|
||||
" -V, --version print version information and exit\n"
|
||||
#ifndef _WIN32
|
||||
" -d, --daemonize become a daemon\n"
|
||||
#endif
|
||||
" -b, --blacklist comma-separated list of RPCs to disable (no spaces, \"?\""
|
||||
" to list available RPCs)\n"
|
||||
" -h, --help display this help and exit\n"
|
||||
|
|
@ -143,9 +149,13 @@ static void ga_log(const gchar *domain, GLogLevelFlags level,
|
|||
}
|
||||
|
||||
level &= G_LOG_LEVEL_MASK;
|
||||
#ifndef _WIN32
|
||||
if (domain && strcmp(domain, "syslog") == 0) {
|
||||
syslog(LOG_INFO, "%s: %s", level_str, msg);
|
||||
} else if (level & s->log_level) {
|
||||
#else
|
||||
if (level & s->log_level) {
|
||||
#endif
|
||||
g_get_current_time(&time);
|
||||
fprintf(s->log_file,
|
||||
"%lu.%lu: %s: %s\n", time.tv_sec, time.tv_usec, level_str, msg);
|
||||
|
|
@ -153,6 +163,7 @@ static void ga_log(const gchar *domain, GLogLevelFlags level,
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
static void become_daemon(const char *pidfile)
|
||||
{
|
||||
pid_t pid, sid;
|
||||
|
|
@ -203,6 +214,7 @@ fail:
|
|||
g_critical("failed to daemonize");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int send_response(GAState *s, QObject *payload)
|
||||
{
|
||||
|
|
@ -466,10 +478,12 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
if (daemonize) {
|
||||
g_debug("starting daemon");
|
||||
become_daemon(pidfile);
|
||||
}
|
||||
#endif
|
||||
|
||||
s = g_malloc0(sizeof(GAState));
|
||||
s->log_file = log_file;
|
||||
|
|
@ -482,10 +496,12 @@ int main(int argc, char **argv)
|
|||
ga_command_state_init_all(s->command_state);
|
||||
json_message_parser_init(&s->parser, process_event);
|
||||
ga_state = s;
|
||||
#ifndef _WIN32
|
||||
if (!register_signal_handlers()) {
|
||||
g_critical("failed to register signal handlers");
|
||||
goto out_bad;
|
||||
}
|
||||
#endif
|
||||
|
||||
s->main_loop = g_main_loop_new(NULL, false);
|
||||
if (!channel_init(ga_state, method, path)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue