From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IiyCv-0006Yf-2n for qemu-devel@nongnu.org; Fri, 19 Oct 2007 16:12:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IiyCq-0006VO-2r for qemu-devel@nongnu.org; Fri, 19 Oct 2007 16:12:32 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IiyCp-0006VE-Ub for qemu-devel@nongnu.org; Fri, 19 Oct 2007 16:12:27 -0400 Received: from moutng.kundenserver.de ([212.227.126.177]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IiyCp-0000K5-BC for qemu-devel@nongnu.org; Fri, 19 Oct 2007 16:12:27 -0400 Message-ID: <47190FA7.80108@mail.berlios.de> Date: Fri, 19 Oct 2007 22:12:23 +0200 From: Stefan Weil MIME-Version: 1.0 Subject: [Qemu-devel] [PATCH] Physical hard disk drive for win32 References: <001d01c6df8e$2de302c0$0464a8c0@athlon> <7fac565a0609240214u5eca5cedka8a023ab562a87f7@mail.gmail.com> <002501c6dfd2$5e5ae820$0464a8c0@athlon> In-Reply-To: <002501c6dfd2$5e5ae820$0464a8c0@athlon> Content-Type: multipart/mixed; boundary="------------090500030901090808030407" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------090500030901090808030407 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 --------------090500030901090808030407 Content-Type: text/x-diff; name="block-raw.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="block-raw.patch" 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: --------------090500030901090808030407--