Skip to contentSkip to conversation

Win32 MinGW build with current CVS

Qemu-devel Andreas Bollhalder 3 participants 4 messages Aug 2, 2006 – Aug 3, 2006

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello

It seems that the aio support broke my MinGW build batch under Win32. Is it suposed to work on WIN32 ?

Any ideas ?

Andreas

gcc -Wall -O2 -g -fno-strict-aliasing -fomit-frame-pointer -I. -I..
- -I/D/DEV/QEMU/qemu/target-i386 -I/D/DEV/QEMU/qemu -D_GNU_SOURCE
- -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I/D/DEV/QEMU/qemu/fpu
- -DHAS_AUDIO -I/D/DEV/QEMU/qemu/slirp -c -o block-raw.o /D/DEV/QEMU/qemu/block-raw.c
d:/DEV/QEMU/qemu/block-raw.c: In function `raw_open':
d:/DEV/QEMU/qemu/block-raw.c:573: `BDRV_O_CREATE' undeclared (first use in this function)
d:/DEV/QEMU/qemu/block-raw.c:573: (Each undeclared identifier is reported only once
d:/DEV/QEMU/qemu/block-raw.c:573: for each function it appears in.) d:/DEV/QEMU/qemu/block-raw.c: In function `raw_aio_new':
d:/DEV/QEMU/qemu/block-raw.c:635: structure has no member named hevent' d:/DEV/QEMU/qemu/block-raw.c:636: structure has no member named hevent' d:/DEV/QEMU/qemu/block-raw.c: In function `raw_aio_cb':
d:/DEV/QEMU/qemu/block-raw.c:643: `acb1' undeclared (first use in this function)
d:/DEV/QEMU/qemu/block-raw.c:648: `s' undeclared (first use in this function)
d:/DEV/QEMU/qemu/block-raw.c: In function `raw_aio_read':
d:/DEV/QEMU/qemu/block-raw.c:662: warning: unused variable ret_count' d:/DEV/QEMU/qemu/block-raw.c: In function raw_aio_write':
d:/DEV/QEMU/qemu/block-raw.c:685: warning: unused variable ret_count' d:/DEV/QEMU/qemu/block-raw.c: In function raw_truncate':
d:/DEV/QEMU/qemu/block-raw.c:737: `length' undeclared (first use in this function)
d:/DEV/QEMU/qemu/vl.h: At top level:
d:/DEV/QEMU/qemu/block-raw.c:627: warning: `raw_aio_new' defined but not used
d:/DEV/QEMU/qemu/block-raw.c:658: warning: `raw_aio_read' defined but not used
d:/DEV/QEMU/qemu/block-raw.c:681: warning: `raw_aio_write' defined but not used
d:/DEV/QEMU/qemu/block-raw.c:714: warning: `raw_aio_delete' defined but not used
make: *** [block-raw.o] Error 1

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE0OnykyKr2gmercERAq3gAJ9hX0tp0/uqCCUrUy1ctCyVih71twCgjRi+ ys2Km+sxRKMZSTPRux+yCi8=
=DDwp
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 8 lines · Andreas Bollhalder

Hello

It seems that the aio support broke my MinGW build batch under Win32. Is it suposed to work on WIN32 ?

Any ideas ?

Andreas

...

Hi!

"Kernel Asynchronous I/O (AIO) Support for Linux
Overview

AIO enables even a single application thread to overlap I/O operations with other processing, by providing an interface for submitting one or more I/O requests in one system call (io_submit()) without waiting for completion, and a separate interface (io_getevents()) to reap completed I/O operations associated with a given completion group.

Support for kernel AIO has been included in the 2.6 Linux kernel."

source:
http://lse.sourceforge.net/io/aio.html

So, I don't think so. But please correct me, if I'm wrong.

Nyos

-------------------------------------------------------
Delay not, Caesar. Read it instantly.
-- Shakespeare, "Julius Caesar" 3,1

Here is a letter, read it at your leisure.
-- Shakespeare, "Merchant of Venice" 5,1

[Quoted in "VMS Internals and Data Structures", V4.4, when
referring to I/O system services.]

#2 lore raw

Sent: Thursday, August 03, 2006 4:07 AM NyOS wrote:

Quoted 8 lines · Andreas Bollhalder
Quoted 8 lines

Hello

It seems that the aio support broke my MinGW build batch under Win32. Is it suposed to work on WIN32 ?

Any ideas ?

Andreas

...

Quoted 1 line

Support for kernel AIO has been included in the 2.6 Linux kernel."

source:
http://lse.sourceforge.net/io/aio.html

Quoted 1 line

So, I don't think so. But please correct me, if I'm wrong.

Asynchronous I/O is implemented by overlapped I/O for Win32 but it is not enabled.

I tried to make the program. A patch attached fixs compile errors.

I found some problems about it.
GetFileSizeEx needs to define WINVER 0x0500. It means that Windows 98/Me host is not supported.
If we try to support Win 98/Me host, it is necessary to change configure to use --enable-win9x and make another binary, etc.

The first attempt to open a hard disk image with a drive letter always failed. After the second time is OK.

Regards,
Kazu

Index: block-raw.c
===================================================================
RCS file: /sources/qemu/qemu/block-raw.c,v
retrieving revision 1.2

block-raw.c +10 -6
diff -u -r1.2 block-raw.c
@@ -518,7 +518,6 @@
 #else /* _WIN32 */
 
 /* XXX: use another file ? */
-#include <windows.h>
 #include <winioctl.h>
 
 typedef struct BDRVRawState {
@@ -632,18 +631,17 @@
 static int raw_aio_new(BlockDriverAIOCB *acb)
 {
     RawAIOCB *acb1;
-    BDRVRawState *s = acb->bs->opaque;
 
     acb1 = qemu_mallocz(sizeof(RawAIOCB));
     if (!acb1)
         return -ENOMEM;
     acb->opaque = acb1;
-    s->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-    if (!s->hEvent)
+    acb1->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+    if (!acb1->hEvent)
         return -ENOMEM;
     return 0;
 }
-
+#ifndef QEMU_TOOL
 static void raw_aio_cb(void *opaque)
 {
     BlockDriverAIOCB *acb = opaque;
@@ -660,7 +658,7 @@
         acb->cb(acb->cb_opaque, 0);
     }
 }
-
+#endif
 static int raw_aio_read(BlockDriverAIOCB *acb, int64_t sector_num, 
                         uint8_t *buf, int nb_sectors)
 {
@@ -676,7 +674,9 @@
     acb1->ov.OffsetHigh = offset >> 32;
     acb1->ov.hEvent = acb1->hEvent;
     acb1->count = nb_sectors * 512;
+#ifndef QEMU_TOOL
     qemu_add_wait_object(acb1->ov.hEvent, raw_aio_cb, acb);
+#endif
     ret = ReadFile(s->hfile, buf, acb1->count, NULL, &acb1->ov);
     if (!ret)
         return -EIO;
@@ -698,7 +698,9 @@
     acb1->ov.OffsetHigh = offset >> 32;
     acb1->ov.hEvent = acb1->hEvent;
     acb1->count = nb_sectors * 512;
+#ifndef QEMU_TOOL
     qemu_add_wait_object(acb1->ov.hEvent, raw_aio_cb, acb);
+#endif
     ret = ReadFile(s->hfile, buf, acb1->count, NULL, &acb1->ov);
     if (!ret)
         return -EIO;
@@ -709,9 +711,11 @@
 {
     BlockDriverState *bs = acb->bs;
     BDRVRawState *s = bs->opaque;
+#ifndef QEMU_TOOL
     RawAIOCB *acb1 = acb->opaque;
 
     qemu_del_wait_object(acb1->ov.hEvent, raw_aio_cb, acb);
+#endif
     /* XXX: if more than one async I/O it is not correct */
     CancelIo(s->hfile);
 }

Index: vl.h
===================================================================
RCS file: /sources/qemu/qemu/vl.h,v
retrieving revision 1.137

vl.h +1 -0
diff -u -r1.137 vl.h
@@ -46,6 +46,7 @@
 #endif
 
 #ifdef _WIN32
+#define WINVER 0x0500
 #include <windows.h>
 #define fsync _commit
 #define lseek _lseeki64
#3 lore raw
Quoted 10 lines · Kazu

Asynchronous I/O is implemented by overlapped I/O for Win32 but it is not enabled.

I tried to make the program. A patch attached fixs compile errors.

I found some problems about it.
GetFileSizeEx needs to define WINVER 0x0500. It means that Windows 98/Me host is not supported.
If we try to support Win 98/Me host, it is necessary to change configure

to

Quoted 5 lines

use --enable-win9x and make another binary, etc.

The first attempt to open a hard disk image with a drive letter always failed. After the second time is OK.

An attached patch fixes the bug which is first time read error.

Regards,
Kazu

Index: block-raw.c
===================================================================
RCS file: /sources/qemu/qemu/block-raw.c,v
retrieving revision 1.2

block-raw.c +26 -18
diff -u -r1.2 block-raw.c
@@ -518,7 +518,6 @@
 #else /* _WIN32 */
 
 /* XXX: use another file ? */
-#include <windows.h>
 #include <winioctl.h>
 
 typedef struct BDRVRawState {
@@ -600,12 +599,14 @@
     memset(&ov, 0, sizeof(ov));
     ov.Offset = offset;
     ov.OffsetHigh = offset >> 32;
-    ret = ReadFile(s->hfile, buf, count, NULL, &ov);
-    if (!ret)
-        return -EIO;
-    ret = GetOverlappedResult(s->hfile, &ov, &ret_count, TRUE);
-    if (!ret)
-        return -EIO;
+    ret = ReadFile(s->hfile, buf, count, &ret_count, &ov);
+    if (!ret) {
+        ret = GetOverlappedResult(s->hfile, &ov, &ret_count, TRUE);
+        if (!ret)
+            return -EIO;
+        else
+            return ret_count;
+    }
     return ret_count;
 }
 
@@ -620,30 +621,31 @@
     memset(&ov, 0, sizeof(ov));
     ov.Offset = offset;
     ov.OffsetHigh = offset >> 32;
-    ret = WriteFile(s->hfile, buf, count, NULL, &ov);
-    if (!ret)
-        return -EIO;
-    ret = GetOverlappedResult(s->hfile, &ov, &ret_count, TRUE);
-    if (!ret)
-        return -EIO;
+    ret = WriteFile(s->hfile, buf, count, &ret_count, &ov);
+    if (!ret) {
+        ret = GetOverlappedResult(s->hfile, &ov, &ret_count, TRUE);
+        if (!ret)
+            return -EIO;
+        else
+            return ret_count;
+    }
     return ret_count;
 }
 
 static int raw_aio_new(BlockDriverAIOCB *acb)
 {
     RawAIOCB *acb1;
-    BDRVRawState *s = acb->bs->opaque;
 
     acb1 = qemu_mallocz(sizeof(RawAIOCB));
     if (!acb1)
         return -ENOMEM;
     acb->opaque = acb1;
-    s->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
-    if (!s->hEvent)
+    acb1->hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+    if (!acb1->hEvent)
         return -ENOMEM;
     return 0;
 }
-
+#ifndef QEMU_TOOL
 static void raw_aio_cb(void *opaque)
 {
     BlockDriverAIOCB *acb = opaque;
@@ -660,7 +662,7 @@
         acb->cb(acb->cb_opaque, 0);
     }
 }
-
+#endif
 static int raw_aio_read(BlockDriverAIOCB *acb, int64_t sector_num, 
                         uint8_t *buf, int nb_sectors)
 {
@@ -676,7 +678,9 @@
     acb1->ov.OffsetHigh = offset >> 32;
     acb1->ov.hEvent = acb1->hEvent;
     acb1->count = nb_sectors * 512;
+#ifndef QEMU_TOOL
     qemu_add_wait_object(acb1->ov.hEvent, raw_aio_cb, acb);
+#endif
     ret = ReadFile(s->hfile, buf, acb1->count, NULL, &acb1->ov);
     if (!ret)
         return -EIO;
@@ -698,7 +702,9 @@
     acb1->ov.OffsetHigh = offset >> 32;
     acb1->ov.hEvent = acb1->hEvent;
     acb1->count = nb_sectors * 512;
+#ifndef QEMU_TOOL
     qemu_add_wait_object(acb1->ov.hEvent, raw_aio_cb, acb);
+#endif
     ret = ReadFile(s->hfile, buf, acb1->count, NULL, &acb1->ov);
     if (!ret)
         return -EIO;
@@ -709,9 +715,11 @@
 {
     BlockDriverState *bs = acb->bs;
     BDRVRawState *s = bs->opaque;
+#ifndef QEMU_TOOL
     RawAIOCB *acb1 = acb->opaque;
 
     qemu_del_wait_object(acb1->ov.hEvent, raw_aio_cb, acb);
+#endif
     /* XXX: if more than one async I/O it is not correct */
     CancelIo(s->hfile);
 }

Index: vl.h
===================================================================
RCS file: /sources/qemu/qemu/vl.h,v
retrieving revision 1.137

vl.h +1 -0
diff -u -r1.137 vl.h
@@ -46,6 +46,7 @@
 #endif
 
 #ifdef _WIN32
+#define WINVER 0x0500
 #include <windows.h>
 #define fsync _commit
 #define lseek _lseeki64