Re: [libvirt] [PATCH] always compile iptables.c
On Fri, Nov 07, 2008 at 02:49:43PM +0100, Jim Meyering wrote: This is slightly different from the previous version. The new part is the addition of the virRun stub to prevent a mingw link failure when building with shared libraries. Now, configured like this, it builds without error: /usr/bin/mingw32-configure --without-sasl --without-avahi \ --without-polkit --without-python --without-xen --without-qemu \ --without-lxc --without-openvz --without-libvirtd \ --prefix=/tmp/libvirt-inst --enable-compile-warnings=maximum OK, looks good to me, +1. On an unrelated point, probably any usage of __MINGW32__ is suspect, eg: #else /* __MINGW32__ */ Our MinGW cross-compiler defines the symbol 'WIN32', and so do all compilers on Windows itself[1][2]. Therefore it's better to use #ifdef WIN32 ... #endif for any code that is specific to the Win32 API. The __MINGW32__ symbol has a place for code which is specific to the MinGW version of GCC, eg. if it had a bug that we needed to work around. The attached patch appears to work with some light testing. Rich. [1] Even for 64-bit code. [2] The exception is Cygwin, but you can argue that Cygwin is really a Unix API. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my OCaml programming blog: http://camltastic.blogspot.com/ Fedora now supports 68 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora Index: src/console.c === RCS file: /data/cvs/libvirt/src/console.c,v retrieving revision 1.7 diff -u -r1.7 console.c --- src/console.c 10 Apr 2008 16:53:29 - 1.7 +++ src/console.c 7 Nov 2008 14:06:57 - @@ -22,7 +22,7 @@ #include config.h -#ifndef __MINGW32__ +#ifndef WIN32 #include stdio.h #include sys/types.h @@ -197,4 +197,4 @@ return ret; } -#endif /* !__MINGW32__ */ +#endif /* !WIN32 */ Index: src/console.h === RCS file: /data/cvs/libvirt/src/console.h,v retrieving revision 1.5 diff -u -r1.5 console.h --- src/console.h 20 Aug 2008 20:48:35 - 1.5 +++ src/console.h 7 Nov 2008 14:06:57 - @@ -23,10 +23,10 @@ #ifndef __VIR_CONSOLE_H__ #define __VIR_CONSOLE_H__ -#ifndef __MINGW32__ +#ifndef WIN32 int vshRunConsole(const char *tty); -#endif /* !__MINGW32__ */ +#endif /* !WIN32 */ #endif /* __VIR_CONSOLE_H__ */ Index: src/storage_backend.c === RCS file: /data/cvs/libvirt/src/storage_backend.c,v retrieving revision 1.26 diff -u -r1.26 storage_backend.c --- src/storage_backend.c 4 Nov 2008 22:30:34 - 1.26 +++ src/storage_backend.c 7 Nov 2008 14:06:57 - @@ -246,7 +246,7 @@ return -2; if (S_ISREG(sb.st_mode)) { -#ifndef __MINGW32__ +#ifndef WIN32 vol-allocation = (unsigned long long)sb.st_blocks * (unsigned long long)sb.st_blksize; #else @@ -421,7 +421,7 @@ } -#ifndef __MINGW32__ +#ifndef WIN32 /* * Run an external program. * Index: src/util.c === RCS file: /data/cvs/libvirt/src/util.c,v retrieving revision 1.66 diff -u -r1.66 util.c --- src/util.c 6 Nov 2008 16:36:07 - 1.66 +++ src/util.c 7 Nov 2008 14:06:58 - @@ -116,7 +116,7 @@ } -#ifndef __MINGW32__ +#ifndef WIN32 static int virSetCloseExec(int fd) { int flags; @@ -577,7 +577,7 @@ return ret; } -#else /* __MINGW32__ */ +#else /* WIN32 */ int virExec(virConnectPtr conn, @@ -594,7 +594,7 @@ return -1; } -#endif /* __MINGW32__ */ +#endif /* WIN32 */ /* Like gnulib's fread_file, but read no more than the specified maximum number of bytes. If the length of the input is = max_len, and Index: src/virsh.c === RCS file: /data/cvs/libvirt/src/virsh.c,v retrieving revision 1.170 diff -u -r1.170 virsh.c --- src/virsh.c 13 Oct 2008 16:46:29 - 1.170 +++ src/virsh.c 7 Nov 2008 14:07:02 - @@ -481,7 +481,7 @@ {NULL, 0, 0, NULL} }; -#ifndef __MINGW32__ +#ifndef WIN32 static int cmdConsole(vshControl *ctl, const vshCmd *cmd) @@ -531,7 +531,7 @@ return ret; } -#else /* __MINGW32__ */ +#else /* WIN32 */ static int cmdConsole(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) @@ -540,7 +540,7 @@ return FALSE; } -#endif /* __MINGW32__ */ +#endif /* WIN32 */ /* * list command -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] always compile iptables.c
Richard W.M. Jones [EMAIL PROTECTED] wrote: On Fri, Nov 07, 2008 at 02:49:43PM +0100, Jim Meyering wrote: This is slightly different from the previous version. The new part is the addition of the virRun stub to prevent a mingw link failure when building with shared libraries. Now, configured like this, it builds without error: /usr/bin/mingw32-configure --without-sasl --without-avahi \ --without-polkit --without-python --without-xen --without-qemu \ --without-lxc --without-openvz --without-libvirtd \ --prefix=/tmp/libvirt-inst --enable-compile-warnings=maximum OK, looks good to me, +1. Thanks. On an unrelated point, probably any usage of __MINGW32__ is suspect, eg: s/any/any *other*/ ? #else /* __MINGW32__ */ Our MinGW cross-compiler defines the symbol 'WIN32', and so do all compilers on Windows itself[1][2]. Therefore it's better to use #ifdef WIN32 ... #endif for any code that is specific to the Win32 API. The __MINGW32__ symbol has a place for code which is specific to the MinGW version of GCC, eg. if it had a bug that we needed to work around. In the case of lstat, that use of __MINGW32__ is deliberate, since the guarded code is needed only on mingw, and not on cygwin. So using WIN32 there would be wrong. -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] always compile iptables.c
On Fri, Nov 07, 2008 at 03:34:59PM +0100, Jim Meyering wrote: Richard W.M. Jones [EMAIL PROTECTED] wrote: On an unrelated point, probably any usage of __MINGW32__ is suspect, eg: s/any/any *other*/ ? I'm pretty sure any, in this case too. #else /* __MINGW32__ */ Our MinGW cross-compiler defines the symbol 'WIN32', and so do all compilers on Windows itself[1][2]. Therefore it's better to use #ifdef WIN32 ... #endif for any code that is specific to the Win32 API. The __MINGW32__ symbol has a place for code which is specific to the MinGW version of GCC, eg. if it had a bug that we needed to work around. In the case of lstat, that use of __MINGW32__ is deliberate, since the guarded code is needed only on mingw, and not on cygwin. So using WIN32 there would be wrong. Cygwin isn't like other Windows compilers -- it exposes a Unix/POSIX API (not Win32 which is a completely different API, even though some of the calls happen to look superficially similar). Cygwin doesn't define WIN32 symbol[1], so using WIN32 here should be OK. Anyway, I don't think anyone is using Cygwin to compile libvirt. The licensing issues alone mean that it'd be unacceptable to most of our users. Rich. [1] Well, that's not entirely true: if you use Cygwin and then include windows.h, you do get WIN32 symbol defined, because by doing this you've got both POSIX _and_ Win32 APIs available. WIN32 tells you that the Win32 API is available, not that POSIX is unavailable. -- 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 -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] always compile iptables.c
This is slightly different from the previous version. The new part is the addition of the virRun stub to prevent a mingw link failure when building with shared libraries. Now, configured like this, it builds without error: /usr/bin/mingw32-configure --without-sasl --without-avahi \ --without-polkit --without-python --without-xen --without-qemu \ --without-lxc --without-openvz --without-libvirtd \ --prefix=/tmp/libvirt-inst --enable-compile-warnings=maximum From 0b35049f3cd10dbfd650aae692c553e940409805 Mon Sep 17 00:00:00 2001 From: Jim Meyering [EMAIL PROTECTED] Date: Thu, 6 Nov 2008 08:42:33 +0100 Subject: [PATCH 1/3] always compile iptables.c Avoid a build error when configuring --without-xen --without-qemu. * src/iptables.c [WITH_QEMU]: Don't #ifdef-out. * src/iptables.h [WITH_QEMU]: Don't #ifdef-out. * src/util.c (virRun) [__MINGW32__]: Define a stub that always fails. --- src/iptables.c |4 src/iptables.h |6 +- src/util.c | 12 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/iptables.c b/src/iptables.c index 53e0f41..ad7fddf 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -21,8 +21,6 @@ #include config.h -#if WITH_QEMU - #include stdio.h #include stdlib.h #include stdarg.h @@ -1120,5 +1118,3 @@ iptablesRemoveForwardMasquerade(iptablesContext *ctx, { return iptablesForwardMasquerade(ctx, network, physdev, REMOVE); } - -#endif /* WITH_QEMU */ diff --git a/src/iptables.h b/src/iptables.h index 95f07de..fbe9b5d 100644 --- a/src/iptables.h +++ b/src/iptables.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Red Hat, Inc. + * Copyright (C) 2007, 2008 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,8 +22,6 @@ #ifndef __QEMUD_IPTABLES_H__ #define __QEMUD_IPTABLES_H__ -#if WITH_QEMU - typedef struct _iptablesContext iptablesContext; iptablesContext *iptablesContextNew (void); @@ -95,6 +93,4 @@ int iptablesRemoveForwardMasquerade (iptablesContext *ctx, const char *network, const char *physdev); -#endif /* WITH_QEMU */ - #endif /* __QEMUD_IPTABLES_H__ */ diff --git a/src/util.c b/src/util.c index abc86d6..6141847 100644 --- a/src/util.c +++ b/src/util.c @@ -580,6 +580,18 @@ virRun(virConnectPtr conn, #else /* __MINGW32__ */ int +virRun(virConnectPtr conn, + const char *const *argv ATTRIBUTE_UNUSED, + int *status) +{ +if (status) +*status = ENOTSUP; +else +ReportError (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__); +return -1; +} + +int virExec(virConnectPtr conn, const char *const*argv ATTRIBUTE_UNUSED, const char *const*envp ATTRIBUTE_UNUSED, -- 1.6.0.3.756.gb776d -- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list