From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAZ62-0008S4-2E for qemu-devel@nongnu.org; Thu, 02 Jul 2015 03:39:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAZ60-00038T-Rh for qemu-devel@nongnu.org; Thu, 02 Jul 2015 03:39:45 -0400 Message-ID: <5594EAB6.5070607@redhat.com> Date: Thu, 02 Jul 2015 09:39:34 +0200 From: Laurent Vivier MIME-Version: 1.0 References: <5594E5C7.9010101@redhat.com> In-Reply-To: <5594E5C7.9010101@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [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: Paolo Bonzini , Programmingkid , Stefan Hajnoczi , Peter Maydell Cc: Kevin Wolf , John Snow , qemu-devel qemu-devel , Qemu-block On 02/07/2015 09:18, Paolo Bonzini wrote: > > > On 02/07/2015 00:13, Programmingkid wrote: >> 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 > > >> >> --- >> 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 = FindEjectableCDMedia( &mediaIterator ); >> kernResult = 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. >> + */ >> + int sizeOfString = strlen("/dev/r"); >> + if (strncmp("/dev/r", bsdPath, sizeOfString) == 0) { >> + sprintf(bsdPath, "/dev/%s", bsdPath + sizeOfString); >> + } > > I think you can just remove the strcat in here: > > if ( bsdPathAsCFString ) { > size_t devPathLength; > strcpy( bsdPath, _PATH_DEV ); > strcat( bsdPath, "r" ); > devPathLength = strlen( bsdPath ); > if ( CFStringGetCString( bsdPathAsCFString, bsdPath + > devPathLength, maxPathSize - devPathLength, kCFStringEncodingASCII ) ) { > kernResult = KERN_SUCCESS; > } > CFRelease( bsdPathAsCFString ); > > So it's still a one-line change. What are the other consequences of > removing the "r"? This code seems to be a cut'n'paste of an Apple example (bad...): https://developer.apple.com/library/mac/samplecode/CDROMSample/Listings/CDROMSample_CDROMSample_c.html Without this interesting comment: Add "r" before the BSD node name from the I/O Registry to specify the raw disknode. The raw disk nodes receive I/O requests directly and do not go through the buffer cache. Laurent