[libvirt] [PATCH] build: port qemu to cygwin

A cygwin build of the qemu driver fails with: qemu/qemu_process.c: In function 'qemuPrepareCpumap': qemu/qemu_process.c:1803:31: error: 'CPU_SETSIZE' undeclared (first use in this function) CPU_SETSIZE is a Linux extension in <sched.h>; a bit more portable is using sysconf if _SC_NPROCESSORS_CONF is defined (several platforms have it, including Cygwin). Ultimately, I would have preferred to use gnulib's 'nproc' module, but it is currently under an incompatible license. * src/qemu/qemu_conf.h (QEMUD_CPUMASK_LEN): Provide definition on cygwin. Signed-off-by: Eric Blake <eblake@redhat.com> --- I'll wait for a review on this one, particularly since I'm still trying to solve another qemu failure on cygwin: qemu/qemu_monitor.c:418:9: error: passing argument 2 of 'sendmsg' from incmpatible pointer type /usr/include/sys/socket.h:42:11: note: expected 'const struct msghdr *' but argument is of type 'struct msghdr *' src/qemu/qemu_conf.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index df0791e..42566b4 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -45,7 +45,13 @@ # include "locking/lock_manager.h" # include "qemu_capabilities.h" -# define QEMUD_CPUMASK_LEN CPU_SETSIZE +# ifdef CPU_SETSIZE /* Linux */ +# define QEMUD_CPUMASK_LEN CPU_SETSIZE +# elif defined(_SC_NPROCESSORS_CONF) /* Cygwin */ +# define QEMUD_CPUMASK_LEN (sysconf(_SC_NPROCESSORS_CONF)) +# else +# error "Port me" +# endif typedef struct _virQEMUCloseCallbacks virQEMUCloseCallbacks; typedef virQEMUCloseCallbacks *virQEMUCloseCallbacksPtr; -- 1.8.1.4

On 30.05.2013 05:04, Eric Blake wrote:
A cygwin build of the qemu driver fails with:
qemu/qemu_process.c: In function 'qemuPrepareCpumap': qemu/qemu_process.c:1803:31: error: 'CPU_SETSIZE' undeclared (first use in this function)
CPU_SETSIZE is a Linux extension in <sched.h>; a bit more portable is using sysconf if _SC_NPROCESSORS_CONF is defined (several platforms have it, including Cygwin). Ultimately, I would have preferred to use gnulib's 'nproc' module, but it is currently under an incompatible license.
* src/qemu/qemu_conf.h (QEMUD_CPUMASK_LEN): Provide definition on cygwin.
Signed-off-by: Eric Blake <eblake@redhat.com> ---
I'll wait for a review on this one, particularly since I'm still trying to solve another qemu failure on cygwin:
qemu/qemu_monitor.c:418:9: error: passing argument 2 of 'sendmsg' from incmpatible pointer type /usr/include/sys/socket.h:42:11: note: expected 'const struct msghdr *' but argument is of type 'struct msghdr *'
src/qemu/qemu_conf.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index df0791e..42566b4 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -45,7 +45,13 @@ # include "locking/lock_manager.h" # include "qemu_capabilities.h"
-# define QEMUD_CPUMASK_LEN CPU_SETSIZE +# ifdef CPU_SETSIZE /* Linux */ +# define QEMUD_CPUMASK_LEN CPU_SETSIZE +# elif defined(_SC_NPROCESSORS_CONF) /* Cygwin */ +# define QEMUD_CPUMASK_LEN (sysconf(_SC_NPROCESSORS_CONF)) +# else +# error "Port me" +# endif
typedef struct _virQEMUCloseCallbacks virQEMUCloseCallbacks; typedef virQEMUCloseCallbacks *virQEMUCloseCallbacksPtr;
ACK Michal

On 05/30/2013 01:39 AM, Michal Privoznik wrote:
On 30.05.2013 05:04, Eric Blake wrote:
A cygwin build of the qemu driver fails with:
qemu/qemu_process.c: In function 'qemuPrepareCpumap': qemu/qemu_process.c:1803:31: error: 'CPU_SETSIZE' undeclared (first use in this function)
CPU_SETSIZE is a Linux extension in <sched.h>; a bit more portable is using sysconf if _SC_NPROCESSORS_CONF is defined (several platforms have it, including Cygwin). Ultimately, I would have preferred to use gnulib's 'nproc' module, but it is currently under an incompatible license.
I'm still chasing that down (https://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00105.html), but at this point, I'd feel safer delaying a gnulib bump until after 1.0.6 is out, since it has missed rc2.
I'll wait for a review on this one, particularly since I'm still trying to solve another qemu failure on cygwin:
qemu/qemu_monitor.c:418:9: error: passing argument 2 of 'sendmsg' from incompatible pointer type /usr/include/sys/socket.h:42:11: note: expected 'const struct msghdr *' but argument is of type 'struct msghdr *'
As far as I can tell, this seems like a bug in cygwin's gcc (4.5.3); still no idea how I will work around that yet.
-# define QEMUD_CPUMASK_LEN CPU_SETSIZE +# ifdef CPU_SETSIZE /* Linux */ +# define QEMUD_CPUMASK_LEN CPU_SETSIZE +# elif defined(_SC_NPROCESSORS_CONF) /* Cygwin */ +# define QEMUD_CPUMASK_LEN (sysconf(_SC_NPROCESSORS_CONF)) +# else +# error "Port me" +# endif
typedef struct _virQEMUCloseCallbacks virQEMUCloseCallbacks; typedef virQEMUCloseCallbacks *virQEMUCloseCallbacksPtr;
ACK
Thanks; I've pushed this patch. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 05/30/2013 06:39 AM, Eric Blake wrote:
I'll wait for a review on this one, particularly since I'm still trying to solve another qemu failure on cygwin:
qemu/qemu_monitor.c:418:9: error: passing argument 2 of 'sendmsg' from incompatible pointer type /usr/include/sys/socket.h:42:11: note: expected 'const struct msghdr *' but argument is of type 'struct msghdr *'
As far as I can tell, this seems like a bug in cygwin's gcc (4.5.3); still no idea how I will work around that yet.
Found the root cause - a bug in cygwin's <sys/un.h> requires that <sys/socket.h> be included first prior to any use of struct msghdr. Patch coming up soon. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Michal Privoznik