[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] win32: fix socket_error() to work with Mingw64
From: |
Andrew Baumann |
Subject: |
Re: [Qemu-devel] [PATCH] win32: fix socket_error() to work with Mingw64 |
Date: |
Mon, 7 Mar 2016 19:03:04 +0000 |
> From: Daniel P. Berrange [mailto:address@hidden
> Sent: Monday, 7 March 2016 3:29 AM
>
> Historically QEMU has had a socket_error() macro that was
> defined to map to WSASocketError(). The os-win32.h header
> file would define errno constants that mapped to the
> WSA error constants. This worked fine with Mingw32 since
> its header files never defined any errno values, nor did
> it even provide an errno.h. So callers of socket_error()
> could match on traditional Exxxx constants and it would
> all "just work".
>
> With Mingw64 though, things work rather differently. First
> there is an errno.h file which defines all the traditional
> errno constants you'd expect from a UNIX platform. There
> is then a winerror.h which defined the WSA error constants.
> Crucially the WSAExxxx errno values in winerror.h do not
> match the Exxxx errno values in error.h.
>
> If QEMU had only imported winerror.h it would still work,
> but the qemu/osdep.h file unconditionally imports errno.h.
> So callers of socket_error() will get now WSAExxxx values
> back and compare them to the Exxx constants. This will
> always fail silently at runtime.
>
> To solve this QEMU needs to stop assuming the WSAExxxx
> constant values match the Exxx constant values. Thus the
> socket_error() macro is turned into a small function that
> re-maps WSAExxxx values into Exxx.
>
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
>
> NB, I've not actually done anything other that compile
> test this so far. I'll be doing a runtime test once I
> get my windows VM working with QEMU builds agian...
If it helps, this works for me.
Tested-by: Andrew Baumann <address@hidden>
(It doesn't fix the watch/accept problem, obviously, but at least we can listen
now.)
Thanks,
Andrew