Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-25 Thread Thiemo Seufer
Johannes Schindelin wrote:
 Hi,
 
 On Wed, 24 Oct 2007, Thiemo Seufer wrote:
 
  Johannes Schindelin wrote:
  
   Staying backwards compatible in this case is so easy, it is not even 
   funny.  (And certainly no reason to groan over having to support it.)
  
  A undirected remark to the general public: If somebody comes up with a 
  patch for better backward compatibility I'll certainly consider it.
 
 I think I fixed it.  Since I am not your regular Windows user (I only use 
 Windows when I have to), I cannot tell if it works, though.
 
 It is here: http://repo.or.cz/w/qemu/dscho.git?a=shortlog;h=diskgeometry
 
 Any testing (especially the physical drive on Windows  XP) would be very 
 much appreciated.
 
 There is also a compilation bugfix with the current CVS on Windows: the 
 tap down script patch left a for() loop without a body.
 
 A question: on some other lists, the preferred way to submit patches is to 
 inline them into the mail, but here I saw many attachments and/or weblinks 
 to patches.  The easiest way for me would be like I just did: provide 
 a link to repo.or.cz.
 
 What is the preferred way on this list?

I prefer inlined or attached patches, so they get archived and don't
develop a 404 problem over time.


Thiemo




Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-24 Thread Ivan Kalvachev
2007/10/22, Stefan Weil [EMAIL PROTECTED]:
 Ivan Kalvachev schrieb:
  According to http://msdn2.microsoft.com/en-us/library/aa365171.aspx
 
  this function requires Win XP or Vista.
  Is qemu supported only on these?
 Good question. The old IOCTL_DISK_GET_DRIVE_GEOMETRY
 was also supported for W2K. Will QEMU support W2K as a host
 longer than MS does? It would make things easier if we
 dropped support for W2K hosts.

 If we need host support for W2K, I'll check another method
 to get the disk size (reading size of partition 0) and send
 a new patch. Please send your feedback in this case.

 I hope we don't need W95 or W98 host support!?

Why not. :P

Anyway, calling the old ioctl code if the new one fails, should be
compatible enough. (and the new structure contains the old one, so no
need of having 2 variables).

It would be even better if somebody finds out what the error for not
supported function is (I don't feel like checking 16000 error codes),
but it is not critical.




Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-24 Thread Johannes Schindelin
Hi,

On Wed, 24 Oct 2007, Ivan Kalvachev wrote:

 2007/10/22, Stefan Weil [EMAIL PROTECTED]:
  Ivan Kalvachev schrieb:
   According to http://msdn2.microsoft.com/en-us/library/aa365171.aspx
  
   this function requires Win XP or Vista.
   Is qemu supported only on these?
  Good question. The old IOCTL_DISK_GET_DRIVE_GEOMETRY
  was also supported for W2K. Will QEMU support W2K as a host
  longer than MS does? It would make things easier if we
  dropped support for W2K hosts.
 
  If we need host support for W2K, I'll check another method
  to get the disk size (reading size of partition 0) and send
  a new patch. Please send your feedback in this case.
 
  I hope we don't need W95 or W98 host support!?
 
 Why not. :P
 
 Anyway, calling the old ioctl code if the new one fails, should be
 compatible enough. (and the new structure contains the old one, so no
 need of having 2 variables).

It is not just that.  You'll have to guard the new ioctl within #ifdef's 
so that it still compiles on MinGW, even if that version does not define 
the constant.

Staying backwards compatible in this case is so easy, it is not even 
funny.  (And certainly no reason to groan over having to support it.)

Ciao,
Dscho





Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-24 Thread Thiemo Seufer
Johannes Schindelin wrote:
 Hi,
 
 On Wed, 24 Oct 2007, Ivan Kalvachev wrote:
 
  2007/10/22, Stefan Weil [EMAIL PROTECTED]:
   Ivan Kalvachev schrieb:
According to http://msdn2.microsoft.com/en-us/library/aa365171.aspx
   
this function requires Win XP or Vista.
Is qemu supported only on these?
   Good question. The old IOCTL_DISK_GET_DRIVE_GEOMETRY
   was also supported for W2K. Will QEMU support W2K as a host
   longer than MS does? It would make things easier if we
   dropped support for W2K hosts.
  
   If we need host support for W2K, I'll check another method
   to get the disk size (reading size of partition 0) and send
   a new patch. Please send your feedback in this case.
  
   I hope we don't need W95 or W98 host support!?
  
  Why not. :P
  
  Anyway, calling the old ioctl code if the new one fails, should be
  compatible enough. (and the new structure contains the old one, so no
  need of having 2 variables).
 
 It is not just that.  You'll have to guard the new ioctl within #ifdef's 
 so that it still compiles on MinGW, even if that version does not define 
 the constant.
 
 Staying backwards compatible in this case is so easy, it is not even 
 funny.  (And certainly no reason to groan over having to support it.)

A undirected remark to the general public: If somebody comes up with a
patch for better backward compatibility I'll certainly consider it.


Thiemo





Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-24 Thread Johannes Schindelin
Hi,

On Wed, 24 Oct 2007, Thiemo Seufer wrote:

 Johannes Schindelin wrote:
 
  Staying backwards compatible in this case is so easy, it is not even 
  funny.  (And certainly no reason to groan over having to support it.)
 
 A undirected remark to the general public: If somebody comes up with a 
 patch for better backward compatibility I'll certainly consider it.

I think I fixed it.  Since I am not your regular Windows user (I only use 
Windows when I have to), I cannot tell if it works, though.

It is here: http://repo.or.cz/w/qemu/dscho.git?a=shortlog;h=diskgeometry

Any testing (especially the physical drive on Windows  XP) would be very 
much appreciated.

There is also a compilation bugfix with the current CVS on Windows: the 
tap down script patch left a for() loop without a body.

A question: on some other lists, the preferred way to submit patches is to 
inline them into the mail, but here I saw many attachments and/or weblinks 
to patches.  The easiest way for me would be like I just did: provide 
a link to repo.or.cz.

What is the preferred way on this list?

Ciao,
Dscho





Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-24 Thread Stefan Weil
Johannes Schindelin schrieb:
 I think I fixed it. Since I am not your regular Windows user (I only use

 Windows when I have to), I cannot tell if it works, though.

 It is here: http://repo.or.cz/w/qemu/dscho.git?a=shortlog;h=diskgeometry

 Any testing (especially the physical drive on Windows  XP) would be very
 much appreciated.
 ...
 Ciao,
 Dscho
With your patch, W2K will still see a wrong disk size.
This is caused by the fact that the size of a modern harddisk
has nothing to do with tracks per cylinder or sectors per track
- it is not simply the product of four values.

You can use a disk to some degree even when some part at
the end is inaccessible, but it is also possible to destroy
it (for example if a partition tool corrects the disk
size in the boot sector) or get other kinds of errors.

I prefer a patch which gives correct values for all
Windows versions and will send one as soon as possible.

Even without a patch, the current code in CVS HEAD
still allows compilation using MinGW on any Windows.
QEMU will also run on the same Windows variants as
before. The only thing no longer working on W2K and
older variants is physical hard disk access. I think
this is better than working with a wrong disk size!

Regards,
Stefan





Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-24 Thread Johannes Schindelin
Hi,

On Wed, 24 Oct 2007, Stefan Weil wrote:

 Johannes Schindelin schrieb:
  I think I fixed it. Since I am not your regular Windows user (I only 
  use Windows when I have to), I cannot tell if it works, though.
 
  It is here: 
  http://repo.or.cz/w/qemu/dscho.git?a=shortlog;h=diskgeometry
 
  Any testing (especially the physical drive on Windows  XP) would be 
  very much appreciated. ... Ciao, Dscho

 With your patch, W2K will still see a wrong disk size.

Funny.  I thought that since kazu did the original patch, and kazu is a 
Windows user, that it worked at _some_ stage.

Also I have to note that IOCTL_DISK_GET_DRIVE_GEOMETRY is a Windows 2000 
feature, so unfortunately there is really no backwards compatibility to 
Windows 95/98/ME.

 This is caused by the fact that the size of a modern harddisk has 
 nothing to do with tracks per cylinder or sectors per track - it is not 
 simply the product of four values.

Since it obviously worked in one setting, there might be a chance that it 
is fixable.  Could you be a little bit more specific in what is going 
wrong?  I.e. what is the real size, and what are the four values?

 Even without a patch, the current code in CVS HEAD
 still allows compilation using MinGW on any Windows.

Yes, but a setup that was evidently working before was broken.

Ciao,
Dscho





Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-22 Thread Ivan Kalvachev
2007/10/19, Stefan Weil [EMAIL PROTECTED]:
 Hi,

 raw harddisk access for Windows (//./PhysicalDrive0) gives wrong disk sizes.
 You can check this by booting a harddisk with the GRUB bootloader installed
 and using GRUB's geometry command.

 The current QEMU code uses IOCTL_DISK_GET_DRIVE_GEOMETRY which is marked
 as obsolete by MS.

 The appended patch gives correct results. Please apply it to CVS.

 Stefan

 Description of block-raw.patch:

 * replace IOCTL_DISK_GET_DRIVE_GEOMETRY by IOCTL_DISK_GET_DRIVE_GEOMETRY_EX


According to http://msdn2.microsoft.com/en-us/library/aa365171.aspx
this function requires Win XP or Vista.
Is qemu supported only on these?




Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-22 Thread Stefan Weil
Ivan Kalvachev schrieb:
 According to http://msdn2.microsoft.com/en-us/library/aa365171.aspx

 this function requires Win XP or Vista.
 Is qemu supported only on these?
Good question. The old IOCTL_DISK_GET_DRIVE_GEOMETRY
was also supported for W2K. Will QEMU support W2K as a host
longer than MS does? It would make things easier if we
dropped support for W2K hosts.

If we need host support for W2K, I'll check another method
to get the disk size (reading size of partition 0) and send
a new patch. Please send your feedback in this case.

I hope we don't need W95 or W98 host support!?

Stefan





Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-22 Thread Johannes Schindelin
Hi,

On Mon, 22 Oct 2007, Stefan Weil wrote:

 Ivan Kalvachev schrieb:
  According to http://msdn2.microsoft.com/en-us/library/aa365171.aspx
 
  this function requires Win XP or Vista.
  Is qemu supported only on these?

 Good question. The old IOCTL_DISK_GET_DRIVE_GEOMETRY was also supported 
 for W2K. Will QEMU support W2K as a host longer than MS does? It would 
 make things easier if we dropped support for W2K hosts.

Do we really want to be as evil as Microsoft and force all users to 
upgrade?

It should not be _that_ hard to stay at least a _little_ backwards 
compatible.

Ciao,
Dscho





Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-22 Thread Shaddy Baddah

Hi,

Stefan Weil wrote:

longer than MS does? It would make things easier if we
dropped support for W2K hosts.
  

Surely not?!? I've heard of people being off hand about supporting
Win95/98 (and I would agree with that) et al..., but surely W2K support
should be sacrosanct ?!?

Regards,
Shaddy






Re: [Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-22 Thread Jamie Lokier
Shaddy Baddah wrote:
 longer than MS does? It would make things easier if we
 dropped support for W2K hosts.
   
 Surely not?!? I've heard of people being off hand about supporting
 Win95/98 (and I would agree with that) et al..., but surely W2K support
 should be sacrosanct ?!?

I would hope so, as I get the impression W2K is the last Windows
version which can be run reliably in a VM, due to the legitimacy
checking done by XP and later. :-)

-- Jamie




[Qemu-devel] [PATCH] Physical hard disk drive for win32

2007-10-19 Thread Stefan Weil
Hi,

raw harddisk access for Windows (//./PhysicalDrive0) gives wrong disk sizes.
You can check this by booting a harddisk with the GRUB bootloader installed
and using GRUB's geometry command.

The current QEMU code uses IOCTL_DISK_GET_DRIVE_GEOMETRY which is marked
as obsolete by MS.

The appended patch gives correct results. Please apply it to CVS.

Stefan

Description of block-raw.patch:

* replace IOCTL_DISK_GET_DRIVE_GEOMETRY by IOCTL_DISK_GET_DRIVE_GEOMETRY_EX


Index: block-raw.c
===
RCS file: /sources/qemu/qemu/block-raw.c,v
retrieving revision 1.24
diff -u -b -B -r1.24 block-raw.c
--- block-raw.c	21 Sep 2007 06:09:39 -	1.24
+++ block-raw.c	19 Oct 2007 19:53:48 -
@@ -1174,7 +1174,7 @@
 BDRVRawState *s = bs-opaque;
 LARGE_INTEGER l;
 ULARGE_INTEGER available, total, total_free;
-DISK_GEOMETRY dg;
+DISK_GEOMETRY_EX dg;
 DWORD count;
 BOOL status;
 
@@ -1190,11 +1190,10 @@
 l.QuadPart = total.QuadPart;
 break;
 case FTYPE_HARDDISK:
-status = DeviceIoControl(s-hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY,
+status = DeviceIoControl(s-hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
  NULL, 0, dg, sizeof(dg), count, NULL);
-if (status != FALSE) {
-l.QuadPart = dg.Cylinders.QuadPart * dg.TracksPerCylinder
-* dg.SectorsPerTrack * dg.BytesPerSector;
+if (status != 0) {
+l = dg.DiskSize;
 }
 break;
 default: