]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fully support mingw builds
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 5 Sep 2008 12:03:45 +0000 (12:03 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 5 Sep 2008 12:03:45 +0000 (12:03 +0000)
14 files changed:
.cvsignore
ChangeLog
Makefile.am
autobuild.sh
configure.in
mingw-libvirt.spec.in [new file with mode: 0644]
qemud/remote_protocol.c
qemud/remote_protocol.h
qemud/remote_protocol.x
src/Makefile.am
src/storage_backend.c
src/storage_conf.c
src/util.c
src/util.h

index cea0b0bf81a970fbdf5af78ab2db5ee6132259d6..5e055a6ad9ebd7785fc15f41d49102566d93f515 100644 (file)
@@ -20,6 +20,7 @@ ltconfig
 update.log
 libvirt.pc
 libvirt.spec
+mingw-libvirt.spec
 COPYING
 m4
 ABOUT-NLS
index 10c660120f0caf6097d3d0f62c2e49e657d716de..f82548c2b152b1f4d5bdc140c675184ba4dbabf1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+Fri Sep  5 13:02:26 BST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+       Fully support mingw builds
+       * .cvsignore: Ignore mingw-libvirt.spec
+       * autobuild.sh: Perform mingw build if toolchain is available
+       * Makefile.am: Add mingw-libvirt.spec to EXTRA_DIST
+       * configure.in: Add check for getuid/getgit. Add gettext()
+       check against libintl. Disable storage drivers if libvirtd
+       is disabled
+       * mingw-libvirt.spec.in: Specfile for mingw cross compile
+       * qemud/remote_protocol.{c,x,h}: Add socketcompat.h include
+       for htons() methods
+       * src/Makefile.am: Don't wrap storage driver conditionals in
+       a  libvirtd conditional
+       * src/storage_backend.c: Add no-op implementations of
+       virStorageBackendRunProgRegex and virStorageBackendRunProgNul
+       functions for mingw
+       * src/storage_conf.c: Fix typo in getgid() call. Avoid
+       not-literal in format string.
+       * src/util.c: Fix signature of virExec() for mingw build
+       * src/util.h: Add stub impl of getuid/getgid calls
+
 Fri Sep  5 12:50:26 BST 2008 Daniel P. Berrange <berrange@redhat.com>
 
        Fix starting of Xen domains without PVFB console, by not
index b5082d6a7eaf7c746c3e52d61f6eb952df79db42..f7ffccbda2d55e8a98fdd6dac2e82ad107cf53d9 100644 (file)
@@ -10,6 +10,7 @@ ACLOCAL_AMFLAGS = -I m4 -I gnulib/m4
 
 EXTRA_DIST = \
   libvirt.spec libvirt.spec.in \
+  mingw-libvirt.spec mingw-libvirt.spec.in \
   libvirt.pc libvirt.pc.in \
   $(man_MANS) autobuild.sh \
   .x-sc_avoid_if_before_free \
index 2fbecea8892dee52f0b85432369b274aa69d4345..50b4e0ce79ea03ff572f10ee28ac9f6c1da3d463 100755 (executable)
@@ -17,8 +17,6 @@ rm -rf coverage
 ./autogen.sh --prefix="$AUTOBUILD_INSTALL_ROOT" \
   --enable-test-coverage \
   --enable-compile-warnings=error \
-  --with-openvz \
-  --with-lxc \
   --with-xen-proxy
 
 # If the MAKEFLAGS envvar does not yet include a -j option,
@@ -51,5 +49,40 @@ if [ -f /usr/bin/rpmbuild ]; then
     NOW=`date +"%s"`
     EXTRA_RELEASE=".$USER$NOW"
   fi
-  rpmbuild --nodeps --define "extra_release $EXTRA_RELEASE" -ta --clean *.tar.gz
+
+  rpmbuild --nodeps \
+     --define "extra_release $EXTRA_RELEASE" \
+     --define "_sourcedir `pwd`" \
+     -ba --clean libvirt.spec
+fi
+
+if [ -x /usr/bin/i686-pc-mingw32-gcc ]; then
+  make distclean
+
+  PKG_CONFIG_PATH="$AUTOBUILD_INSTALL_ROOT/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig" \
+  CC="i686-pc-mingw32-gcc" \
+  ./configure \
+    --build=$(uname -m)-pc-linux \
+    --host=i686-pc-mingw32 \
+    --prefix="$AUTOBUILD_INSTALL_ROOT/i686-pc-mingw32/sys-root/mingw" \
+    --without-sasl \
+    --without-avahi \
+    --without-polkit \
+    --without-python \
+    --without-xen \
+    --without-qemu \
+    --without-lxc \
+    --without-openvz \
+    --without-libvirtd
+
+  make
+  make install
+
+  #set -o pipefail
+  #make check 2>&1 | tee "$RESULTS"
+
+  rpmbuild --nodeps \
+     --define "extra_release $EXTRA_RELEASE" \
+     --define "_sourcedir `pwd`" \
+     -ba --clean mingw-libvirt.spec
 fi
index e057f1c099c97aa9d658da7763c4dfda93487f47..6b4521be09f056cbaf8f93e4174eb02b6680097d 100644 (file)
@@ -65,10 +65,10 @@ dnl Use --disable-largefile if you don't want this.
 AC_SYS_LARGEFILE
 
 dnl Availability of various common functions (non-fatal if missing).
-AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity])
+AC_CHECK_FUNCS([cfmakeraw regexec uname sched_getaffinity getuid getgid])
 
 dnl Availability of various common headers (non-fatal if missing).
-AC_CHECK_HEADERS([pwd.h paths.h sys/syslimits.h sys/utsname.h sys/wait.h winsock2.h sched.h termios.h])
+AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h sys/utsname.h sys/wait.h winsock2.h sched.h termios.h])
 
 dnl Where are the XDR functions?
 dnl If portablexdr is installed, prefer that.
@@ -77,6 +77,8 @@ AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
        AC_SEARCH_LIBS([xdrmem_create],[rpc xdr])
        ])
 
+AC_CHECK_LIB([intl],[gettext],[])
+
 dnl Do we have rpcgen?
 AC_PATH_PROG([RPCGEN], [rpcgen], [no])
 AM_CONDITIONAL([RPCGEN], [test "x$ac_cv_path_RPCGEN" != "xno"])
@@ -649,6 +651,20 @@ AC_ARG_WITH([storage-iscsi],
 AC_ARG_WITH([storage-disk],
 [  --with-storage-disk         with GPartd Disk backend for the storage driver (on)],[],[with_storage_disk=check])
 
+with_storage_dir=yes
+if test "$with_libvirtd" = "no"; then
+  with_storage_dir=no
+  with_storage_fs=no
+  with_storage_lvm=no
+  with_storage_iscsi=no
+  with_storage_disk=no
+fi
+if test "$with_storage_dir" = "yes" ; then
+  AC_DEFINE_UNQUOTED([WITH_STORAGE_DIR], 1, [whether directory backend for storage driver is enabled])
+fi
+AM_CONDITIONAL([WITH_STORAGE_DIR], [test "$with_storage_dir" = "yes"])
+
+
 if test "$with_storage_fs" = "yes" -o "$with_storage_fs" = "check"; then
   AC_PATH_PROG([MOUNT], [mount], [], [$PATH:/sbin:/usr/sbin])
   AC_PATH_PROG([UMOUNT], [umount], [], [$PATH:/sbin:/usr/sbin])
@@ -1024,7 +1040,7 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
          docs/examples/python/Makefile \
          gnulib/lib/Makefile \
          gnulib/tests/Makefile \
-          libvirt.pc libvirt.spec \
+          libvirt.pc libvirt.spec mingw-libvirt.spec \
           po/Makefile.in \
          include/libvirt/Makefile include/libvirt/libvirt.h \
          python/Makefile python/tests/Makefile \
@@ -1053,7 +1069,7 @@ AC_MSG_NOTICE([Libvirtd: $with_libvirtd])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Storage Drivers])
 AC_MSG_NOTICE([])
-AC_MSG_NOTICE([     Dir: yes])
+AC_MSG_NOTICE([     Dir: $with_storage_dir])
 AC_MSG_NOTICE([      FS: $with_storage_fs])
 AC_MSG_NOTICE([   NetFS: $with_storage_fs])
 AC_MSG_NOTICE([     LVM: $with_storage_lvm])
diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
new file mode 100644 (file)
index 0000000..d6f91b9
--- /dev/null
@@ -0,0 +1,87 @@
+%include        /usr/lib/rpm/mingw-defs
+
+Name:           mingw-libvirt
+Version:        @VERSION@
+Release:        1%{?dist}%{?extra_release}
+Summary:        MinGW Windows libvirt virtualization library
+
+License:        LGPLv2+
+Group:          Development/Libraries
+URL:            http://www.libvirt.org/
+Source0:        ftp://libvirt.org/libvirt/libvirt-%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires:  mingw-filesystem >= 19
+BuildRequires:  mingw-gcc
+BuildRequires:  mingw-binutils
+BuildRequires:  mingw-libgpg-error
+BuildRequires:  mingw-libgcrypt
+BuildRequires:  mingw-gnutls
+BuildRequires:  mingw-gettext
+BuildRequires:  mingw-libxml2
+BuildRequires:  mingw-portablexdr
+
+%description
+MinGW Windows libvirt virtualization library.
+
+
+%prep
+%setup -q -n libvirt-%{version}
+
+
+%build
+# XXX enable SASL in future
+PKG_CONFIG_PATH="%{_prefix}/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig" \
+CC="i686-pc-mingw32-gcc" \
+CFLAGS="-O2 -g -Wall -pipe" \
+./configure \
+  --build=%_build \
+  --host=i686-pc-mingw32 \
+  --prefix=%{_prefix}/i686-pc-mingw32/sys-root/mingw \
+  --without-sasl \
+  --without-avahi \
+  --without-polkit \
+  --without-python \
+  --without-xen \
+  --without-qemu \
+  --without-lxc \
+  --without-openvz \
+  --without-libvirtd
+make
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+make DESTDIR=$RPM_BUILD_ROOT install
+
+rm -rf $RPM_BUILD_ROOT/%{_mingw_sysconfdir}/libvirt
+rm -rf $RPM_BUILD_ROOT/%{_mingw_datadir}/doc/*
+rm -rf $RPM_BUILD_ROOT/%{_mingw_datadir}/gtk-doc/*
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root)
+%{_mingw_bindir}/libvirt-0.dll
+%{_mingw_bindir}/virsh.exe
+
+%{_mingw_libdir}/libvirt.a
+%{_mingw_libdir}/libvirt.dll.a
+%{_mingw_libdir}/libvirt.la
+%{_mingw_libdir}/pkgconfig/libvirt.pc
+
+%{_mingw_datadir}/locale/*/LC_MESSAGES/libvirt.mo
+
+%dir %{_mingw_includedir}/libvirt
+%{_mingw_includedir}/libvirt/libvirt.h
+%{_mingw_includedir}/libvirt/virterror.h
+
+%{_mingw_mandir}/man1/virsh.1*
+
+
+%changelog
+* Tue Sep  2 2008 Daniel P. Berrange <berrange@redhat.com> - 0.4.4-1
+- Initial RPM release, largely based on earlier work from several sources.
index ea9a160565f041efaef7395184857c348aa591da..be1d6d8180f48fb41aa64d79d0c083e0d101c492 100644 (file)
@@ -6,6 +6,7 @@
 #include "remote_protocol.h"
 #include <config.h>
 #include "internal.h"
+#include "socketcompat.h"
 
 bool_t
 xdr_remote_nonnull_string (XDR *xdrs, remote_nonnull_string *objp)
index e4b1487cb91b79067bfd7ab23abfbcdca1587382..bcaa219308ec16cf2b930cb710f2730c02dc89bc 100644 (file)
@@ -15,6 +15,7 @@ extern "C" {
 
 #include <config.h>
 #include "internal.h"
+#include "socketcompat.h"
 #define REMOTE_MESSAGE_MAX 262144
 #define REMOTE_STRING_MAX 65536
 
index 148fbd58073614b8899f52cb84fe41ba984e21a4..f848ae51243d0e8dc26f61840b3ad104b9dfbd22 100644 (file)
@@ -38,6 +38,7 @@
 
 %#include <config.h>
 %#include "internal.h"
+%#include "socketcompat.h"
 
 /*----- Data types. -----*/
 
index 2d06c8514bed485bae8141dfb0b330486aaa4adc..98453327a59a99bfe9d7c2a9a238dd0a2cfc7b0d 100644 (file)
@@ -58,7 +58,8 @@ NETWORK_CONF_SOURCES =                                                \
 
 # Storage driver generic impl APIs
 STORAGE_CONF_SOURCES =                                         \
-               storage_conf.h storage_conf.c
+               storage_conf.h storage_conf.c                   \
+               storage_backend.h storage_backend.c
 
 
 # The remote RPC driver, covering domains, storage, networks, etc
@@ -109,8 +110,7 @@ QEMU_DRIVER_SOURCES =                                               \
 
 # And finally storage backend specific impls
 STORAGE_DRIVER_SOURCES =                                       \
-               storage_driver.h storage_driver.c               \
-               storage_backend.h storage_backend.c
+               storage_driver.h storage_driver.c
 
 STORAGE_DRIVER_FS_SOURCES =                                    \
                storage_backend_fs.h storage_backend_fs.c
index ff6527e32f1a543c0c5347595ce684a092a69ed4..9cda7177a941e8f099d012a21ea63525f945f738 100644 (file)
 #include <config.h>
 
 #include <string.h>
+#if HAVE_REGEX_H
 #include <regex.h>
+#endif
 #include <sys/types.h>
+#if HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdint.h>
 #endif
 
 #include "internal.h"
+#include "util.h"
+#include "memory.h"
+
+#include "storage_backend.h"
 
 #if WITH_STORAGE_LVM
 #include "storage_backend_logical.h"
 #if WITH_STORAGE_DISK
 #include "storage_backend_disk.h"
 #endif
-
-#include "util.h"
-#include "memory.h"
-
-#include "storage_backend.h"
+#if WITH_STORAGE_DIR
 #include "storage_backend_fs.h"
+#endif
 
 static virStorageBackendPtr backends[] = {
+#if WITH_STORAGE_DIR
     &virStorageBackendDirectory,
+#endif
 #if WITH_STORAGE_FS
     &virStorageBackendFileSystem,
     &virStorageBackendNetFileSystem,
@@ -209,8 +216,12 @@ virStorageBackendUpdateVolInfoFD(virConnectPtr conn,
         return -2;
 
     if (S_ISREG(sb.st_mode)) {
+#ifndef __MINGW32__
         vol->allocation = (unsigned long long)sb.st_blocks *
             (unsigned long long)sb.st_blksize;
+#else
+        vol->allocation = sb.st_size;
+#endif
         /* Regular files may be sparse, so logical size (capacity) is not same
          * as actual allocation above
          */
@@ -337,6 +348,8 @@ virStorageBackendStablePath(virConnectPtr conn,
     return devpath;
 }
 
+
+#ifndef __MINGW32__
 /*
  * Run an external program.
  *
@@ -620,3 +633,33 @@ virStorageBackendRunProgNul(virConnectPtr conn,
 
     return 0;
 }
+
+#else
+
+int
+virStorageBackendRunProgRegex(virConnectPtr conn,
+                              virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                              const char *const*prog ATTRIBUTE_UNUSED,
+                              int nregex ATTRIBUTE_UNUSED,
+                              const char **regex ATTRIBUTE_UNUSED,
+                              int *nvars ATTRIBUTE_UNUSED,
+                              virStorageBackendListVolRegexFunc func ATTRIBUTE_UNUSED,
+                              void *data ATTRIBUTE_UNUSED,
+                              int *outexit ATTRIBUTE_UNUSED)
+{
+    virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("%s not implemented on Win32"), __FUNCTION__);
+    return -1;
+}
+
+int
+virStorageBackendRunProgNul(virConnectPtr conn,
+                            virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
+                            const char **prog ATTRIBUTE_UNUSED,
+                            size_t n_columns ATTRIBUTE_UNUSED,
+                            virStorageBackendListVolNulFunc func ATTRIBUTE_UNUSED,
+                            void *data ATTRIBUTE_UNUSED)
+{
+    virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, _("%s not implemented on Win32"), __FUNCTION__);
+    return -1;
+}
+#endif
index dcc1fc2611086f908a6428dd8944b4e61713e669..8887108b672648d9c0657669cc47c5669312745c 100644 (file)
@@ -200,7 +200,7 @@ virStoragePoolDefParsePerms(virConnectPtr conn,
     }
 
     if (virXPathNode(conn, "/pool/permissions/group", ctxt) == NULL) {
-        perms->uid = getgid();
+        perms->gid = getgid();
     } else {
         if (virXPathLong(conn, "number(/pool/permissions/group)", ctxt, &v) < 0) {
             virStorageReportError(conn, VIR_ERR_XML_ERROR,
@@ -425,7 +425,7 @@ virStoragePoolDefParse(virConnectPtr conn,
     if (!xml) {
         if (conn && conn->err.code == VIR_ERR_NONE)
               virStorageReportError(conn, VIR_ERR_XML_ERROR,
-                                    _("failed to parse xml document"));
+                                    "%s",_("failed to parse xml document"));
         goto cleanup;
     }
 
@@ -799,7 +799,7 @@ virStorageVolDefParse(virConnectPtr conn,
     if (!xml) {
         if (conn && conn->err.code == VIR_ERR_NONE)
               virStorageReportError(conn, VIR_ERR_XML_ERROR,
-                                    _("failed to parse xml document"));
+                                    "%s", _("failed to parse xml document"));
         goto cleanup;
     }
 
index c7242686f4c120c16a8cecb4aa65e363f7cf3840..ca14be1624cb63d719765d304d6c3c685fc24a27 100644 (file)
@@ -440,22 +440,13 @@ virRun(virConnectPtr conn,
 int
 virExec(virConnectPtr conn,
         const char *const*argv ATTRIBUTE_UNUSED,
+        const char *const*envp ATTRIBUTE_UNUSED,
+        const fd_set *keepfd ATTRIBUTE_UNUSED,
         int *retpid ATTRIBUTE_UNUSED,
         int infd ATTRIBUTE_UNUSED,
         int *outfd ATTRIBUTE_UNUSED,
-        int *errfd ATTRIBUTE_UNUSED)
-{
-    ReportError (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
-    return -1;
-}
-
-int
-virExecNonBlock(virConnectPtr conn,
-                const char *const*argv ATTRIBUTE_UNUSED,
-                int *retpid ATTRIBUTE_UNUSED,
-                int infd ATTRIBUTE_UNUSED,
-                int *outfd ATTRIBUTE_UNUSED,
-                int *errfd ATTRIBUTE_UNUSED)
+        int *errfd ATTRIBUTE_UNUSED,
+        int flags ATTRIBUTE_UNUSED)
 {
     ReportError (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
     return -1;
index f2da006772d60b5d167db5e1f8478ba34b815f0a..093ef46674abb785072d26bb0141fe9ff079a0c5 100644 (file)
@@ -144,4 +144,12 @@ const char *virEnumToString(const char *const*types,
     const char *name ## TypeToString(int type);         \
     int name ## TypeFromString(const char*type);
 
+#ifndef HAVE_GETUID
+static inline int getuid (void) { return 0; }
+#endif
+
+#ifndef HAVE_GETGID
+static inline int getgid (void) { return 0; }
+#endif
+
 #endif /* __VIR_UTIL_H__ */