[Libguestfs] Notes: Building the daemon on Windows

Richard W.M. Jones rjones at redhat.com
Wed Nov 25 17:30:32 UTC 2009


My aim is to get to the stage where we can start the daemon and run it
under Wine.  By using a dummy QEMU wrapper[1] we can have the daemon
be run from a real Linux libguestfs program.  It'll be running on the
same machine (not in an appliance) and it'll be running under Wine,
not Windows, but that's good enough to start testing the XDR protocol
and some simple commands.

It's very close to being able to do that now - there are only a few
minor fixes left.

If you want to try this, you will need the latest libguestfs sources
from git, plus the three attached patches which hack out bits that
I've not fixed yet.

You'll need the basic Fedora MinGW cross-compiler packages installed,
and the Fedora package "wine(x86-32)".

You'll need to build and install PortableXDR:

http://git.annexia.org/?p=fedora-mingw.git;a=tree;f=portablexdr;hb=HEAD

Configure the toplevel of libguestfs source as if you were going
to build it for Fedora.

The go into the daemon subdirectory and reconfigure it for
cross-compilation:

  cd daemon
  make distclean
  mingw32-configure
  make

That will get you 99% of the way there.  There are still some bits to
hack out and/or fix in order to get a daemon.

Rich.

[1] http://libguestfs.org/guestfs.3.html#qemu_wrappers

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
-------------- next part --------------
>From db4c43600fbfe541287a6f8b798d878ce94fcd27 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Fri, 20 Nov 2009 12:18:36 +0000
Subject: [PATCH 1/3] LOCAL: REMOVE PRINTF FORMATTER TEST

---
 daemon/configure.ac |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/daemon/configure.ac b/daemon/configure.ac
index bd0bdbe..aa0dc5c 100644
--- a/daemon/configure.ac
+++ b/daemon/configure.ac
@@ -195,19 +195,19 @@ AC_CHECK_HEADERS([\
 
 dnl For modified printf, we need glibc either (old-style)
 dnl register_printf_function or (new-style) register_printf_specifier.
-AC_CHECK_FUNC([register_printf_specifier],[
-        AC_DEFINE([HAVE_REGISTER_PRINTF_SPECIFIER],[1],
-                [Define to 1 if you have new-style register_printf_specifier])
-        ],[
-        AC_CHECK_FUNC([register_printf_function],[
-                AC_DEFINE([HAVE_REGISTER_PRINTF_FUNCTION],[1],
-                        [Define to 1 if you have old-style register_printf_function])
-                ],[
-                AC_MSG_FAILURE(
-[No support for glibc-style extended printf formatters.
-
-This means you either have a very old glibc (pre-2.0) or you
-are using some other libc where this is not supported.])])])
+dnl AC_CHECK_FUNC([register_printf_specifier],[
+dnl         AC_DEFINE([HAVE_REGISTER_PRINTF_SPECIFIER],[1],
+dnl                 [Define to 1 if you have new-style register_printf_specifier])
+dnl         ],[
+dnl         AC_CHECK_FUNC([register_printf_function],[
+dnl                 AC_DEFINE([HAVE_REGISTER_PRINTF_FUNCTION],[1],
+dnl                         [Define to 1 if you have old-style register_printf_function])
+dnl                 ],[
+dnl                 AC_MSG_FAILURE(
+dnl [No support for glibc-style extended printf formatters.
+dnl 
+dnl This means you either have a very old glibc (pre-2.0) or you
+dnl are using some other libc where this is not supported.])])])
 
 dnl Produce output files.
 AC_CONFIG_HEADERS([config.h])
-- 
1.6.5.2

-------------- next part --------------
>From 9dced74b24ea0385fb84d84ef2814abaa56bf45a Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Wed, 25 Nov 2009 16:33:17 +0000
Subject: [PATCH 2/3] LOCAL: DISABLE COMMAND

---
 daemon/guestfsd.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 9691053..3af0baa 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -677,6 +677,7 @@ int
 commandrvf (char **stdoutput, char **stderror, int flags,
             char const* const *argv)
 {
+#ifndef WIN32
   int so_size = 0, se_size = 0;
   int so_fd[2], se_fd[2];
   pid_t pid;
@@ -838,6 +839,10 @@ commandrvf (char **stdoutput, char **stderror, int flags,
     return WEXITSTATUS (r);
   } else
     return -1;
+#else
+  fprintf (stderr, "commandrvf: We would execute %s here, but this isn't yet implemented on Win32\n", argv[0]);
+  return -1;
+#endif
 }
 
 /* Split an output string into a NULL-terminated list of lines.
-- 
1.6.5.2

-------------- next part --------------
>From 4d80e57b9f4e3b1292a00c6753363a5d6cec60f1 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Wed, 25 Nov 2009 16:35:22 +0000
Subject: [PATCH 3/3] LOCAL: DISABLE PRINTF FORMATTERS

---
 daemon/guestfsd.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 3af0baa..9f9d5df 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -66,6 +66,7 @@ static char *read_cmdline (void);
 
 int verbose = 0;
 
+#ifndef WIN32
 static int print_shell_quote (FILE *stream, const struct printf_info *info, const void *const *args);
 static int print_sysroot_shell_quote (FILE *stream, const struct printf_info *info, const void *const *args);
 #ifdef HAVE_REGISTER_PRINTF_SPECIFIER
@@ -77,6 +78,7 @@ static int print_arginfo (const struct printf_info *info, size_t n, int *argtype
 #error "HAVE_REGISTER_PRINTF_{SPECIFIER|FUNCTION} not defined"
 #endif
 #endif
+#endif
 
 /* Location to mount root device. */
 const char *sysroot = "/sysroot"; /* No trailing slash. */
@@ -105,6 +107,7 @@ main (int argc, char *argv[])
   char *cmdline;
   char *vmchannel = NULL;
 
+#ifndef WIN32
 #ifdef HAVE_REGISTER_PRINTF_SPECIFIER
   /* http://udrepper.livejournal.com/20948.html */
   register_printf_specifier ('Q', print_shell_quote, print_arginfo);
@@ -117,6 +120,7 @@ main (int argc, char *argv[])
 #error "HAVE_REGISTER_PRINTF_{SPECIFIER|FUNCTION} not defined"
 #endif
 #endif
+#endif
 
   for (;;) {
     c = getopt_long (argc, argv, options, long_options, NULL);
@@ -899,6 +903,7 @@ split_lines (char *str)
   return lines;
 }
 
+#ifndef WIN32
 /* printf helper function so we can use %Q ("quoted") and %R to print
  * shell-quoted strings.  See HACKING file for more details.
  */
@@ -957,6 +962,7 @@ print_arginfo (const struct printf_info *info, size_t n, int *argtypes)
 #error "HAVE_REGISTER_PRINTF_{SPECIFIER|FUNCTION} not defined"
 #endif
 #endif
+#endif
 
 /* Perform device name translation.  Don't call this directly -
  * use the RESOLVE_DEVICE macro.
-- 
1.6.5.2



More information about the Libguestfs mailing list