qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Physical hard disk drive for win32
@ 2006-09-24  4:01 Kazu
  2006-09-24  9:14 ` Alexey Eremenko
  0 siblings, 1 reply; 16+ messages in thread
From: Kazu @ 2006-09-24  4:01 UTC (permalink / raw)
  To: qemu-devel

[-- 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)

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-10-25 10:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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     ` [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

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).