From: Stefan Weil <weil@mail.berlios.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Physical hard disk drive for win32
Date: Fri, 19 Oct 2007 22:12:23 +0200 [thread overview]
Message-ID: <47190FA7.80108@mail.berlios.de> (raw)
In-Reply-To: <002501c6dfd2$5e5ae820$0464a8c0@athlon>
[-- Attachment #1: Type: text/plain, Size: 473 bytes --]
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
[-- Attachment #2: block-raw.patch --]
[-- Type: text/x-diff, Size: 1088 bytes --]
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:
next prev parent reply other threads:[~2007-10-19 20:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-24 4:01 [Qemu-devel] Physical hard disk drive for win32 Kazu
2006-09-24 9:14 ` Alexey Eremenko
2006-09-24 12:10 ` Kazu
2007-10-19 20:12 ` Stefan Weil [this message]
2007-10-22 11:33 ` [Qemu-devel] [PATCH] " Ivan Kalvachev
2007-10-22 18:25 ` Stefan Weil
2007-10-22 19:07 ` Johannes Schindelin
2007-10-23 0:31 ` Shaddy Baddah
2007-10-23 3:34 ` Jamie Lokier
2007-10-24 9:46 ` Ivan Kalvachev
2007-10-24 10:03 ` Johannes Schindelin
2007-10-24 12:33 ` Thiemo Seufer
2007-10-24 17:32 ` Johannes Schindelin
2007-10-24 18:41 ` Stefan Weil
2007-10-25 0:26 ` Johannes Schindelin
2007-10-25 10:04 ` Thiemo Seufer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47190FA7.80108@mail.berlios.de \
--to=weil@mail.berlios.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).