Received: from eggs.gnu.org ([2001:4830:134:3::10]:34349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAQFt-0001bP-RK for qemu-devel@nongnu.org; Wed, 01 Jul 2015 18:13:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAQFo-0000Wa-RH for qemu-devel@nongnu.org; Wed, 01 Jul 2015 18:13:21 -0400 From: Programmingkid Content-Type: multipart/alternative; boundary=Apple-Mail-8-67574981 Date: Wed, 1 Jul 2015 18:13:11 -0400 Message-Id: Mime-Version: 1.0 (Apple Message framework v1084) Subject: [Qemu-devel] [PATCH] raw-posix.c: remove raw device access for cdrom List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Peter Maydell , Paolo Bonzini Cc: Kevin Wolf , Laurent Vivier , John Snow , qemu-devel qemu-devel , Qemu-block --Apple-Mail-8-67574981 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Fix real cdrom access in Mac OS X so it can be used in QEMU. It simply removes the r from a device file's name. This allows for a real cdrom to be accessible to the guest. It has been successfully tested with a Windows XP guest in qemu-system-i386. The qemu-system-ppc emulator doesn't quit anymore, but there is another problem that prevents a=20 real cdrom from working. Signed-off-by: John Arbuckle --- block/raw-posix.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index a967464..3585ed9 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -2096,6 +2096,16 @@ static int hdev_open(BlockDriverState *bs, QDict = *options, int flags, kernResult =3D FindEjectableCDMedia( &mediaIterator ); kernResult =3D GetBSDPath( mediaIterator, bsdPath, sizeof( = bsdPath ) ); =20 + /* + * Remove the r from cdrom block device if needed. + * /dev/rdisk1 would become /dev/disk1. + * The r means raw access. It doesn't work well. + */ + int sizeOfString =3D strlen("/dev/r"); + if (strncmp("/dev/r", bsdPath, sizeOfString) =3D=3D 0) { + sprintf(bsdPath, "/dev/%s", bsdPath + sizeOfString); + } + if ( bsdPath[ 0 ] !=3D '\0' ) { strcat(bsdPath,"s0"); /* some CDs don't have a partition 0 */ --=20 1.7.5.4 --Apple-Mail-8-67574981 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Fix = real cdrom access in Mac OS X so it can be used in QEMU.
It = simply removes the r from a device file's name. This
allows = for a real cdrom to be accessible to the guest.
It has = been successfully tested with a Windows XP guest
in = qemu-system-i386. The qemu-system-ppc emulator doesn't
quit = anymore, but there is another problem that = prevents a 
real cdrom from working.
Signed-off-by: John Arbuckle <programmingkidx@gmail.com>= ;

---
 block/raw-posix.c | =   10 ++++++++++
 1 files changed, 10 insertions(+), 0 = deletions(-)

diff --git a/block/raw-posix.c = b/block/raw-posix.c
index a967464..3585ed9 100644
--- = a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ = -2096,6 +2096,16 @@ static int hdev_open(BlockDriverState *bs, QDict = *options, int flags,
         kernResult =3D = FindEjectableCDMedia( &mediaIterator );
       =   kernResult =3D GetBSDPath( mediaIterator, bsdPath, sizeof( = bsdPath ) );

 

+        = /*
+ =         * Remove the r from cdrom block device if = needed.
+         * /dev/rdisk1 would = become /dev/disk1.
+         * The r means raw = access. It doesn't work well.
+         = */
+        if (strncmp("/dev/r", = bsdPath, sizeOfString) =3D=3D 0) {
+          =   sprintf(bsdPath, "/dev/%s", bsdPath + sizeOfString);
+
         if = ( bsdPath[ 0 ] !=3D '\0' ) {
         =     strcat(bsdPath,"s0");
         =     /* some CDs don't have a partition 0 */
1.7.5.4