From patchwork Thu Feb 2 19:58:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 139214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5D016104785 for ; Fri, 3 Feb 2012 07:41:52 +1100 (EST) Received: from localhost ([::1]:54308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt2q6-0004Ku-J2 for incoming@patchwork.ozlabs.org; Thu, 02 Feb 2012 15:01:02 -0500 Received: from eggs.gnu.org ([140.186.70.92]:36858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt2pV-0003NP-IZ for qemu-devel@nongnu.org; Thu, 02 Feb 2012 15:00:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rt2pI-0002RS-AU for qemu-devel@nongnu.org; Thu, 02 Feb 2012 15:00:19 -0500 Received: from mout.perfora.net ([74.208.4.195]:55207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rt2pI-0002Qj-3C for qemu-devel@nongnu.org; Thu, 02 Feb 2012 15:00:12 -0500 Received: from illuin.austin.ibm.com ([32.97.110.59]) by mrelay.perfora.net (node=mrus0) with ESMTP (Nemesis) id 0Mg52j-1SGMzi3bSH-00NVaj; Thu, 02 Feb 2012 15:00:05 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2012 13:58:57 -0600 Message-Id: <1328212740-15799-6-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1328212740-15799-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1328212740-15799-1-git-send-email-mdroth@linux.vnet.ibm.com> X-Provags-ID: V02:K0:/JYqUYa1JFrzmo2vejalAlXPkqhcfjJul0miNK48UIS wfEOWNct9/b0R/vLLx5uA6wNpvoTc+Sxxt9Te9te7cSSXNF93Q b2MrfZTb3P2D6dRqPAHJLfpCbH3LrXI+8RcS3OnRIF27T2idc1 b8mMMu8abWmwUYgdiziICK2RxVLWCw5m5Tw5KukPNnfxXmrOH1 Amfw5wdpheXqCviMkui3b4jietAtjKCesaL+ZAz1Jtq6fefKOH RJLEST+OY6KcEz6bVWRbFLYR+v7BNnrMYLPvXVcGNFJF3fX1f3 yxqD8AzpRl8oOKKC0WauiQW1RqYry5sZI9OLNQfBGKnHXMg9Wj t1LPJH0MBFZ7GMebI8OKJJpfhENYUPoLV/2yv5f4G+o275pG3P 87G/R6OC/HwvqZgVMjKFfzQzk9tsAJqLUM= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.208.4.195 Cc: ghammer@redhat.com, aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v2 5/8] qemu-ga: fixes for win32 build of qemu-ga X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 2560b59..9baa532 100644 --- a/Makefile +++ b/Makefile @@ -199,7 +199,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 2e2efb4..18e79ce 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 3b0b300..aaf8171 100755 --- a/configure +++ b/configure @@ -508,7 +508,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 #include #include +#ifndef _WIN32 #include +#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 + * + * 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 +#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) +{ +}