From patchwork Tue Feb 14 15:15:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 141196 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 618BFB6FD3 for ; Wed, 15 Feb 2012 08:02:39 +1100 (EST) Received: from localhost ([::1]:56292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxPWH-0004o1-Fv for incoming@patchwork.ozlabs.org; Tue, 14 Feb 2012 16:02:37 -0500 Received: from eggs.gnu.org ([140.186.70.92]:51115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxK6w-0001TT-GX for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:16:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxK6o-0005Jc-Bh for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:16:06 -0500 Received: from mail-tul01m020-f173.google.com ([209.85.214.173]:63580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxK6o-0005I2-5j for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:15:58 -0500 Received: by mail-tul01m020-f173.google.com with SMTP id up16so80705obb.4 for ; Tue, 14 Feb 2012 07:15:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=p9KG/1qBwP9Y4QDQ9IOjs4eJHlhJrgZU7gRK14t981U=; b=SVkLJAXBU3cea1onaOcZhkdRuwzF8M/M2gYEHs7SvDJaUVCZKHYrnQ1JRt1MhyTkLu m3T2SzU1u8fIpJsNp9iC4Xu+O8XeT6GScV90TMeLZyZlsTU03wUOgfFu55cfdlt2CQWz ZpLG/ySp3LgDiTNiGp5N/b/OzfcmMH/jRKUEs= Received: by 10.182.44.10 with SMTP id a10mr4471041obm.43.1329232557941; Tue, 14 Feb 2012 07:15:57 -0800 (PST) Received: from localhost.localdomain ([108.224.40.39]) by mx.google.com with ESMTPS id y3sm5373891obx.4.2012.02.14.07.15.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Feb 2012 07:15:57 -0800 (PST) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 14 Feb 2012 09:15:39 -0600 Message-Id: <1329232542-30251-6-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1329232542-30251-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1329232542-30251-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.173 Cc: ghammer@redhat.com, aliguori@us.ibm.com, matsudadik@intellilink.co.jp, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH v3 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 e66e885..2d9ebdc 100644 --- a/Makefile +++ b/Makefile @@ -201,7 +201,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 a6297d2..5f05afd 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -422,12 +422,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 763db24..4b0ce71 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 #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) +{ +}