]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix Win32 portability problems
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 7 Apr 2010 15:06:43 +0000 (16:06 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 8 Apr 2010 11:01:57 +0000 (12:01 +0100)
The network filter / snapshot / hooks code introduced some
non-portable pices that broke the win32 build

* configure.ac: Check for net/ethernet.h required by nwfile config
   parsing code
* src/conf/nwfilter_conf.c: Define ethernet protocol  constants
  if net/ethernet.h is missing
* src/util/hooks.c: Disable hooks build on Win32 since it lacks
  fork/exec/pipe
* src/util/threads-win32.c: Fix unchecked return value
* tools/virsh.c: Disable SIGPIPE on Win32 since it doesn't exist.
  Fix non-portable strftime() formats

configure.ac
src/conf/nwfilter_conf.c
src/util/hooks.c
src/util/threads-win32.c
tools/virsh.c

index 2faab9e107aa1e485dfa27af82ff6d6156ca9e31..aa4937430531153aa93f768c36c0516314883ae3 100644 (file)
@@ -112,7 +112,7 @@ dnl Availability of various not common threadsafe functions
 AC_CHECK_FUNCS([strerror_r strtok_r getmntent_r getgrnam_r getpwuid_r])
 
 dnl Availability of various common headers (non-fatal if missing).
-AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h sys/utsname.h sys/wait.h winsock2.h sched.h termios.h sys/poll.h syslog.h mntent.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 sys/poll.h syslog.h mntent.h net/ethernet.h])
 
 dnl Where are the XDR functions?
 dnl If portablexdr is installed, prefer that.
index 3991c3bf98a08e82c7fafd355bd98e607e3121be..c83d5f5fe0fd1d77b906dfc21151ba83b2a744cd 100644 (file)
 
 #include <config.h>
 
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <dirent.h>
-#include <net/ethernet.h>
+#if HAVE_NET_ETHERNET_H
+# include <net/ethernet.h>
+#endif
 
 #include "internal.h"
 
 #include "domain_conf.h"
 
 
+/* XXX
+ * The config parser/structs should not be using platform specific
+ * constants. Win32 lacks these constants, breaking the parser,
+ * so temporarily define them until this can be re-written to use
+ * locally defined enums for all constants
+ */
+#ifndef ETHERTYPE_IP
+#define ETHERTYPE_IP            0x0800
+#endif
+#ifndef ETHERTYPE_ARP
+#define ETHERTYPE_ARP           0x0806
+#endif
+#ifndef ETHERTYPE_IPV6
+#define ETHERTYPE_IPV6          0x86dd
+#endif
+
 #define VIR_FROM_THIS VIR_FROM_NWFILTER
 
 
index 755679d73dd411bb4c1d39fe09baf4b2f8acb087..bcab4eb086628a93f6d2b8e8c7721e3a6272f7a0 100644 (file)
@@ -24,7 +24,9 @@
 #include <config.h>
 
 #include <sys/types.h>
+#if HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif
 #include <sys/stat.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -188,6 +190,19 @@ virHookPresent(int driver) {
  * Returns: 0 if the execution succeeded, 1 if the script was not found or
  *          invalid parameters, and -1 if script returned an error
  */
+#ifdef WIN32
+int
+virHookCall(int driver ATTRIBUTE_UNUSED,
+            const char *id ATTRIBUTE_UNUSED,
+            int op ATTRIBUTE_UNUSED,
+            int sub_op ATTRIBUTE_UNUSED,
+            const char *extra ATTRIBUTE_UNUSED,
+            const char *input ATTRIBUTE_UNUSED) {
+    virReportSystemError(ENOSYS, "%s",
+                         _("spawning hooks not supported on this platform"));
+    return -1;
+}
+#else
 int
 virHookCall(int driver, const char *id, int op, int sub_op, const char *extra,
             const char *input) {
@@ -447,3 +462,4 @@ no_memory:
 #undef ADD_ENV_LIT
 #undef ADD_ENV_SPACE
 }
+#endif
index b1d15712cbe525e227e7cd77b6f7bd9759f67adc..a30bccfdd192929047d7bc1cdc63714856f4ad48 100644 (file)
@@ -69,7 +69,7 @@ void virThreadOnExit(void)
 
 int virMutexInit(virMutexPtr m)
 {
-    virMutexInitRecursive(m);
+    return virMutexInitRecursive(m);
 }
 
 int virMutexInitRecursive(virMutexPtr m)
index aaae7cacca98d08b541008f27c8c74bc9abb01a0..8017bebfe84fcb6df1ee3d060cf8e9ff98d2fa0b 100644 (file)
@@ -414,6 +414,7 @@ out:
  */
 static int disconnected = 0; /* we may have been disconnected */
 
+#ifdef SIGPIPE
 /*
  * vshCatchDisconnect:
  *
@@ -442,6 +443,10 @@ vshSetupSignals(void) {
 
     sigaction(SIGPIPE, &sig_action, NULL);
 }
+#else
+static void
+vshSetupSignals(void) {}
+#endif
 
 /*
  * vshReconnect:
@@ -8425,7 +8430,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
                              &creation) < 0)
                 continue;
             localtime_r(&creation, &time_info);
-            strftime(timestr, sizeof(timestr), "%F %T %z", &time_info);
+            strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %z", &time_info);
 
             vshPrint(ctl, " %-20s %-25s %s\n", names[i], timestr, state);
         }