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 -0000	1.24
+++ block-raw.c	19 Oct 2007 19:53:48 -0000
@@ -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:

Reply via email to