Skip to contentSkip to conversation

QEMU SVN on Windows 2000 :-(

Qemu-devel Robert Riebisch 10 participants 16 messages Feb 2, 2009 – Feb 12, 2009

lore
Share & tools
lore
#0 lore raw

Hi!

Unfortunately Win32 binaries built from QEMU SVN don't run on Windows 2000 anymore, because of missing DLL entry points in `ws2_32.dll'.

With the introduction of IPv6 QEMU relies on the presence of getaddrinfo(), getnameinfo(), and freeaddrinfo(). This is OK for Windows XP or later, but not for Windows 2000.

Quoted 1 line

From <http://msdn.microsoft.com/en-us/library/ms738520(VS.85).aspx>:

***
*Support for getaddrinfo on older versions of Windows*

The getaddrinfo function was added to the Ws2_32.dll on Windows XP and later. To execute an application that uses this function on earlier versions of Windows, then you need to include the Ws2tcpip.h and Wspiapi.h files. When the Wspiapi.h include file is added, the getaddrinfo function is defined to the WspiapiGetAddrInfo inline function in the Wspiapi.h file. At runtime, the WspiapiGetAddrInfo function is implemented in such a way that if the Ws2_32.dll or the Wship6.dll (the file containing getaddrinfo in the IPv6 Technology Preview for Windows 2000) does not include getaddrinfo, then a version of getaddrinfo is implemented inline based on code in the Wspiapi.h header file. This inline code will be used on older Windows platforms that do not natively support the getaddrinfo function.

The IPv6 protocol is supported on Windows 2000 when the IPv6 Technology Preview for Windows 2000 is installed. Otherwise getaddrinfo support on versions of Windows earlier than Windows XP is limited to handling IPv4 name resolution.
***

This stupid little patch works for me, but it requires copyrighted file `Wspiapi.h' from MSVC2005, because MinGW doesn't provide such a file. I've tested this on Windows 2000 only with IPv4. Better solutions are highly appreciated.

***

qemu-sockets.c renamed from qemu-sockets.c.orig +3 -0
@@ -22,6 +22,9 @@
 #include "qemu_socket.h"
 #include "qemu-common.h" /* for qemu_isdigit */
 
+#define _inline __inline /* circumvent header file issue */
+#include <wspiapi.h>
+
 #ifndef AI_ADDRCONFIG
 # define AI_ADDRCONFIG 0
 #endif

***

Robert Riebisch

Signature · 2 lines
BTTR Software
http://www.bttr-software.de/
#1 lore raw
Quoted 5 lines · Robert Riebisch

Hi!

Unfortunately Win32 binaries built from QEMU SVN don't run on Windows 2000 anymore, because of missing DLL entry points in `ws2_32.dll'.

Unfortunately, win2k is so old at this point, that I don't know that it's worth jumping through hoops to support.

If someone can come up with a simple patch (with appropriately licensed code), then I'd be happy to apply it. Otherwise, I don't think not supporting win2k as a host is a huge loss.

Regards,

Anthony Liguori

Quoted 51 lines

With the introduction of IPv6 QEMU relies on the presence of getaddrinfo(), getnameinfo(), and freeaddrinfo(). This is OK for Windows XP or later, but not for Windows 2000.

From <http://msdn.microsoft.com/en-us/library/ms738520(VS.85).aspx>:
***
*Support for getaddrinfo on older versions of Windows*

The getaddrinfo function was added to the Ws2_32.dll on Windows XP and later. To execute an application that uses this function on earlier versions of Windows, then you need to include the Ws2tcpip.h and Wspiapi.h files. When the Wspiapi.h include file is added, the getaddrinfo function is defined to the WspiapiGetAddrInfo inline function in the Wspiapi.h file. At runtime, the WspiapiGetAddrInfo function is implemented in such a way that if the Ws2_32.dll or the Wship6.dll (the file containing getaddrinfo in the IPv6 Technology Preview for Windows 2000) does not include getaddrinfo, then a version of getaddrinfo is implemented inline based on code in the Wspiapi.h header file. This inline code will be used on older Windows platforms that do not natively support the getaddrinfo function.

The IPv6 protocol is supported on Windows 2000 when the IPv6 Technology Preview for Windows 2000 is installed. Otherwise getaddrinfo support on versions of Windows earlier than Windows XP is limited to handling IPv4 name resolution.
***

This stupid little patch works for me, but it requires copyrighted file `Wspiapi.h' from MSVC2005, because MinGW doesn't provide such a file. I've tested this on Windows 2000 only with IPv4. Better solutions are highly appreciated.

***

qemu-sockets.c renamed from qemu-sockets.c.orig +3 -0
@@ -22,6 +22,9 @@
 #include "qemu_socket.h"
 #include "qemu-common.h" /* for qemu_isdigit */
 
+#define _inline __inline /* circumvent header file issue */
+#include <wspiapi.h>
+
 #ifndef AI_ADDRCONFIG
 # define AI_ADDRCONFIG 0
 #endif

***

Robert Riebisch

#2 lore raw
Quoted 11 lines · Anthony Liguori
Quoted 5 lines · Robert Riebisch

Hi!

Unfortunately Win32 binaries built from QEMU SVN don't run on Windows 2000 anymore, because of missing DLL entry points in `ws2_32.dll'.

Unfortunately, win2k is so old at this point, that I don't know that it's worth jumping through hoops to support.

If someone can come up with a simple patch (with appropriately licensed code), then I'd be happy to apply it. Otherwise, I don't think not supporting win2k as a host is a huge loss.

There is in fact a signed-off two-liner still in the thread:

Quoted 16 lines
Quoted 16 lines
qemu-sockets.c Mon Feb 02 22:04:42 2009 renamed from qemu-sockets.c.orig Wed Jan 14 19:34:22 2009 +3 -0
@@ -22,6 +22,9 @@
 #include "qemu_socket.h"
 #include "qemu-common.h" /* for qemu_isdigit */
 
+#define _inline __inline /* circumvent header file issue */
+#include <wspiapi.h>
+
 #ifndef AI_ADDRCONFIG
 # define AI_ADDRCONFIG 0
 #endif

***

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#3 lore raw
Quoted 8 lines · Avi Kivity
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Robert Riebisch

Hi!

Unfortunately Win32 binaries built from QEMU SVN don't run on Windows 2000 anymore, because of missing DLL entry points in `ws2_32.dll'.

Quoted 6 lines
Quoted 4 lines

Unfortunately, win2k is so old at this point, that I don't know that it's worth jumping through hoops to support.

If someone can come up with a simple patch (with appropriately licensed code), then I'd be happy to apply it. Otherwise, I don't think not supporting win2k as a host is a huge loss.

There is in fact a signed-off two-liner still in the thread:

"but it requires copyrighted file `Wspiapi.h' from MSVC2005, because MinGW doesn't provide such a file."

So if Wspiapi.h carries a GPL compatible license, it's fine to include. The patch lacks Wspiapi.h though so it'll break the build on mingw.

Regards,

Anthony Liguori

Quoted 18 lines
Quoted 16 lines
Quoted 16 lines
qemu-sockets.c Mon Feb 02 22:04:42 2009 renamed from qemu-sockets.c.orig Wed Jan 14 19:34:22 2009 +3 -0
@@ -22,6 +22,9 @@
 #include "qemu_socket.h"
 #include "qemu-common.h" /* for qemu_isdigit */
 
+#define _inline __inline /* circumvent header file issue */
+#include <wspiapi.h>
+
 #ifndef AI_ADDRCONFIG
 # define AI_ADDRCONFIG 0
 #endif

***

#4 lore raw
Quoted 17 lines · Anthony Liguori
Quoted 16 lines · Avi Kivity
Quoted 14 lines · Anthony Liguori
Quoted 5 lines · Robert Riebisch

Hi!

Unfortunately Win32 binaries built from QEMU SVN don't run on Windows 2000 anymore, because of missing DLL entry points in `ws2_32.dll'.

Unfortunately, win2k is so old at this point, that I don't know that it's worth jumping through hoops to support.

If someone can come up with a simple patch (with appropriately licensed code), then I'd be happy to apply it. Otherwise, I don't think not supporting win2k as a host is a huge loss.

Quoted 7 lines
Quoted 1 line

There is in fact a signed-off two-liner still in the thread:

"but it requires copyrighted file `Wspiapi.h' from MSVC2005, because MinGW doesn't provide such a file."

So if Wspiapi.h carries a GPL compatible license, it's fine to include. The patch lacks Wspiapi.h though so it'll break the build on mingw.

Well MinGW already builds fine with getaddrinfo(), so no need for a GPL header providing Wspiapi.h there. Since this is only needed for a few Win builds, why not just make the include conditional on whether that header actually exists. eg

#ifdef HAVE_WSPIAPI_H
#include <Wspiapi.h>
#endif

Regards,
Daniel

Signature · 4 lines
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
#5 lore raw
Quoted 8 lines · Daniel P. Berrange

Well MinGW already builds fine with getaddrinfo(), so no need for a GPL
header providing Wspiapi.h there. Since this is only needed for a few
Win builds, why not just make the include conditional on whether that header actually exists. eg

#ifdef HAVE_WSPIAPI_H
#include <Wspiapi.h>
#endif

If that works, that's fine.

Regards,

Anthony Liguori

Quoted 3 lines

Regards,
Daniel

#6 lore raw

For the record, getaddrinfo() was introduced in Windows 2000 Professional and Server, see end of
http://msdn.microsoft.com/en-us/library/ms738520(VS.85).aspx
(it's only missing from 2000 Workstation).

you just need to add -DWINVER=0x501 to your CFLAGS to be able to have it properly declared (and linked to) with should be able to compile it with mingw

hope this helps

Quoted 27 lines · Anthony Liguori
Quoted 10 lines · Daniel P. Berrange

Well MinGW already builds fine with getaddrinfo(), so no need for a GPL header providing Wspiapi.h there. Since this is only needed for a few Win builds, why not just make the include conditional on whether that header actually exists. eg

#ifdef HAVE_WSPIAPI_H
#include <Wspiapi.h>
#endif

If that works, that's fine.

Regards,

Anthony Liguori

Regards,

Quoted 3 lines

Daniel

#7 lore raw
Quoted 3 lines · David Turner

For the record, getaddrinfo() was introduced in Windows 2000 Professional and Server, see end of
http://msdn.microsoft.com/en-us/library/ms738520(VS.85).aspx

I already wrote in my original post.

Quoted 1 line

(it's only missing from 2000 Workstation).

There's no such thing ("Workstation").

Quoted 1 line

you just need to add -DWINVER=0x501 to your CFLAGS to be able to have it

We already have "#define WINVER 0x0501" in `qemu_common.h".

Quoted 2 lines

properly declared (and linked to) with should be able to compile it with mingw

But one would still need (copyrighted) `Wspiapi.h' to make the resulting binary run on Windows 2000.

Robert Riebisch

Signature · 2 lines
BTTR Software
http://www.bttr-software.de/
#8 lore raw
Quoted 5 lines · Robert Riebisch
Quoted 2 lines

(it's only missing from 2000 Workstation).

There's no such thing ("Workstation").

Damn, damn, you're absolutely right... oh my memory :-)

Quoted 6 lines
Quoted 2 lines

properly declared (and linked to) with should be able to compile it with mingw

But one would still need (copyrighted) `Wspiapi.h' to make the resulting binary run on Windows 2000.

I'm curious to know that this header contains that makes the result magically run on Windows 2000.
In the meantime, I'll probably change my code to use GetProcAddress() to load it dynamically it
available and revert to gethostbyname() when applicable.

thanks for the clarification

Quoted 8 lines

Robert Riebisch
--
BTTR Software
http://www.bttr-software.de/

#9 lore raw
In reply to Daniel P. Berrange
Quoted 10 lines · Daniel P. Berrange
Quoted 5 lines

"but it requires copyrighted file `Wspiapi.h' from MSVC2005, because MinGW doesn't provide such a file."

So if Wspiapi.h carries a GPL compatible license, it's fine to include. The patch lacks Wspiapi.h though so it'll break the build on mingw.

Well MinGW already builds fine with getaddrinfo(), so no need for a GPL header providing Wspiapi.h there. Since this is only needed for a few Win builds, why not just make the include conditional on whether that header actually exists. eg

It should compile, but the point is it will fail at run time on most versions of Windows 2000, and all earlier Windows versions.

Imho it's standard practice on Windows to look up getaddrinfo() dynamically, in case it doesn't exist - same for a few other functions. But maybe that's just my standard practice ;-)

Windows XP was introduced in 2003, iirc, about the same time as Linux 2.6.0, although major distributions didn't pick up Linux 2.6 until years later. Does Qemu run on Linux 2.4?

-- Jamie

#10 lore raw
Quoted 3 lines · Jamie Lokier

years later. Does Qemu run on Linux 2.4?

QEMU runs on RedHat 9 which is 2.4.20 but only with this patch (otherwise it just hangs at startup):

vl.c (working copy) renamed from vl.c (revision 6510) +0 -0
@@ -1008,8 +1008,8 @@

static struct qemu_alarm_timer alarm_timers[] = {
#ifndef _WIN32
#ifdef __linux__
- {"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
- dynticks_stop_timer, dynticks_rearm_timer, NULL},
+// {"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
+// dynticks_stop_timer, dynticks_rearm_timer, NULL},

    /* HPET - if available - is preferred */
    {"hpet", 0, hpet_start_timer, hpet_stop_timer, NULL, NULL},
    /* ...otherwise try RTC */
#11 lore raw

dynticks was introduced in release 2.6.21.
Maybe a #ifdef around these lines is needed?

Best Regards
-david-

Quoted 25 lines · Robert Reif
Quoted 4 lines · Jamie Lokier

years later. Does Qemu run on Linux 2.4?

QEMU runs on RedHat 9 which is 2.4.20 but only with this patch (otherwise it just hangs at startup):

vl.c (working copy) renamed from vl.c (revision 6510) +2 -2
@@ -1008,8 +1008,8 @@
 static struct qemu_alarm_timer alarm_timers[] = {
 #ifndef _WIN32
 #ifdef __linux__
-    {"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
-     dynticks_stop_timer, dynticks_rearm_timer, NULL},
+//    {"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
+//     dynticks_stop_timer, dynticks_rearm_timer, NULL},
   /* HPET - if available - is preferred */
   {"hpet", 0, hpet_start_timer, hpet_stop_timer, NULL, NULL},
   /* ...otherwise try RTC */
#12 lore raw
Quoted 1 line · David Coppa

dynticks was introduced in release 2.6.21.

You're thinking of something completely different.

Paul

#13 lore raw
In reply to Robert Reif
Quoted 4 lines · Robert Reif
Quoted 1 line · Jamie Lokier

years later. Does Qemu run on Linux 2.4?

QEMU runs on RedHat 9 which is 2.4.20 but only with this patch (otherwise it just hangs at startup):

That suggests a latent bug in QEMU - there's no obvious reason why dynticks wouldn't work on Linux 2.4.20.

-- Jamie

#14 lore raw
In reply to Robert Reif
Quoted 10 lines · Robert Reif
Quoted 2 lines · Jamie Lokier

years later. Does Qemu run on Linux 2.4?

QEMU runs on RedHat 9 which is 2.4.20 but only with this patch (otherwise it just hangs at startup):

vl.c (working copy) line 1015

Quoted 10 lines
vl.c (working copy) renamed from vl.c (revision 6510) +2 -2
@@ -1008,8 +1008,8 @@
 static struct qemu_alarm_timer alarm_timers[] = {
 #ifndef _WIN32
 #ifdef __linux__
-    {"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
-     dynticks_stop_timer, dynticks_rearm_timer, NULL},
+//    {"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer,
+//     dynticks_stop_timer, dynticks_rearm_timer, NULL},
   /* HPET - if available - is preferred */
   {"hpet", 0, hpet_start_timer, hpet_stop_timer, NULL, NULL},
   /* ...otherwise try RTC */

You can override the order of the timers with -clock, e.g.:
-clock hpet,rtc,unix
will try first hpet, then rtc and unix (ignoring dynticks). It should hang though, can you see if dynticks_rearm_timer gets called?

Luca

#15 lore raw
In reply to Anthony Liguori
Quoted 6 lines · Anthony Liguori
Quoted 2 lines

There is in fact a signed-off two-liner still in the thread:

"but it requires copyrighted file `Wspiapi.h' from MSVC2005, because MinGW doesn't provide such a file."

So if Wspiapi.h carries a GPL compatible license, it's fine to include. The patch lacks Wspiapi.h though so it'll break the build on mingw.

Sounds like a mingw bug, no?

Signature · 1 line
error compiling committee.c: too many arguments to function