From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EFOUJ-0001Jw-FV for qemu-devel@nongnu.org; Wed, 14 Sep 2005 00:03:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EFOUG-0001IT-Gg for qemu-devel@nongnu.org; Wed, 14 Sep 2005 00:03:10 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EFOU5-0000vr-LP for qemu-devel@nongnu.org; Wed, 14 Sep 2005 00:02:57 -0400 Received: from [211.5.2.75] (helo=nm01omta01f.dion.ne.jp) by monty-python.gnu.org with smtp (Exim 4.34) id 1EFO9M-0008JA-Lv for qemu-devel@nongnu.org; Tue, 13 Sep 2005 23:41:33 -0400 Message-ID: <005a01c5b8de$373f1a20$0464a8c0@athlon> From: "Kazu" Subject: [Qemu-devel] Real hard disk drive for Win2k/XP host Date: Wed, 14 Sep 2005 12:41:39 +0900 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0057_01C5B929.A6FE2B80" 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_0057_01C5B929.A6FE2B80 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit Hi, This patch supports a real hard disk drive by \\.\PhysicalDriveN (N=0,1,2,...) on Windows 2000/XP host. Windows 98/Me are not supported. You can also use slash like //./PhysicalDriveN. You can see a number in Administration Tools in Control Panel. This is not case-sensitive. It is necessary to have an administrative priviledge.This can be used like this. > qemu.exe -L .\bios -hda win2k.img -hdb \\.\PhysicalDrive0 This patch also adds a size information about CD-ROM. It is safe to use it as a read-only. Making a file from guest OS to real hard disk isn't recognized immediately. Rebooting a host OS recognized the file. Making a directory from guest OS breaks a host's file system. There is a case that changes of files in a host OS isn't recognized by a guest OS. Shut down the guest OS, move the file to another directory and boot the guest OS. Then the file is recognized. Windows 98/Me doesn't recognize NTFS file system. When you use Windows XP on NTFS, Windows 98/Me guest can't see host files. If you don't have a multi-boot environment, don't boot from your system hard disk. >qemu.exe -L .\bios -hda \\.\PhysicalDrive0 It will break your host OS. Regards, Kazu ------=_NextPart_000_0057_01C5B929.A6FE2B80 Content-Type: application/octet-stream; name="qemu-0.7.2-hd.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="qemu-0.7.2-hd.patch" diff -ur qemu-0.7.2.orig/block.c qemu-0.7.2/block.c=0A= --- qemu-0.7.2.orig/block.c Mon Sep 5 02:11:31 2005=0A= +++ qemu-0.7.2/block.c Sun Sep 11 17:16:15 2005=0A= @@ -546,6 +546,44 @@=0A= return 1; /* maybe */=0A= }=0A= =0A= +#ifdef _WIN32=0A= +static int64_t get_size(BlockDriverState *bs, const char *filename, int = fd)=0A= +{=0A= + int64_t size;=0A= + BOOL status;=0A= + ULARGE_INTEGER available, total, total_free; =0A= + char *drive_letter;=0A= + HANDLE hHd;=0A= + DISK_GEOMETRY dg;=0A= + DWORD count;=0A= +=0A= + if (bdrv_get_type_hint(bs) =3D=3D BDRV_TYPE_CDROM &&=0A= + (strstart(filename, "//", NULL) || strstart(filename, "\\\\", = NULL))) {=0A= + drive_letter =3D (char *)filename + 4;=0A= + status =3D GetDiskFreeSpaceEx(drive_letter, &available, &total, = &total_free);=0A= + if (status !=3D FALSE){=0A= + return total.QuadPart;=0A= + } else {=0A= + return -1;=0A= + }=0A= + } else if (bdrv_get_type_hint(bs) =3D=3D BDRV_TYPE_HD &&=0A= + (strstart(filename, "//", NULL) || strstart(filename, = "\\\\", NULL))) {=0A= + hHd =3D (HANDLE)_get_osfhandle(fd);=0A= + status =3D DeviceIoControl(hHd, IOCTL_DISK_GET_DRIVE_GEOMETRY,=0A= + NULL, 0, &dg, sizeof(dg), &count, = NULL);=0A= + if (status !=3D FALSE) {=0A= + size =3D dg.Cylinders.QuadPart * dg.TracksPerCylinder=0A= + * dg.SectorsPerTrack * dg.BytesPerSector;=0A= + return size;=0A= + } else {=0A= + return -1;=0A= + }=0A= + }=0A= + size =3D lseek(fd, 0, SEEK_END);=0A= + return size;=0A= +}=0A= +#endif=0A= +=0A= static int raw_open(BlockDriverState *bs, const char *filename)=0A= {=0A= BDRVRawState *s =3D bs->opaque;=0A= @@ -576,8 +614,7 @@=0A= #ifdef _WIN32=0A= /* On Windows hosts it can happen that we're unable to get file size=0A= for CD-ROM raw device (it's inherent limitation of the CDFS = driver). */=0A= - if (size =3D=3D -1)=0A= - size =3D LONG_LONG_MAX;=0A= + size =3D get_size(bs, filename, fd);=0A= #endif=0A= bs->total_sectors =3D size / 512;=0A= s->fd =3D fd;=0A= diff -ur qemu-0.7.2.orig/vl.c qemu-0.7.2/vl.c=0A= --- qemu-0.7.2.orig/vl.c Mon Sep 5 02:11:31 2005=0A= +++ qemu-0.7.2/vl.c Sun Sep 11 17:16:15 2005=0A= @@ -61,8 +61,6 @@=0A= #ifdef _WIN32=0A= #include =0A= #include =0A= -#include =0A= -#define getopt_long_only getopt_long=0A= #define memalign(align, size) malloc(size)=0A= #endif=0A= =0A= diff -ur qemu-0.7.2.orig/vl.h qemu-0.7.2/vl.h=0A= --- qemu-0.7.2.orig/vl.h Mon Sep 5 02:11:31 2005=0A= +++ qemu-0.7.2/vl.h Sun Sep 11 17:16:15 2005=0A= @@ -47,6 +47,8 @@=0A= #endif=0A= =0A= #ifdef _WIN32=0A= +#include =0A= +#include =0A= #define lseek _lseeki64=0A= #define ENOTSUP 4096=0A= /* XXX: find 64 bit version */=0A= ------=_NextPart_000_0057_01C5B929.A6FE2B80--