qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 5/8] qemu-ga: fixes for win32 build of qemu-ga


From: Michael Roth
Subject: [Qemu-devel] [PATCH 5/8] qemu-ga: fixes for win32 build of qemu-ga
Date: Thu, 23 Feb 2012 16:10:52 -0600

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.

Signed-off-by: Michael Roth <address@hidden>
---
 Makefile             |    2 +-
 Makefile.objs        |    9 +++--
 configure            |    2 +-
 qemu-ga.c            |   16 +++++++++
 qga/commands-win32.c |   91 ++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 114 insertions(+), 6 deletions(-)
 create mode 100644 qga/commands-win32.c

diff --git a/Makefile b/Makefile
index c67493e..ad1e627 100644
--- a/Makefile
+++ b/Makefile
@@ -202,7 +202,7 @@ QGALIB_GEN=$(addprefix $(qapi-dir)/, qga-qapi-types.h 
qga-qapi-visit.h qga-qmp-c
 $(QGALIB_OBJ): $(QGALIB_GEN) $(GENERATED_HEADERS)
 $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) $(GENERATED_HEADERS)
 
-qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(qapi-obj-y) $(tools-obj-y) 
$(qobject-obj-y) $(version-obj-y) $(QGALIB_OBJ)
+qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(tools-obj-y) $(qapi-obj-y) 
$(qobject-obj-y) $(version-obj-y) $(QGALIB_OBJ)
 
 QEMULIBS=libhw32 libhw64 libuser libdis libdis-user
 
diff --git a/Makefile.objs b/Makefile.objs
index 6ce8a1d..39c7f4e 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -424,12 +424,13 @@ common-obj-y += qmp.o hmp.o
 ######################################################################
 # guest agent
 
-qga-nested-y = commands.o commands-posix.o guest-agent-command-state.o
-qga-nested-y += channel-posix.o
+qga-nested-y = commands.o guest-agent-command-state.o
+qga-nested-$(CONFIG_POSIX) += commands-posix.o channel-posix.o
+qga-nested-$(CONFIG_WIN32) += commands-win32.o
 qga-obj-y = $(addprefix qga/, $(qga-nested-y))
-qga-obj-y += qemu-ga.o qemu-sockets.o module.o qemu-option.o
+qga-obj-y += qemu-ga.o module.o
 qga-obj-$(CONFIG_WIN32) += oslib-win32.o
-qga-obj-$(CONFIG_POSIX) += oslib-posix.o
+qga-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-sockets.o qemu-option.o
 
 vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
diff --git a/configure b/configure
index 037f7f7..a1f4a6b 100755
--- a/configure
+++ b/configure
@@ -509,7 +509,7 @@ if test "$mingw32" = "yes" ; then
   bindir="\${prefix}"
   sysconfdir="\${prefix}"
   confsuffix=""
-  guest_agent="no"
+  libs_qga="-lws2_32 -lwinmm $lib_qga"
 fi
 
 werror=""
diff --git a/qemu-ga.c b/qemu-ga.c
index 2e8af02..93ebc3e 100644
--- a/qemu-ga.c
+++ b/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)) {
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
new file mode 100644
index 0000000..d96f1ad
--- /dev/null
+++ b/qga/commands-win32.c
@@ -0,0 +1,91 @@
+/*
+ * QEMU Guest Agent win32-specific command implementations
+ *
+ * Copyright IBM Corp. 2012
+ *
+ * Authors:
+ *  Michael Roth      <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <glib.h>
+#include "qga/guest-agent-core.h"
+#include "qga-qmp-commands.h"
+#include "qerror.h"
+
+void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+}
+
+int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, 
Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return 0;
+}
+
+void qmp_guest_file_close(int64_t handle, Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+}
+
+GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
+                                   int64_t count, Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return 0;
+}
+
+GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64,
+                                     bool has_count, int64_t count, Error 
**err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return 0;
+}
+
+GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset,
+                                   int64_t whence, Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return 0;
+}
+
+void qmp_guest_file_flush(int64_t handle, Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+}
+
+/*
+ * Return status of freeze/thaw
+ */
+GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return 0;
+}
+
+/*
+ * Walk list of mounted file systems in the guest, and freeze the ones which
+ * are real local file systems.
+ */
+int64_t qmp_guest_fsfreeze_freeze(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return 0;
+}
+
+/*
+ * Walk list of frozen file systems in the guest, and thaw them.
+ */
+int64_t qmp_guest_fsfreeze_thaw(Error **err)
+{
+    error_set(err, QERR_UNSUPPORTED);
+    return 0;
+}
+
+/* register init/cleanup routines for stateful command groups */
+void ga_command_state_init(GAState *s, GACommandState *cs)
+{
+}
-- 
1.7.4.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]