Received: from eggs.gnu.org ([2001:4830:134:3::10]:41738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z88oP-0005h5-Q7 for qemu-devel@nongnu.org; Thu, 25 Jun 2015 11:11:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z88oL-0000a1-NS for qemu-devel@nongnu.org; Thu, 25 Jun 2015 11:11:33 -0400 Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: multipart/alternative; boundary=Apple-Mail-3--476131923 From: Programmingkid In-Reply-To: <20150625133106.GL4419@stefanha-thinkpad.redhat.com> Date: Thu, 25 Jun 2015 11:11:24 -0400 Message-Id: <831C3655-C8DD-412C-AE88-42AC9B419F0C@gmail.com> References: <3B3C7431-1003-4AAA-90AF-0E1A154DFBE2@gmail.com> <5589A026.5020800@redhat.com> <455CF92B-58FA-446D-9EB0-42661C23B739@gmail.com> <20150625133106.GL4419@stefanha-thinkpad.redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] block.c: fix real cdrom detection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Peter Maydell , John Snow , qemu-devel qemu-devel , Qemu-block --Apple-Mail-3--476131923 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Jun 25, 2015, at 9:31 AM, Stefan Hajnoczi wrote: > On Tue, Jun 23, 2015 at 02:26:51PM -0400, Programmingkid wrote: >>=20 >> On Jun 23, 2015, at 2:06 PM, John Snow wrote: >>=20 >>>=20 >>>=20 >>> On 06/23/2015 01:56 PM, Programmingkid wrote: >>>> Fix real cdrom detection so that a real cdrom can actually be used. >>>>=20 >>>> signed-off-by: John Arbuckle >>> > >>>>=20 >>>> This patch has been tested on Mac OS X host and guest.=20 >>>> Command used: qemu-system-ppc -cdrom /dev/cdrom >>>>=20 >>>> Note: I was able to view the files using OpenBIOS, but not on=20 >>>> Mac OS X. The size of the disc is reported correctly but some >>>> error happens that prevents it from mounting in Mac OS X. This >>>> is probably another bug with QEMU. >>>>=20 >>>> --- >>>> block.c | 3 ++- >>>> 1 files changed, 2 insertions(+), 1 deletions(-) >>>>=20 >>>> diff --git a/block.c b/block.c >>>> index dd4f58d..75ccfad 100644 >>>> --- a/block.c >>>> +++ b/block.c >>>> @@ -583,7 +583,8 @@ static int find_image_format(BlockDriverState = *bs, >>>> const char *filename, >>>> int ret =3D 0; >>>>=20 >>>>=20 >>>>=20 >>>> /* Return the raw BlockDriver * to scsi-generic devices or empty >>>> drives */ >>>> - if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) =3D=3D= 0) { >>>> + if (bs->sg || !bdrv_is_inserted(bs) || bdrv_getlength(bs) =3D=3D= 0=20 >>>> + || strcmp("/dev/cdrom", filename) =3D=3D 0) { >>>> *pdrv =3D &bdrv_raw; >>>> return ret; >>>> } >>>> --=20 >>>> 1.7.5.4 >>>>=20 >>>=20 >>> So what's the issue that this patch attempts to fix and how did you >>> determine that the fix was needed here? It doesn't look like it = respects >>> proper abstraction at a glance. >>=20 >> Without the patch, QEMU would just quit when the "-cdrom /dev/cdrom" = option is given. >=20 > Why does it quit? Because of a bug. This is what it prints: "Could not read image for = determining its format: Invalid argument". This message seems to = indicate that QEMU thinks the real cdrom drive is an image file.=20= --Apple-Mail-3--476131923 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
On Tue, Jun 23, 2015 at 02:26:51PM -0400, = Programmingkid wrote:

On Jun 23, = 2015, at 2:06 PM, John Snow wrote:



On 06/23/2015 01:56 PM, = Programmingkid wrote:
Fix = real cdrom detection so that a real cdrom can actually be = used.

signed-off-by: John Arbuckle <programmingkidx@gmail.com
<mailto:programmingkidx@gmail.com= >>

This = patch has been tested on Mac OS X host and guest. =
Command = used: qemu-system-ppc -cdrom = /dev/cdrom

Note: = I was able to view the files using OpenBIOS, but not on =
Mac OS = X. The size of the disc is reported correctly but = some
error = happens that prevents it from mounting in Mac OS X. = This
is = probably another bug with = QEMU.

---
block.c = |    3 = ++-
1 = files changed, 2 insertions(+), 1 = deletions(-)

diff = --git a/block.c = b/block.c
index = dd4f58d..75ccfad = 100644
--- = a/block.c
+++ = b/block.c
@@ = -583,7 +583,8 @@ static int find_image_format(BlockDriverState = *bs,
const = char *filename,
=    int ret =3D = 0;



=    /* Return the raw BlockDriver * to scsi-generic = devices or empty
drives = */
- =    if (bs->sg || !bdrv_is_inserted(bs) || = bdrv_getlength(bs) =3D=3D 0) = {
+ =    if (bs->sg || !bdrv_is_inserted(bs) || = bdrv_getlength(bs) =3D=3D 0 =
+ =             &n= bsp; || strcmp("/dev/cdrom", filename) =3D=3D 0) = {
=        *pdrv =3D = &bdrv_raw;
=        return = ret;
=    }
-- =
1.7.5.4


So what's the issue that this = patch attempts to fix and how did = you
determine that the fix was needed here? It doesn't look = like it respects
proper abstraction at a = glance.

Without the = patch, QEMU would just quit when the "-cdrom /dev/cdrom" option is = given.

Why does it = quit?

Because of a bug. This is = what it prints: "Could not read image for determining its = format: Invalid argument". This message seems to indicate that QEMU = thinks the real cdrom drive is an image = file. 
= --Apple-Mail-3--476131923--