From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GRLBk-0001NB-1p for qemu-devel@nongnu.org; Sun, 24 Sep 2006 00:01:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GRLBi-0001MI-25 for qemu-devel@nongnu.org; Sun, 24 Sep 2006 00:01:55 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GRLBh-0001M6-RM for qemu-devel@nongnu.org; Sun, 24 Sep 2006 00:01:53 -0400 Received: from [211.5.2.73] (helo=nm01omta015.dion.ne.jp) by monty-python.gnu.org with smtp (Exim 4.52) id 1GRLFn-0007Xx-Oy for qemu-devel@nongnu.org; Sun, 24 Sep 2006 00:06:08 -0400 Message-ID: <001d01c6df8e$2de302c0$0464a8c0@athlon> From: "Kazu" Subject: [Qemu-devel] Physical hard disk drive for win32 Date: Sun, 24 Sep 2006 13:01:57 +0900 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0018_01C6DFD9.9D989E40" 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. ------=_NextPart_000_0018_01C6DFD9.9D989E40 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_0018_01C6DFD9.9D989E40 Content-Type: application/octet-stream; name="qemu-20060922-harddisk.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="qemu-20060922-harddisk.patch" Index: block-raw.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /sources/qemu/qemu/block-raw.c,v=0A= retrieving revision 1.10=0A= diff -u -r1.10 block-raw.c=0A= --- block-raw.c 3 Sep 2006 12:08:37 -0000 1.10=0A= +++ block-raw.c 24 Sep 2006 03:56:44 -0000=0A= @@ -833,6 +833,7 @@=0A= =0A= #define FTYPE_FILE 0=0A= #define FTYPE_CD 1=0A= +#define FTYPE_HARDDISK 2=0A= =0A= typedef struct BDRVRawState {=0A= HANDLE hfile;=0A= @@ -1090,6 +1091,9 @@=0A= BDRVRawState *s =3D bs->opaque;=0A= LARGE_INTEGER l;=0A= ULARGE_INTEGER available, total, total_free; =0A= + DISK_GEOMETRY dg;=0A= + DWORD count;=0A= + BOOL status;=0A= =0A= switch(s->type) {=0A= case FTYPE_FILE:=0A= @@ -1102,6 +1106,14 @@=0A= return -EIO;=0A= l.QuadPart =3D total.QuadPart;=0A= break;=0A= + case FTYPE_HARDDISK:=0A= + status =3D DeviceIoControl(s->hfile, = IOCTL_DISK_GET_DRIVE_GEOMETRY,=0A= + NULL, 0, &dg, sizeof(dg), &count, = NULL);=0A= + if (status !=3D FALSE) {=0A= + l.QuadPart =3D dg.Cylinders.QuadPart * dg.TracksPerCylinder=0A= + * dg.SectorsPerTrack * dg.BytesPerSector;=0A= + }=0A= + break;=0A= default:=0A= return -EIO;=0A= }=0A= @@ -1201,9 +1213,17 @@=0A= BDRVRawState *s =3D bs->opaque;=0A= UINT type;=0A= const char *p;=0A= + char *q;=0A= + int i;=0A= + char physical_drive[14];=0A= =0A= if (strstart(filename, "\\\\.\\", &p) ||=0A= strstart(filename, "//./", &p)) {=0A= + for (i =3D 0, q =3D p; i < 13; i++, q++) {=0A= + physical_drive[i] =3D tolower(*q);=0A= + }=0A= + if (strstart(physical_drive, "physicaldrive", NULL))=0A= + return FTYPE_HARDDISK;=0A= snprintf(s->drive_path, sizeof(s->drive_path), "%c:\\", p[0]);=0A= type =3D GetDriveType(s->drive_path);=0A= if (type =3D=3D DRIVE_CDROM)=0A= ------=_NextPart_000_0018_01C6DFD9.9D989E40--