mingw compile error patch
Hi,
The patch below allows me to compile qemu on Windows, however it is still not working.
The program exits immediately reporting that it can't open the hard disk image.
GDB reports the offensive pies of code is in malloc(), which does not make sense to me.
Am I doing something wrong?
qemu_mallocz (size=2680) at c:/qemu/osdep.c:190
190 ptr = qemu_malloc(size);
(gdb)
188 {
(gdb)
190 ptr = qemu_malloc(size);
(gdb)qemu_malloc (size=2680) at c:/qemu/osdep.c:56
56 return malloc(size);
(gdb)
Program exited with code 01.
(gdb) where
(gdb) No stack.
---------patch------------
RCS file: /sources/qemu/qemu/block-raw.c,v
retrieving revision 1.7
diff -r1.7 block-raw.c
821a822,823
Quoted 2 lines
static int
find_cdrom(char *cdrom_name, int cdrom_name_size); static intfind_device_type(const char *filename);
1095c1097
< LARGE_INTEGER l;
---
Quoted 1 line
ULARGE_INTEGER l;
1098c1100
< switch(s->ftype) {
---
Quoted 1 line
switch(s->type) {1185c1187
< memset(drives, 0, sizeof(drivers));
---
Quoted 1 line
memset(drives, 0, sizeof(drives));
1204c1206
<
---
Quoted 1 line
char drive_letter[2];
1207,1209c1209,1211
< s->drive_letter[0] = p[0]; < s->drive_letter[1] = '\0'; < type = GetDriveType(s->drive_letter);
---
Quoted 3 lines
drive_letter[0] = p[0];
drive_letter[1] = '\0';
type = GetDriveType(drive_letter);Quoted 9 lines · alex
Hi,
The patch below allows me to compile qemu on Windows, however it is still not working.
The program exits immediately reporting that it can't open the hard disk image.
GDB reports the offensive pies of code is inmalloc(), which does not make sense to me.
Am I doing something wrong?
An attached patch fixes compile error for win32.
It also fixes using /dev/cdrom and a file name with a drive letter. Qcow is not fixed.
Regards,
Kazu
Index: block-raw.c
===================================================================
RCS file: /sources/qemu/qemu/block-raw.c,v
retrieving revision 1.7
block-raw.c +13 -9
@@ -871,13 +871,15 @@ NULL, 0, NULL, 0, &returned, NULL); } +static int find_cdrom (char *cdrom_name,int cdrom_name_size); +static int find_device_type (BlockDriverState *bs,const char *filename); +static int raw_open (BlockDriverState *bs,const char *filename,int flags) {BDRVRawState *s = bs->opaque;int access_flags, create_flags;DWORD overlapped;char device_name[64 ]; -const char *p;if (strstart (filename,"/dev/cdrom" ,NULL )) {if (find_cdrom (device_name,sizeof (device_name)) <0 )
@@ -892,7 +894,7 @@ filename = device_name; } } - s->type =find_device_type (filename); + s->type =find_device_type (bs, filename);if ((flags &BDRV_O_ACCESS ) ==O_RDWR ) { access_flags =GENERIC_READ |GENERIC_WRITE ;
@@ -1095,7 +1097,7 @@LARGE_INTEGER l;ULARGE_INTEGER available, total, total_free; -switch (s->ftype) { +switch (s->type) {case FTYPE_FILE : l.LowPart =GetFileSize (s->hfile, &l.HighPart);if (l.LowPart ==0xffffffffUL &&GetLastError () !=NO_ERROR )
@@ -1104,7 +1106,7 @@case FTYPE_CD :if (!GetDiskFreeSpaceEx (s->drive_letter, &available, &total, &total_free))return -EIO ; - l = total; + l.QuadPart = total.QuadPart;break ;default :return -EIO ;
@@ -1182,7 +1184,7 @@char drives[256 ], *pdrv = drives;UINT type; -memset (drives,0 ,sizeof (drivers)); +memset (drives,0 ,sizeof (drives));GetLogicalDriveStrings (sizeof (drives), drives);while (pdrv[0 ] !='\0' ) { type =GetDriveType (pdrv);
@@ -1197,16 +1199,19 @@return -1 ; } -static int find_device_type (const char *filename) +static int find_device_type (BlockDriverState *bs,const char *filename) { +BDRVRawState *s = bs->opaque;UINT type;const char *p; +char root_path[4 ];if (strstart (filename,"\\\\.\\" , &p) ||strstart (filename,"//./" , &p)) { s->drive_letter[0 ] = p[0 ]; s->drive_letter[1 ] ='\0' ; - type =GetDriveType (s->drive_letter); +snprintf (root_path,sizeof (root_path),"%c:\\" , p[0 ]); + type =GetDriveType (root_path);if (type ==DRIVE_CDROM )return FTYPE_CD ;else
@@ -1222,7 +1227,6 @@int access_flags, create_flags;DWORD overlapped;char device_name[64 ]; -const char *p;if (strstart (filename,"/dev/cdrom" ,NULL )) {if (find_cdrom (device_name,sizeof (device_name)) <0 )
@@ -1237,7 +1241,7 @@ filename = device_name; } } - s->type =find_device_type (filename); + s->type =find_device_type (bs, filename);if ((flags &BDRV_O_ACCESS ) ==O_RDWR ) { access_flags =GENERIC_READ |GENERIC_WRITE ;
Index: block.c
===================================================================
RCS file: /sources/qemu/qemu/block.c,v
retrieving revision 1.34
block.c +11 -2
@@ -182,11 +182,18 @@#endif #ifdef _WIN32 -static int is_windows_drive (const char *filename) +static int is_windows_file (const char *filename) {if (((filename[0 ] >='a' && filename[0 ] <='z' ) || (filename[0 ] >='A' && filename[0 ] <='Z' )) && - filename[1 ] ==':' && filename[2 ] =='\0' ) + filename[1 ] ==':' ) +return 1 ; +return 0 ; +} + +static int is_windows_drive (const char *filename) +{ +if (is_windows_file (filename) && filename[2 ] =='\0' )return 1 ;if (strstart (filename,"\\\\.\\" ,NULL ) ||strstart (filename,"//./" ,NULL ))
@@ -205,6 +212,8 @@#ifdef _WIN32if (is_windows_drive (filename))return &bdrv_raw; +if (is_windows_file (filename)) +return &bdrv_raw;#endif p =strchr (filename,':' );if (!p)
That's better. What's wrong with QCOW?
Signature · 4 lines
Alex. "Kazu" <[email protected]> wrote in message news:001401c6c5a2$84edab20$0464a8c0@athlon...
Quoted 13 lines
Quoted 10 lines · alex
Hi,
The patch below allows me to compile qemu on Windows, however it is still not working.
The program exits immediately reporting that it can't open the hard disk image.
GDB reports the offensive pies of code is inmalloc(), which does not make
sense to me.
Am I doing something wrong?
Quoted 7 lines
An attached patch fixes compile error for win32.
It also fixes using/dev/cdromand a file name with a drive letter. Qcow is not fixed.Regards,
Kazu
--------------------------------------------------------------------------------
Quoted 5 lines
_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Quoted 2 lines · Alex
That's better. What's wrong with QCOW?
Qcow uses aio interface but aio emulation is not fully implemented.
Regards,
Kazu
Is anybody actively working on that?
Any hints of what should be done to make it work?
Looking at the code, I see that qemu_aio_init, qemu_aio_poll, qemu_aio_wait_start, qemu_aio_wait, and qemu_aio_wait_end under _WIN32 have empty bodies. Is this intentional or what should happen there?
"Kazu" <[email protected]> wrote in message
news:000c01c6c5be$fdffdda0$0464a8c0@athlon...
Quoted 9 lines
Quoted 2 lines · Alex
That's better. What's wrong with QCOW?
Qcow uses aio interface but aio emulation is not fully implemented.
Regards,
Kazu