From: "Kazu" <kazoo@r3.dion.ne.jp>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Physical hard disk drive for win32
Date: Sun, 24 Sep 2006 13:01:57 +0900 [thread overview]
Message-ID: <001d01c6df8e$2de302c0$0464a8c0@athlon> (raw)
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
Hi,
An attached patch fixes to use raw access to physical hard disk drive for
win32.
It can be used as -hdb \\.\PhysicalDrive0 or -hdb //./PhysicalDrive0.
For example, if the guest OS is Linux, the second partition can be accessed
by /dev/hdb2.
Regards,
Kazu
[-- Attachment #2: qemu-20060922-harddisk.patch --]
[-- Type: application/octet-stream, Size: 1818 bytes --]
Index: block-raw.c
===================================================================
RCS file: /sources/qemu/qemu/block-raw.c,v
retrieving revision 1.10
diff -u -r1.10 block-raw.c
--- block-raw.c 3 Sep 2006 12:08:37 -0000 1.10
+++ block-raw.c 24 Sep 2006 03:56:44 -0000
@@ -833,6 +833,7 @@
#define FTYPE_FILE 0
#define FTYPE_CD 1
+#define FTYPE_HARDDISK 2
typedef struct BDRVRawState {
HANDLE hfile;
@@ -1090,6 +1091,9 @@
BDRVRawState *s = bs->opaque;
LARGE_INTEGER l;
ULARGE_INTEGER available, total, total_free;
+ DISK_GEOMETRY dg;
+ DWORD count;
+ BOOL status;
switch(s->type) {
case FTYPE_FILE:
@@ -1102,6 +1106,14 @@
return -EIO;
l.QuadPart = total.QuadPart;
break;
+ case FTYPE_HARDDISK:
+ status = DeviceIoControl(s->hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY,
+ NULL, 0, &dg, sizeof(dg), &count, NULL);
+ if (status != FALSE) {
+ l.QuadPart = dg.Cylinders.QuadPart * dg.TracksPerCylinder
+ * dg.SectorsPerTrack * dg.BytesPerSector;
+ }
+ break;
default:
return -EIO;
}
@@ -1201,9 +1213,17 @@
BDRVRawState *s = bs->opaque;
UINT type;
const char *p;
+ char *q;
+ int i;
+ char physical_drive[14];
if (strstart(filename, "\\\\.\\", &p) ||
strstart(filename, "//./", &p)) {
+ for (i = 0, q = p; i < 13; i++, q++) {
+ physical_drive[i] = tolower(*q);
+ }
+ if (strstart(physical_drive, "physicaldrive", NULL))
+ return FTYPE_HARDDISK;
snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", p[0]);
type = GetDriveType(s->drive_path);
if (type == DRIVE_CDROM)
next reply other threads:[~2006-09-24 4:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-24 4:01 Kazu [this message]
2006-09-24 9:14 ` [Qemu-devel] Physical hard disk drive for win32 Alexey Eremenko
2006-09-24 12:10 ` Kazu
2007-10-19 20:12 ` [Qemu-devel] [PATCH] " Stefan Weil
2007-10-22 11:33 ` 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='001d01c6df8e$2de302c0$0464a8c0@athlon' \
--to=kazoo@r3.dion.ne.jp \
--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).