
I got about 95% of the way towards compiling on MinGW using the MinGW cross-compiler from http://mirzam.it.vu.nl/mingw/. Attached are some fairly non-controversial patches which fix some of the problems I found. Build notes follow below. Rich. ---------------------------------------------------------------------- Install the MinGW cross-compiler. Compile and install the following packages: (1) libgpg-error (2) libgcrypt (3) gnutls (4) libxml2 (5) PortableXDR I'm building into a local area. Most of them will compile straight with: CFLAGS="-I$HOME/win32/include" \ LDFLAGS="-L$HOME/win32/lib" \ ./configure --host=i386-mingw32 --prefix=$HOME/win32 make make install GnuTLS (3) is troublesome. I ended up using version 1.6.3, upgrading the gnulib packages in the gl/ subdirectory, and doing a bit of bug-fixing on the Makefile.am files (mainly just making sure my custom LDFLAGS gets through everywhere). Then build libvirt + attached patch: PKG_CONFIG_PATH=$HOME/win32/lib/pkgconfig \ CFLAGS="-I$HOME/win32/include" \ LDFLAGS="-L$HOME/win32/lib" \ ./configure --host=i386-mingw32 --prefix=$HOME/win32 \ --without-xen --without-qemu --without-libvirtd \ --without-sasl --without-python make [Currently it fails when linking virsh because of the usual weirdness in libtool] -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

On Thu, Apr 17, 2008 at 08:04:59PM +0100, Richard W.M. Jones wrote:
I got about 95% of the way towards compiling on MinGW using the MinGW cross-compiler from http://mirzam.it.vu.nl/mingw/. Attached are some fairly non-controversial patches which fix some of the problems I found. Build notes follow below.
This all looks reasonable to me. Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Thu, Apr 17, 2008 at 08:04:59PM +0100, Richard W.M. Jones wrote:
I got about 95% of the way towards compiling on MinGW using the MinGW cross-compiler from http://mirzam.it.vu.nl/mingw/. Attached are some fairly non-controversial patches which fix some of the problems I found. Build notes follow below.
Fine by me. +1 For the pthread stuff, it's a shame we really went though all of that in libxml2, too bad we can't reuse it. For the doc, IMHO add a win32 directory and put what you have there in a mingw directory, people will find it more easilly than when looking up in doc/ or on the web (doesn't prevent adding it there too :-) thanks ! Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

"Richard W.M. Jones" <rjones@redhat.com> wrote:
I got about 95% of the way towards compiling on MinGW using the MinGW cross-compiler from http://mirzam.it.vu.nl/mingw/. Attached are some fairly non-controversial patches which fix some of the problems I found. Build notes follow below. ... Index: src/hash.c =================================================================== RCS file: /data/cvs/libvirt/src/hash.c,v retrieving revision 1.36 diff -u -r1.36 hash.c --- src/hash.c 10 Apr 2008 16:53:29 -0000 1.36 +++ src/hash.c 17 Apr 2008 18:55:16 -0000 @@ -25,7 +25,10 @@ #include <libxml/threads.h> #include "internal.h" #include "hash.h" + +#if HAVE_PTHREAD_H #include <pthread.h> +#endif
Hi Rich, Looks good. You might want to define-away the pthread_* functions instead. With definitions something like this (untested) you can remove all of those in-function #if directives. #if HAVE_PTHREAD_H # include <pthread.h> #else # define pthread_mutex_init(a, b) /* empty */ # define pthread_mutex_lock(a) /* empty */ # define pthread_mutex_unlock(a) /* empty */ # define pthread_mutex_destroy(a) /* empty */ #endif
#define MAX_HASH_LEN 8
@@ -713,7 +716,9 @@ if (ret->storageVols == NULL) goto failed;
+#if HAVE_LIBPTHREAD pthread_mutex_init(&ret->lock, NULL); +#endif
ret->refs = 1; return(ret); @@ -729,7 +734,9 @@ if (ret->storageVols != NULL) virHashFree(ret->storageVols, (virHashDeallocator) virStorageVolFreeName);
+#if HAVE_LIBPTHREAD pthread_mutex_destroy(&ret->lock); +#endif free(ret); } return(NULL); @@ -762,8 +769,10 @@
free(conn->name);
+#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); pthread_mutex_destroy(&conn->lock); +#endif free(conn); }
@@ -784,7 +793,9 @@ virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(-1); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&conn->lock); +#endif DEBUG("unref connection %p %s %d", conn, conn->name, conn->refs); conn->refs--; refs = conn->refs; @@ -793,7 +804,9 @@ /* Already unlocked mutex */ return (0); } +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif return (refs); }
@@ -818,7 +831,9 @@ virHashError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__); return(NULL); } +#if HAVE_LIBPTHREAD pthread_mutex_lock(&conn->lock); +#endif
/* TODO search by UUID first as they are better differenciators */
@@ -849,11 +864,15 @@ conn->refs++; } ret->refs++; +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif return(ret);
error: +#if HAVE_LIBPTHREAD pthread_mutex_unlock(&conn->lock); +#endif
...

Hi, Rich I have 2 questions about MinGW fixes. (It has already committed, sorry for delaying) 1)src/storage_driver.c patch I think storage_driver.c is not compiled on MinGW. So It should remove HAVE_PWD_H in src/storage_driver.c http://git.et.redhat.com/?p=libvirt.git;a=blobdiff;f=src/storage_driver.c;h=... 2)src/util.c patch I think sys/wait.h(waitpid) has not supported on MinGW. So I think it should add check (HAVE_SYS_WAIT_H) on waitpid() to avoid compilation warnings. How do you think? Thanks Atsushi SAKAI "Richard W.M. Jones" <rjones@redhat.com> wrote:
I got about 95% of the way towards compiling on MinGW using the MinGW cross-compiler from http://mirzam.it.vu.nl/mingw/. Attached are some fairly non-controversial patches which fix some of the problems I found. Build notes follow below.
Rich.

On Mon, Apr 21, 2008 at 03:56:39PM +0900, Atsushi SAKAI wrote:
Hi, Rich
I have 2 questions about MinGW fixes. (It has already committed, sorry for delaying)
1)src/storage_driver.c patch I think storage_driver.c is not compiled on MinGW. So It should remove HAVE_PWD_H in src/storage_driver.c
Sure, but I left this one in because there may be other platforms which lack <pwd.h> which would need this. In theory every header of this type should be defended with #ifdef .. #endif
2)src/util.c patch I think sys/wait.h(waitpid) has not supported on MinGW. So I think it should add check (HAVE_SYS_WAIT_H) on waitpid() to avoid compilation warnings.
OK thanks. This compiles for me, but I agree that if a version of MinGW doesn't support waitpid we should either find an alternate way or find some way to comment that out. Do you have any suggested Windows/MinGW patches? FWIW it looks like I'm going to use the cross-compiler approach to build libvirt for Windows in future because I don't have the time or energy to maintain a running copy of Windows itself. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

Hi, Rich "Richard W.M. Jones" <rjones@redhat.com> wrote:
2)src/util.c patch I think sys/wait.h(waitpid) has not supported on MinGW. So I think it should add check (HAVE_SYS_WAIT_H) on waitpid() to avoid compilation warnings.
OK thanks. This compiles for me, but I agree that if a version of MinGW doesn't support waitpid we should either find an alternate way or find some way to comment that out. Do you have any suggested Windows/MinGW patches?
I think following patch seems good (but not tested yet by me.) http://cvsweb.xfree86.org/cvsweb/cvs/windows-NT/waitpid.c?rev=HEAD
FWIW it looks like I'm going to use the cross-compiler approach to build libvirt for Windows in future because I don't have the time or energy to maintain a running copy of Windows itself.
I also hope to unite the development environment. Thanks Atsushi SAKAI

On Mon, Apr 21, 2008 at 07:28:29PM +0900, Atsushi SAKAI wrote:
I think following patch seems good (but not tested yet by me.) http://cvsweb.xfree86.org/cvsweb/cvs/windows-NT/waitpid.c?rev=HEAD
Yes, that looks good. Gnulib actually contains a "wait-process" module which basically implements that in the same way (using _cwait on Win32[1]): http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/wait-process.c;h=97b... Rich. [1] http://msdn2.microsoft.com/en-us/library/zb9ehy71(VS.80).aspx -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
participants (5)
-
Atsushi SAKAI
-
Daniel P. Berrange
-
Daniel Veillard
-
Jim Meyering
-
Richard W.M. Jones