From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLgwr-0001VQ-L1 for qemu-devel@nongnu.org; Thu, 06 Mar 2014 17:39:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLgwl-0004NC-L4 for qemu-devel@nongnu.org; Thu, 06 Mar 2014 17:39:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLgwl-0004Mz-E1 for qemu-devel@nongnu.org; Thu, 06 Mar 2014 17:39:23 -0500 Message-ID: <5318F915.9010804@redhat.com> Date: Thu, 06 Mar 2014 23:39:17 +0100 From: Max Reitz MIME-Version: 1.0 References: <1394144739-2294-1-git-send-email-mreitz@redhat.com> <1394144739-2294-4-git-send-email-mreitz@redhat.com> <20140306223737.GA28835@irqsave.net> In-Reply-To: <20140306223737.GA28835@irqsave.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/5] block/raw-posix: bdrv_parse_filename() for cdrom List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-1?Q?Beno=EEt_Canet?= Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On 06.03.2014 23:37, Beno=EEt Canet wrote: > The Thursday 06 Mar 2014 =E0 23:25:37 (+0100), Max Reitz wrote : >> The "host_cdrom" protocol drivers should strip the "host_cdrom:" prefi= x >> from filenames if present. >> >> Signed-off-by: Max Reitz >> --- >> block/raw-posix.c | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) >> >> diff --git a/block/raw-posix.c b/block/raw-posix.c >> index 4b8c183..6c9b8f2 100644 >> --- a/block/raw-posix.c >> +++ b/block/raw-posix.c >> @@ -1984,6 +1984,15 @@ static BlockDriver bdrv_host_floppy =3D { >> .bdrv_eject =3D floppy_eject, >> }; >> =20 >> +static void cdrom_parse_filename(const char *filename, QDict *options= , >> + Error **errp) >> +{ >> + /* The prefix is optional, just as for "file". */ >> + strstart(filename, "host_cdrom:", &filename); >> + >> + qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filen= ame))); >> +} >> + >> static int cdrom_open(BlockDriverState *bs, QDict *options, int flag= s, >> Error **errp) >> { >> @@ -2070,6 +2079,7 @@ static BlockDriver bdrv_host_cdrom =3D { >> .instance_size =3D sizeof(BDRVRawState), >> .bdrv_needs_filename =3D true, >> .bdrv_probe_device =3D cdrom_probe_device, >> + .bdrv_parse_filename =3D cdrom_parse_filename, >> .bdrv_file_open =3D cdrom_open, >> .bdrv_close =3D raw_close, >> .bdrv_reopen_prepare =3D raw_reopen_prepare, >> @@ -2101,6 +2111,15 @@ static BlockDriver bdrv_host_cdrom =3D { >> #endif /* __linux__ */ >> =20 >> #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) >> +static void cdrom_parse_filename(const char *filename, QDict *options= , >> + Error **errp) >> +{ >> + /* The prefix is optional, just as for "file". */ >> + strstart(filename, "host_cdrom:", &filename); >> + >> + qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filen= ame))); >> +} >> + > The cdrom_probe_device and cdrom_open function actually differs and are= not > duplicated whereas these two instances of cdrom_parse_filename are pret= ty much > the same. > Why not putting a merged version on the top of the file and guarded by > #if defined(__linux__) || defined (__FreeBSD__) || defined(__FreeBSD_= kernel__) > ? I didn't want to since the #ifdef linux began before the floppy driver=20 and ended after the Linux CD-ROM driver, so I'd have to split it up. But=20 since you're suggesting it now, I'll do it. ;-) Max >> static int cdrom_open(BlockDriverState *bs, QDict *options, int flag= s, >> Error **errp) >> { >> @@ -2200,6 +2219,7 @@ static BlockDriver bdrv_host_cdrom =3D { >> .instance_size =3D sizeof(BDRVRawState), >> .bdrv_needs_filename =3D true, >> .bdrv_probe_device =3D cdrom_probe_device, >> + .bdrv_parse_filename =3D cdrom_parse_filename, >> .bdrv_file_open =3D cdrom_open, >> .bdrv_close =3D raw_close, >> .bdrv_reopen_prepare =3D raw_reopen_prepare, >> --=20 >> 1.9.0 >>