[libvirt] [PATCH] dnsmasqReload: avoid mingw link failure

* src/util/dnsmasq.c (dnsmasqReload): Mingw lacks kill, but is not running a dnsmasq daemon either. --- I'm not as familiar with the mingw cross-build setup, but I finally got enough pieces installed on my F-12 machine that this was the only remaining compilation failure that I ran into. Let me know if we need an alternate patch that solves dnsmasq more gracefully than just crippling one function. src/util/dnsmasq.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/util/dnsmasq.c b/src/util/dnsmasq.c index 1cb5f21..d6cef40 100644 --- a/src/util/dnsmasq.c +++ b/src/util/dnsmasq.c @@ -328,14 +328,16 @@ dnsmasqDelete(const dnsmasqContext *ctx) * Reloads all the configurations associated to a context */ int -dnsmasqReload(pid_t pid) +dnsmasqReload(pid_t pid ATTRIBUTE_UNUSED) { +#ifndef __MINGW32__ if (kill(pid, SIGHUP) != 0) { virReportSystemError(errno, _("Failed to make dnsmasq (PID: %d) reload config files.\n"), pid); return -1; } +#endif /* __MINGW32__ */ return 0; } -- 1.6.6.1

2010/5/3 Eric Blake <eblake@redhat.com>:
* src/util/dnsmasq.c (dnsmasqReload): Mingw lacks kill, but is not running a dnsmasq daemon either. ---
I'm not as familiar with the mingw cross-build setup, but I finally got enough pieces installed on my F-12 machine that this was the only remaining compilation failure that I ran into. Let me know if we need an alternate patch that solves dnsmasq more gracefully than just crippling one function.
There's no dnsmasq to kill on Windows. I think this fix is fine.
src/util/dnsmasq.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/util/dnsmasq.c b/src/util/dnsmasq.c index 1cb5f21..d6cef40 100644 --- a/src/util/dnsmasq.c +++ b/src/util/dnsmasq.c @@ -328,14 +328,16 @@ dnsmasqDelete(const dnsmasqContext *ctx) * Reloads all the configurations associated to a context */ int -dnsmasqReload(pid_t pid) +dnsmasqReload(pid_t pid ATTRIBUTE_UNUSED) { +#ifndef __MINGW32__
Typically, WIN32 instead of __MINGW32__ is used in the libvirt code base. Cygwin doesn't define WIN32, so this won't interfere with a Cygwin build.
if (kill(pid, SIGHUP) != 0) { virReportSystemError(errno, _("Failed to make dnsmasq (PID: %d) reload config files.\n"),
You could kill the \n here.
pid); return -1; } +#endif /* __MINGW32__ */
return 0; } -- 1.6.6.1
ACK Matthias

On 05/03/2010 12:43 PM, Matthias Bolte wrote:
-dnsmasqReload(pid_t pid) +dnsmasqReload(pid_t pid ATTRIBUTE_UNUSED) { +#ifndef __MINGW32__
Typically, WIN32 instead of __MINGW32__ is used in the libvirt code base. Cygwin doesn't define WIN32, so this won't interfere with a Cygwin build.
for exp in MINGW32 WIN32; do git grep $exp -- tools lib daemon | wc done shows 4 of the former, and 13 of the latter. Patch updated accordingly, and I'm working on a followup to make it consistent.
if (kill(pid, SIGHUP) != 0) { virReportSystemError(errno, _("Failed to make dnsmasq (PID: %d) reload config files.\n"),
You could kill the \n here.
Sure, as long as I'm in the area.
ACK
Thanks, and applied with your suggested updates. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

WIN32 is always defined when __MINGW32__ is defined, but the converse is not true. WIN32 is more generic, if someone were to ever attempt porting to a microsoft compiler. This does not affect Cygwin, which intentionally does not define WIN32. * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Use more generic flag macro. * src/storage/storage_backend.c (virStorageBackendUpdateVolTargetInfoFD) (virStorageBackendRunProgRegex): Likewise. * tools/console.h (vshRunConsole): Likewise. ---
for exp in MINGW32 WIN32; do git grep $exp -- tools lib daemon | wc done
shows 4 of the former, and 13 of the latter. Patch updated accordingly, and I'm working on a followup to make it consistent.
Like so. src/qemu/qemu_driver.c | 2 +- src/storage/storage_backend.c | 6 +++--- tools/console.c | 6 +++--- tools/console.h | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 08cff00..704f824 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9080,7 +9080,7 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom, } if (S_ISREG(sb.st_mode)) { -#ifndef __MINGW32__ +#ifndef WIN32 info->physical = (unsigned long long)sb.st_blocks * (unsigned long long)DEV_BSIZE; #else diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 5003b8c..83bbd93 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -954,7 +954,7 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target, if (allocation) { if (S_ISREG(sb.st_mode)) { -#ifndef __MINGW32__ +#ifndef WIN32 *allocation = (unsigned long long)sb.st_blocks * (unsigned long long)DEV_BSIZE; #else @@ -1184,7 +1184,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, } -#ifndef __MINGW32__ +#ifndef WIN32 /* * Run an external program. * @@ -1466,7 +1466,7 @@ virStorageBackendRunProgNul(virStoragePoolObjPtr pool, return 0; } -#else +#else /* WIN32 */ int virStorageBackendRunProgRegex(virConnectPtr conn, diff --git a/tools/console.c b/tools/console.c index 4201ba4..60e62e2 100644 --- a/tools/console.c +++ b/tools/console.c @@ -1,7 +1,7 @@ /* * console.c: A dumb serial console client * - * Copyright (C) 2007, 2008 Red Hat, Inc. + * Copyright (C) 2007, 2008, 2010 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,7 +22,7 @@ #include <config.h> -#ifndef __MINGW32__ +#ifndef WIN32 # include <stdio.h> # include <sys/types.h> @@ -197,4 +197,4 @@ int vshRunConsole(const char *tty) { return ret; } -#endif /* !__MINGW32__ */ +#endif /* !WIN32 */ diff --git a/tools/console.h b/tools/console.h index 683f1cb..d0df78d 100644 --- a/tools/console.h +++ b/tools/console.h @@ -1,7 +1,7 @@ /* * console.c: A dumb serial console client * - * Copyright (C) 2007 Red Hat, Inc. + * Copyright (C) 2007, 2010 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 @@ -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__ */ -- 1.6.6.1

2010/5/3 Eric Blake <eblake@redhat.com>:
WIN32 is always defined when __MINGW32__ is defined, but the converse is not true. WIN32 is more generic, if someone were to ever attempt porting to a microsoft compiler. This does not affect Cygwin, which intentionally does not define WIN32.
ACK. Matthias

On 05/03/2010 03:29 PM, Matthias Bolte wrote:
2010/5/3 Eric Blake <eblake@redhat.com>:
WIN32 is always defined when __MINGW32__ is defined, but the converse is not true. WIN32 is more generic, if someone were to ever attempt porting to a microsoft compiler. This does not affect Cygwin, which intentionally does not define WIN32.
ACK.
Thanks; pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Matthias Bolte